[PATCH] [InstCombine] Added check for NUW flag.
Ilya Krotov
krotov-ilua at mail.ru
Fri May 8 10:26:04 PDT 2015
Hi dblaikie, djasper,
Check if we can add NUW flag. If so, set this.
http://reviews.llvm.org/D9610
Files:
InstructionCombining.cpp
Index: InstructionCombining.cpp
===================================================================
--- InstructionCombining.cpp
+++ InstructionCombining.cpp
@@ -502,22 +502,27 @@
++NumFactor;
SimplifiedInst->takeName(&I);
- // Check if we can add NSW flag to SimplifiedInst. If so, set NSW flag.
- // TODO: Check for NUW.
+ // Check if we can add NSW/NUW flag to SimplifiedInst. If so, set NSW/NUW flag.
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(SimplifiedInst)) {
if (isa<OverflowingBinaryOperator>(SimplifiedInst)) {
bool HasNSW = false;
- if (isa<OverflowingBinaryOperator>(&I))
+ bool HasNUW = false;
+ if (isa<OverflowingBinaryOperator>(&I)){
HasNSW = I.hasNoSignedWrap();
-
+ HasNUW = I.hasNoUnsignedWrap();
+ }
if (BinaryOperator *Op0 = dyn_cast<BinaryOperator>(LHS))
- if (isa<OverflowingBinaryOperator>(Op0))
+ if (isa<OverflowingBinaryOperator>(Op0)){
HasNSW &= Op0->hasNoSignedWrap();
-
+ HasNUW &= Op0->hasNoUnsignedWrap();
+ }
if (BinaryOperator *Op1 = dyn_cast<BinaryOperator>(RHS))
- if (isa<OverflowingBinaryOperator>(Op1))
+ if (isa<OverflowingBinaryOperator>(Op1)){
HasNSW &= Op1->hasNoSignedWrap();
+ HasNUW &= Op1->hasNoUnsignedWrap();
+ }
BO->setHasNoSignedWrap(HasNSW);
+ BO->setHasNoUnsignedWrap(HasNUW);
}
}
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9610.25345.patch
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150508/0fe7efa5/attachment.bin>
More information about the llvm-commits
mailing list