| Issue |
60989
|
| Summary |
[optimization] fold the shift into the offset of memory access instruction
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
vfdff
|
* test: https://gcc.godbolt.org/z/68zEq8x81
```
void update (uint32_t *histogram, uint32_t *records, uint32_t num_records)
{
for (uint32_t i = 0; i < num_records; i++)
histogram[records[i]] += 1;
}
```
* gcc
```
.L3:
ldr w3, [x1], 4
ldr w2, [x0, x3, lsl 2]
add w2, w2, 1
str w2, [x0, x3, lsl 2]
cmp x1, x4
bne .L3
```
* llvm
```
.LBB0_2: // =>This Inner Loop Header: Depth=1
ldr w9, [x1], #4
subs x8, x8, #1
lsl x9, x9, #2 // the shift operand can be fold into address offset ?
ldr w10, [x0, x9]
add w10, w10, #1
str w10, [x0, x9]
b.ne .LBB0_2
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs