[RISCV] Expand i32 abs to negw+max at isel.
authorCraig Topper <craig.topper@sifive.com>
Tue, 15 Nov 2022 03:37:04 +0000 (19:37 -0800)
committerCraig Topper <craig.topper@sifive.com>
Tue, 15 Nov 2022 03:44:05 +0000 (19:44 -0800)
commitdde8423f21fb09c77b83d1ec50d5fff6bb940586
tree0cd5d700e2660a2ebcf70443ad9d8f0505c0625f
parent17737437ed7bb4ca646020b17df822865247d193
[RISCV] Expand i32 abs to negw+max at isel.

This adds a RISCVISD::ABSW to remember that we started with an i32
abs. Previously we used a DAG combine of (sext_inreg (abs)) to
delay emitting a freeze from type legalization in order to make
ComputeNumSignBits optimizations work on other promoted nodes.

This new approach always uses negw+max even if the result doesn't
need to be sign extended. This helps the RISCVSExtWRemoval pass
if the sext.w is in another basic block.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
llvm/test/CodeGen/RISCV/iabs.ll
llvm/test/CodeGen/RISCV/neg-abs.ll
llvm/test/CodeGen/RISCV/rv64zbb.ll