diff options
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index ead8aa6..83c6ecd 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -7138,6 +7138,7 @@ bool CodeGenPrepare::optimizeLoadExt(LoadInst *Load) { SmallVector<Instruction *, 8> WorkList; SmallPtrSet<Instruction *, 16> Visited; SmallVector<Instruction *, 8> AndsToMaybeRemove; + SmallVector<Instruction *, 8> DropFlags; for (auto *U : Load->users()) WorkList.push_back(cast<Instruction>(U)); @@ -7185,6 +7186,7 @@ bool CodeGenPrepare::optimizeLoadExt(LoadInst *Load) { return false; uint64_t ShiftAmt = ShlC->getLimitedValue(BitWidth - 1); DemandBits.setLowBits(BitWidth - ShiftAmt); + DropFlags.push_back(I); break; } @@ -7192,6 +7194,7 @@ bool CodeGenPrepare::optimizeLoadExt(LoadInst *Load) { EVT TruncVT = TLI->getValueType(*DL, I->getType()); unsigned TruncBitWidth = TruncVT.getSizeInBits(); DemandBits.setLowBits(TruncBitWidth); + DropFlags.push_back(I); break; } @@ -7249,6 +7252,10 @@ bool CodeGenPrepare::optimizeLoadExt(LoadInst *Load) { ++NumAndUses; } + // NSW flags may not longer hold. + for (auto *Inst : DropFlags) + Inst->setHasNoSignedWrap(false); + ++NumAndsAdded; return true; } |