[llvm] [DAGCombiner] Fix the "subtraction if above a constant threshold" miscompile (PR #140042)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 02:26:37 PDT 2025
================
@@ -12140,11 +12140,16 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
// (select (ult x, C), x, (add x, -C)) -> (umin x, (add x, -C))
APInt C;
if (sd_match(Cond1, m_ConstInt(C)) && hasUMin(VT)) {
----------------
bjope wrote:
nit: Could add a small comment here telling why we need to recreate the ADD. Just to avoid that someone tries to simplify this in the future, or if someone wonder why we can do this without introducing FREEZE.
Maybe something like this:
` // Need to drop any poison generating flags from the ADD, to ensure that the result isn't more poisonous.`
https://github.com/llvm/llvm-project/pull/140042
More information about the llvm-commits
mailing list