[llvm] [X86] Optimized ADD + ADC to ADC (PR #173543)
Sebastian Buchwald via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 2 14:23:54 PST 2026
================
@@ -18,15 +18,18 @@ define i32 @test_i32_add_add_idx(i32 %x, i32 %y, i32 %z) nounwind {
; X86-LABEL: test_i32_add_add_idx:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: addl {{[0-9]+}}(%esp), %eax
; X86-NEXT: btl $30, {{[0-9]+}}(%esp)
-; X86-NEXT: adcl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: adcl $0, %eax
----------------
UniQP wrote:
This should not change.
It looks like `needCarryOrOverflowFlag` looks at users of the `SDNode` rather than at users of the passed `SDValue`. The following change should fix this:
```diff
static bool needCarryOrOverflowFlag(SDValue Flags) {
assert(Flags.getValueType() == MVT::i32 && "Unexpected VT!");
- for (const SDNode *User : Flags->users()) {
+ for (const SDUse &Use : Flags->uses()) {
+ if (Use != Flags)
+ continue;
+ const SDNode* User = Use.getUser();
X86::CondCode CC;
switch (User->getOpcode()) {
default:
```
https://github.com/llvm/llvm-project/pull/173543
More information about the llvm-commits
mailing list