[llvm] Support replacing `add rd, Zero, Zero` with `c.li rd, 0` (PR #86937)
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 08:01:03 PDT 2024
asb wrote:
> Why should add rd, Zero, Zero be special? If we support this, shouldn't we do it for And, Or, Xor, Sll, Srl, Sra that all produce 0 with x0, x0 arguments?
>
> Given the number of cases, I don't think we should do this.
I'd say it's more likely that `add rd, zero, zero` is written by a less experienced programmer meaning to have the effect of `li, rd, 0`. But at that point we're picking and choosing which edge cases we handle here which I admit is less attractive vs being able to say "we compress all instructions if possible". I don't feel too strongly about this.
https://github.com/llvm/llvm-project/pull/86937
More information about the llvm-commits
mailing list