diff options
| author | Brandon <61314499+brandonxin@users.noreply.github.com> | 2025-10-24 03:26:08 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-24 08:26:08 +0000 |
| commit | ea2de9aaa64ac5e20a9c7898864760c1086e0f8c (patch) | |
| tree | 05a5b1cdaa82d0cc4dfcd30b043e7ea64c341950 /lldb/packages/Python/lldbsuite/test/configuration.py | |
| parent | 6b30d2104084eda539278097b6b16215a7c908d7 (diff) | |
| download | llvm-ea2de9aaa64ac5e20a9c7898864760c1086e0f8c.zip llvm-ea2de9aaa64ac5e20a9c7898864760c1086e0f8c.tar.gz llvm-ea2de9aaa64ac5e20a9c7898864760c1086e0f8c.tar.bz2 | |
[X86] Fold generic ADD/SUB with constants to X86ISD::SUB/ADD (#164316)
Fix #163125
This PR enhances `combineX86AddSub` so that it can handle `X86ISD::SUB(X,Constant)` with `add(X,-Constant)` and other similar cases:
- `X86ISD::ADD(LHS, C)` will fold `sub(-C, LHS)`
- `X86ISD::SUB(LHS, C)` will fold `add(LHS, -C)`
- `X86ISD::SUB(C, RHS)` will fold `add(RHS, -C)`
`CodeGen/X86/dag-update-nodetomatch.ll` is updated because following IR is folded:
```llvm
for.body2:
; ......
; This generates `add t6, Constant:i64<1>`
%indvars.iv.next = add nsw i64 %indvars.iv, 1;
; This generates `X86ISD::SUB t6, Constant:i64<-1>` and folds the previous `add`
%cmp = icmp slt i64 %indvars.iv, -1;
br i1 %cmp, label %for.body2, label %for.cond1.for.inc3_crit_edge.loopexit
```
```diff
- ; CHECK-NEXT: movq (%r15), %rax
- ; CHECK-NEXT: movq %rax, (%r12,%r13,8)
- ; CHECK-NEXT: leaq 1(%r13), %rdx
- ; CHECK-NEXT: cmpq $-1, %r13
- ; CHECK-NEXT: movq %rdx, %r13
+ ; CHECK-NEXT: movq (%r12), %rax
+ ; CHECK-NEXT: movq %rax, (%r13,%r9,8)
+ ; CHECK-NEXT: incq %r9
```
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/configuration.py')
0 files changed, 0 insertions, 0 deletions
