[llvm] [WebAssembly] Don't fold non-nuw add/sub in FastISel (PR #111278)

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 09:15:24 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())
----------------
dschuff wrote:

Do you have any sense of how often this happens, i.e. how often these address-calculation adds lack `nuw`? It would be a bummer if we bailed out of fast-isel for the majority of address-calculations (since bailing out forces the whole block to be re-selected, it could potentially regress compile time noticeably).

https://github.com/llvm/llvm-project/pull/111278


More information about the llvm-commits mailing list