diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-04-22 22:42:05 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-04-22 22:42:05 +0000 |
| commit | 7d0e99c6019ca1c4c6708309ef5dade0db03b425 (patch) | |
| tree | ab617ef7dee6f4e251678779e1cbe578abb7d2c0 /llvm/lib/Transforms | |
| parent | 64a2a6a473553f178b74c785722d4f8dfd6b9eb1 (diff) | |
| download | bcm5719-llvm-7d0e99c6019ca1c4c6708309ef5dade0db03b425.tar.gz bcm5719-llvm-7d0e99c6019ca1c4c6708309ef5dade0db03b425.zip | |
[InstCombine] Use a more targeted fix instead of r235544
Only clear out the NSW/NUW flags if we are optimizing 'add'/'sub' while
taking advantage that the sign bit is not set. We do this optimization
to further shrink the mask but shrinking the mask isn't NSW/NUW
preserving in this case.
llvm-svn: 235558
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 0695ec17e36..3dbb1b190be 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -88,13 +88,6 @@ bool InstCombiner::SimplifyDemandedBits(Use &U, APInt DemandedMask, KnownOne, Depth, UserI); if (!NewVal) return false; U = NewVal; - - // Shrinking a constant might cause a nsw/nuw violation to occur in - // instructions which are themselves demanded. - if (auto *UserOBO = dyn_cast<OverflowingBinaryOperator>(UserI)) { - cast<BinaryOperator>(UserOBO)->setHasNoSignedWrap(false); - cast<BinaryOperator>(UserOBO)->setHasNoUnsignedWrap(false); - } return true; } @@ -607,8 +600,11 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, if (SimplifyDemandedBits(I->getOperandUse(0), DemandedFromOps, LHSKnownZero, LHSKnownOne, Depth + 1) || SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps, - LHSKnownZero, LHSKnownOne, Depth + 1)) + LHSKnownZero, LHSKnownOne, Depth + 1)) { + cast<BinaryOperator>(I)->setHasNoSignedWrap(false); + cast<BinaryOperator>(I)->setHasNoUnsignedWrap(false); return I; + } } } break; @@ -624,8 +620,11 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, if (SimplifyDemandedBits(I->getOperandUse(0), DemandedFromOps, LHSKnownZero, LHSKnownOne, Depth + 1) || SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps, - LHSKnownZero, LHSKnownOne, Depth + 1)) + LHSKnownZero, LHSKnownOne, Depth + 1)) { + cast<BinaryOperator>(I)->setHasNoSignedWrap(false); + cast<BinaryOperator>(I)->setHasNoUnsignedWrap(false); return I; + } } // Otherwise just hand the sub off to computeKnownBits to fill in |

