Issue 173408
Summary [X86] Missed combining of `adc` + `add` with constant arguments
Labels new issue
Assignees
Reporter UniQP
    For the following code, the generated `adc` and `add` instructions can be combined into a single `adc` instruction.

Compiler explorer: https://godbolt.org/z/95v4x53Ef

```llvm
define i32 @test(i32 %0, i32 %1, i32 %2) {
  %4 = icmp ult i32 %0, %1
  %5 = zext i1 %4 to i32
  %6 = add i32 %2, 42
  %7 = add i32 %6, %5
  %8 = icmp slt i32 %7, 0
  %9 = select i1 %8, i32 %1, i32 %0
  ret i32 %9
}
```

Output:
```assembly
test:
 mov     eax, edi
        cmp     edi, esi
        adc     edx, 0
 add     edx, 42
        cmovs   eax, esi
 ret
```

Expected:
```assembly
test:
        mov     eax, edi
 cmp     edi, esi
        adc     edx, 42
        cmovs   eax, esi
 ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to