Commit 5f02043
committed
[AArch64] prevent (shl (srl x, c1), c2) -> (and (shift x, c3)) when load
Currently, process of replacing bitwise operations consisting of
`(shl (srl x, c1), c2)` with `And` is performed by `DAGCombiner`.
However, in certain case like `(shl (srl, x, c1) 2)` is do not
need to transform to `AND` if it was used to `Load` Target.
Consider following case:
```
lsr x8, x8, #56
and x8, x8, #0xfc
ldr w0, [x2, x8]
ret
```
In this case, we can remove the `AND` by changing the target of `LDR`
to `[X2, X8, LSL #2]` and right-shifting amount change to 56 to 58.
after changed:
```
lsr x8, x8, #58
ldr w0, [x2, x8, lsl #2]
ret
```
This patch checks to see if the `(shl (srl x, c1) 2)` operation on
`load` target can be prevent transform to `And`.1 parent 5251d57 commit 5f02043
File tree
2 files changed
+24
-8
lines changed- llvm
- lib/Target/AArch64
- test/CodeGen/AArch64
2 files changed
+24
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16918 | 16918 | | |
16919 | 16919 | | |
16920 | 16920 | | |
| 16921 | + | |
| 16922 | + | |
| 16923 | + | |
| 16924 | + | |
| 16925 | + | |
| 16926 | + | |
| 16927 | + | |
| 16928 | + | |
| 16929 | + | |
| 16930 | + | |
| 16931 | + | |
| 16932 | + | |
| 16933 | + | |
| 16934 | + | |
| 16935 | + | |
| 16936 | + | |
| 16937 | + | |
| 16938 | + | |
16921 | 16939 | | |
16922 | 16940 | | |
16923 | 16941 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
39 | | - | |
| 37 | + | |
| 38 | + | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 52 | + | |
| 53 | + | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
| |||
0 commit comments