[llvm] [X86] Fix CCMP miscompile for flag-source-folded SETCC leaves (PR #217682)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 20:01:26 PDT 2026
================
@@ -25736,23 +25739,52 @@ static SDValue emitConjunctionForCCMPRec(SDValue Val, X86::CondCode &OutCC,
assert(X86CC != X86::COND_INVALID);
OutCC = X86CC;
- SDValue Flags = EmitCmp(LHS, RHS, X86CC, DL, DAG, Subtarget);
- // Produce a normal comparison if we are first in the chain.
+ // Produce a normal comparison if we are first in the chain. Only there may
+ // EmitCmp fold the comparison into the EFLAGS of an existing arithmetic or
+ // logic node: those flags are unconditional, which is exactly what the root
+ // of the chain needs.
if (!CCOp)
- return Flags;
+ return EmitCmp(LHS, RHS, X86CC, DL, DAG, Subtarget);
----------------
phoebewang wrote:
Looks like we can use it in non-root as long as the node is a SUB. Anyway, let's fix miscompilation first.
https://github.com/llvm/llvm-project/pull/217682
More information about the llvm-commits
mailing list