[PATCH] D117450: [LoopInterchange] Support loop interchange with floating point reductions

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 06:49:13 PST 2022


Meinersbur added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopInterchange.cpp:900
+      Instruction *I = dyn_cast<Instruction>(followLCSSA(&PHI));
+      if (!F->getFnAttribute("unsafe-fp-math").getValueAsBool() ||
+          I == nullptr || !I->isFast())
----------------
I couldn't find a reference for `unsafe-fp-math`, but I would have guessed that it forces all instructions to be fast-math, even if not marked as fast. If already marked as fast, then no additional tag `unsafe-fp-math` should be necessary.

Instead of `isFast`, would `allowReassoc` be sufficient (or whatever flag controls commutativity)?

The logic here will check only one fp instruction. What if two instructions are involved? Such as:
```
  for (...)
    for (...) {
      sum += A[i];
      sum += B[j];
   }
print(sum);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117450/new/

https://reviews.llvm.org/D117450



More information about the llvm-commits mailing list