[PATCH] D116720: [RISCV] Use shift for zext.h when Zbb and Zbp are not enabled
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 00:27:52 PST 2022
benshi001 added a comment.
I also concern that the 0xffff has multiple uses, such as
unsigned short foo(unsigned short a, unsigned short b, int c, int d) {
return (a >> c) + (b >> d);
}
And there is only one immediate 0xffff is materialized.
foo:
srl a0, a0, a2
srl a1, a1, a3
add a0, a0, a1
lui a1, 16
addi a1, a1, -1
and a0, a0, a1
ret
Using a pass seems to be better, two cases should be excluded,
1. in a loop body
2. 0xffff has multiple uses
What's more, the pass can be generalized to a common immediate optimization pass, which combines several small optimization rules, just like AArch64's AArch64MIPeepholeOpt pass. However we need not make is so complex in current patch, that would be something TODO in the future.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116720/new/
https://reviews.llvm.org/D116720
More information about the llvm-commits
mailing list