[llvm] [SCEV] Retain SCEVSequentialMinMaxExpr if an operand may trigger UB. (PR #92177)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 03:17:00 PDT 2024


================
@@ -510,9 +510,12 @@ class SCEVUMinExpr : public SCEVMinMaxExpr {
 
 /// This node is the base class for sequential/in-order min/max selections.
 /// Note that their fundamental difference from SCEVMinMaxExpr's is that they
-/// are early-returning upon reaching saturation point.
-/// I.e. given `0 umin_seq poison`, the result will be `0`,
-/// while the result of `0 umin poison` is `poison`.
+/// are early-returning
+///  * upon reaching saturation point
+///    I.e. given `0 umin_seq poison`, the result will be `0`,
+///    while the result of `0 umin poison` is `poison`.
+///  * if any operand may trigger UB, e.g. if there is an UDiv operand that may
+///    divide by 0.
----------------
nikic wrote:

These aren't really two separate cases. The "early return" happens "upon reaching the saturation point" in both cases. The clarification here is just that "early return" is in the sense that the RHS will not be executed at all (even if it has UB), rather than only that its value will not be used.

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


More information about the llvm-commits mailing list