[all-commits] [llvm/llvm-project] e196a7: [X86] Fix CCMP miscompile for flag-source-folded S...
Evgenii Kudriashov via All-commits
all-commits at lists.llvm.org
Tue Sep 29 13:00:40 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e196a7e873c01c7176345541167ecd3fcb60f2e4
https://github.com/llvm/llvm-project/commit/e196a7e873c01c7176345541167ecd3fcb60f2e4
Author: Evgenii Kudriashov <evgenii.kudriashov at intel.com>
Date: 2026-09-29 (Tue, 29 Sep 2026)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/apx/ccmp-flag-source.ll
Log Message:
-----------
[X86] Fix CCMP miscompile for flag-source-folded SETCC leaves (#217682)
EmitCmp does not always return a comparison: where
it can it reuses the EFLAGS of an instruction that is computed anyway,
so (X | Y) == 0 comes back as the flags of an X86ISD::OR, (X & Y) == 0
as those of an X86ISD::AND, and (0 - X) == Y is rewritten into
(X + Y) == 0 and comes back as the flags of an X86ISD::ADD.
Only a subtract (CCMP) and an AND (CTEST) have conditional forms, so
build the link from the comparison's own operands rather than from a
flag source:
A comparison with zero can set neither OF nor CF, and TEST clears both,
so the last two are flag-equivalent for every condition code. An equality
comparison is a test of the operands' XOR, so an already live XOR is still
reused instead of keeping both operands live.
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list