[PATCH] D149423: [ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to speculate

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 12:39:24 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:6042
+    if (!isGuaranteedNotToBePoison(Inst->getOperand(1), AC, CtxI, DT,
+                                   /*Depth*/ 0) ||
+        !isKnownNonZero(Inst->getOperand(1), DL, /*Depth*/ 0, AC, CtxI, DT))
----------------
Omit Depth=0, which is the default.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:6046
+
+    // Unsigned case only need to avoid denominator == 0 or poison.
+    if (Opcode == Instruction::UDiv || Opcode == Instruction::URem)
----------------
either case -> cases or need -> needs.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:6062
+        computeKnownBits(Inst->getOperand(0), DL, /*Depth*/ 0, AC, CtxI, DT);
+    return !KnownNumerator.getSignedMinValue().isMinSignedValue();
   }
----------------
This also needs to check that op0 is not poison.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149423



More information about the llvm-commits mailing list