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

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 04:37:44 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:

> and see if this is really regressing -O0 compilation times a lot

I can get some PIN (binary instrumentation) data on this change with our input - it should not take a lot of time (mainly building clang itself).

However, after looking at the code, I have a more basic question: why `return false` and not `break`? I don't think there is a need to support complex addressing modes with two registers, we can presumably just use the non-`nuw` `add` as the one and only base register (with a zero offset), which, if I am reading the code correctly, is what `break`ing will do.

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


More information about the llvm-commits mailing list