[llvm] [WebAssembly] Don't fold non-nuw add/sub in FastISel (PR #111278)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 09:55:49 PDT 2024
================
@@ -337,6 +337,12 @@ bool WebAssemblyFastISel::computeAddress(const Value *Obj, Address &Addr) {
break;
}
case Instruction::Add: {
+ // We should not fold operands into an offset when 'nuw' (no unsigned wrap)
+ // is not present, because the address calculation does not wrap.
+ if (auto *OFBinOp = dyn_cast<OverflowingBinaryOperator>(U))
+ if (!OFBinOp->hasNoUnsignedWrap())
----------------
SingleAccretion wrote:
I would assume this will be frontend-dependent. For C/C++ input, it should be rare because address arithmetic is all `inbounds` GEPs. For the input [we](https://github.com/llvm/llvm-project/issues/111018#issuecomment-2397415761) have, it will be very common.
https://github.com/llvm/llvm-project/pull/111278
More information about the llvm-commits
mailing list