Commit b380592
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 1b500fb commit b380592
File tree
2 files changed
+35
-25
lines changed- llvm
- lib/Target/AArch64
- test/CodeGen/AArch64
2 files changed
+35
-25
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 | + | |
16921 | 16938 | | |
16922 | 16939 | | |
16923 | 16940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
| |||
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
42 | | - | |
| 39 | + | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | | - | |
57 | | - | |
58 | | - | |
| 54 | + | |
| 55 | + | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
72 | | - | |
73 | | - | |
| 69 | + | |
| 70 | + | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 84 | + | |
| 85 | + | |
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
| |||
100 | 96 | | |
101 | 97 | | |
102 | 98 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 99 | + | |
| 100 | + | |
106 | 101 | | |
107 | 102 | | |
108 | 103 | | |
| |||
116 | 111 | | |
117 | 112 | | |
118 | 113 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 114 | + | |
| 115 | + | |
122 | 116 | | |
123 | 117 | | |
124 | 118 | | |
| |||
132 | 126 | | |
133 | 127 | | |
134 | 128 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 129 | + | |
| 130 | + | |
138 | 131 | | |
139 | 132 | | |
140 | 133 | | |
| |||
0 commit comments