[PATCH] D41949: [RISCV] implement li pseudo instruction
Sameer AbuAsal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 17 18:20:40 PDT 2018
sabuasal added a comment.
Hi,
This patch causes repeated LUI generation for the following test case :
void foo (int num, int* addr) {
addr[0] = num*4097;
addr[1] = num*4098;
addr[2] = num*4099;
addr[3] = num*4100;
}
Without patch:
1. lui a0, 1
2. addi a3, a0, 2
3. mul a3, a1, a3
4. sw a3, 4(a2)
5. addi a3, a0, 1
6. mul a3, a1, a3
7. sw a3, 0(a2)
8. addi a3, a0, 3
9. mul a3, a1, a3
10. sw a3, 8(a2)
11. addi a0, a0, 4
12. mul a0, a1, a0
13. sw a0, 12(a2)
14. ret
with patch:
1. lui a0, 1
2. addi a0, a0, 2
3. mul a0, a1, a0
4. sw a0, 4(a2)
5. lui a0, 1 repeated lui!
6. addi a0, a0, 1
7. mul a0, a1, a0
8. sw a0, 0(a2)
9. lui a0, 1 ---> repeated load
10. addi a0, a0, 3
11. mul a0, a1, a0
12. sw a0, 8(a2)
13. lui a0, 1 ---> repeated load
14. addi a0, a0, 4
15. mul a0, a1, a0
16. sw a0, 12(a2)
17. ret
I think this is bacuse we are hiding the %hi part f the immediate from the Selection Dag so it doesn't optimize it away.
Sorry for the late reply. I thought you were going to hold off committing this till the compression issue is addressed.
Repository:
rL LLVM
https://reviews.llvm.org/D41949
More information about the llvm-commits
mailing list