[llvm] [CodeGenPrepare] don't promote sdiv/srem by -1 (PR #218737)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 00:20:20 PDT 2026


================
@@ -8367,16 +8367,13 @@ class VectorPromoteHelper {
   /// Check if it is profitable to promote \p ToBePromoted
   /// by moving downward the transition through.
   bool shouldPromote(const Instruction *ToBePromoted) const {
+    if (!isSafeToSpeculativelyExecuteWithVariableReplaced(ToBePromoted))
+      return false;
     // Promote only if all the operands can be statically expanded.
     // Indeed, we do not want to introduce any new kind of transitions.
     for (const Use &U : ToBePromoted->operands()) {
       const Value *Val = U.get();
       if (Val == getEndOfTransition()) {
-        // If the use is a division and the transition is on the rhs,
-        // we cannot promote the operation, otherwise we may create a
-        // division by zero.
-        if (canCauseUndefinedBehavior(ToBePromoted, U.getOperandNo()))
----------------
im-lunex wrote:

Okay, i did so. Can I work on this as a follow-up? 

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


More information about the llvm-commits mailing list