[PATCH] D144045: [InstCombine] Avoid sinking fdiv into a loop

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 03:27:43 PDT 2023


sdesmalen added a comment.

Did you do any performance runs to check if there were regressions? If so, we'd need to change some of the InstCombine instances to run in a different mode (suggestion (2) <https://reviews.llvm.org/D144045#4292250>) by explicitly forcing the canonical form regardless of LoopInfo. If not, I'm not sure if such an option is still worth adding.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:663-669
+      bool ShouldSink = false;
+      Loop *L = LI ? LI->getLoopFor(I.getParent()) : nullptr;
+      if (!L) {
+        // The fdiv should always be an instruction so the cast is safe.
+        ShouldSink = cast<Instruction>(FDiv)->getParent() == I.getParent();
+      } else if (!L->isLoopInvariant(FDiv))
+        ShouldSink = true;
----------------
Is this equivalent to:

  bool ShouldSink = L ? !L->isLoopInvariant(FDiv) : cast<Instruction>(FDiv)->getParent() == I.getParent();

?


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

https://reviews.llvm.org/D144045



More information about the llvm-commits mailing list