Commit 1e40d92
Automerge: [X86] Fix X86 conditional load/store optimization for non-constant operands (#163353)
This PR fixes a bug in combineX86CloadCstore where an optimization was
being applied too broadly, causing incorrect code generation.
Without any assumptions about `X` this transformation is only valid when
`Y` is a non zero power of two/single-bit mask.
```cpp
// res, flags2 = sub 0, (and (xor X, -1), Y)
// cload/cstore ..., cond_ne, flag2
// ->
// res, flags2 = sub 0, (and X, Y)
// cload/cstore ..., cond_e, flag2
```
We can restrict the optimization to most important case, so only apply
when `llvm::isOneConstant(Op1.getOperand(1))`. It might be not trivial
to find code that creates a SelectionDag with other values of `Y`.
Basline test: llvm/llvm-project#163354File tree
2 files changed
+6
-4
lines changed- llvm
- lib/Target/X86
- test/CodeGen/X86/apx
2 files changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58342 | 58342 | | |
58343 | 58343 | | |
58344 | 58344 | | |
58345 | | - | |
58346 | | - | |
| 58345 | + | |
| 58346 | + | |
| 58347 | + | |
58347 | 58348 | | |
58348 | 58349 | | |
58349 | | - | |
| 58350 | + | |
58350 | 58351 | | |
58351 | 58352 | | |
58352 | 58353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
238 | 239 | | |
239 | 240 | | |
240 | | - | |
| 241 | + | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| |||
0 commit comments