[RISCV] Relax a one use restriction performSRACombine
authorCraig Topper <craig.topper@sifive.com>
Thu, 4 Aug 2022 18:16:27 +0000 (11:16 -0700)
committerCraig Topper <craig.topper@sifive.com>
Thu, 4 Aug 2022 18:25:08 +0000 (11:25 -0700)
commita2de12c987339f228f7fa412222f7e7746e220ed
treeae0f0a2b115003465087326e6e9bde3d84424b0e
parentbefa77e59a7760d8c4fdd177b234e4a59500f61c
[RISCV] Relax a one use restriction performSRACombine

When folding (sra (add (shl X, 32), C1), 32 - C) -> (shl (sext_inreg (add X, C1), C)
ignore the use count on the (shl X, 32).

The sext_inreg after the transform is free. So we're only making
2 new instructions, the add and the shl. So we only need to be
concerned with replacing the original sra+add. The original shl
can have other uses. This helps if there are multiple different
constants being added to the same shl.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rv64i-shift-sext.ll