[PATCH] D149132: [LICM] Reassociate & hoist add expressions

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 12:50:30 PDT 2023


nikic added a comment.

Proof: https://alive2.llvm.org/ce/z/imgdNt

Somewhat skeptical about introducing SCEV use in LICM. As you are actually reasoning about loop invariants here, do we need SCEV? Would using computeOverflowForSignedSub() from ValueTracking work, possibly even provide better results?



================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2591-2594
+  const SCEV *InvariantOpS = SE.getNegativeSCEV(SE.getSCEV(InvariantOp));
+  if (!SE.willNotOverflow(Instruction::BinaryOps::Add, /*Signed*/ true, RHSS,
+                          InvariantOpS, /*CtxI*/ &I))
+    return false;
----------------
This seems more obvious and matches the generated sub?


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

https://reviews.llvm.org/D149132



More information about the llvm-commits mailing list