[RISCV] Teach RISCVSExtWRemoval to remove sext.w whose upper bits aren't demanded.
authorCraig Topper <craig.topper@sifive.com>
Thu, 15 Dec 2022 19:01:20 +0000 (11:01 -0800)
committerCraig Topper <craig.topper@sifive.com>
Thu, 15 Dec 2022 19:01:20 +0000 (11:01 -0800)
commit992bee045b7586774ffd539bb46d9a1e22896f60
tree1d714316528a0ba86e3250942926292d4d1df284
parenta3b4feff2503f805aed898defbdb0ea30d7ed44a
[RISCV] Teach RISCVSExtWRemoval to remove sext.w whose upper bits aren't demanded.

SelectionDAG aggressively creates sext_inreg operations after
promoting an i32 add. If the add is later matched to a sh1add,
sh2add or sh3add, a sext.w from the sext_inreg will get left behind.
In many cases we can prove this sext.w is unnecessary by checking
if its upper bits are ever used.
llvm/lib/Target/RISCV/RISCVSExtWRemoval.cpp
llvm/test/CodeGen/RISCV/sextw-removal.ll