[RISCV] Teach RISCVCodeGenPrepare to optimize (zext (abs(i32 X, i1 1))).
(abs(i32 X, i1 1) always produces a positive result. The 'i1 1' means INT_MIN input produces poison. If the result is sign extended, InstCombine will convert it to zext. This does not produce ideal code for RISCV. This patch reverses the zext back to sext which can be folded into a subw or negw. Ideally we'd do this in SelectionDAG, but we lose the INT_MIN poison flag when llvm.abs becomes ISD::ABS. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D130412
Loading
Please sign in to comment