diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2024-12-01 11:25:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-01 11:25:31 +0800 |
commit | 6568ceb9fa1c49383b2fa102a04fd8fd3af01491 (patch) | |
tree | b96c544171c1786cd5cc8a865f39f935ec77c70f /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 1c7e4074b1efe7c3c9110f1d116b16f50fce9c88 (diff) | |
download | llvm-6568ceb9fa1c49383b2fa102a04fd8fd3af01491.zip llvm-6568ceb9fa1c49383b2fa102a04fd8fd3af01491.tar.gz llvm-6568ceb9fa1c49383b2fa102a04fd8fd3af01491.tar.bz2 |
[CodeGenPrepare] Drop nsw flags in `optimizeLoadExt` (#118180)
Alive2: https://alive2.llvm.org/ce/z/pMcD7q
Closes https://github.com/llvm/llvm-project/issues/118172.
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; } |