[RISCV][LegalizeTypes] Teach type legalizer that it can promote UMIN/UMAX using SExtP...
authorCraig Topper <craig.topper@sifive.com>
Fri, 27 Nov 2020 19:20:24 +0000 (11:20 -0800)
committerCraig Topper <craig.topper@sifive.com>
Fri, 27 Nov 2020 19:37:25 +0000 (11:37 -0800)
commitfa0f01a3c0e1bdc1a0b4e1188445335184eae03c
treef9f7ea630ec9379f41256a735f0c1b45503b5362
parentf325b4bbceb5e680e64532dd018b3c0a36d1b01a
[RISCV][LegalizeTypes] Teach type legalizer that it can promote UMIN/UMAX using SExtPromotedInteger if that's better for the target.

If Sext is cheaper than Zext for a target, we can use that to promote the operands of UMIN/UMAX. Using sext just makes numbers with the sign bit set even larger when treated as an unsigned number and it has no effect on number without the sign bit set. So the relative order doesn't change. This is similar to what we already do for promoting SETCC.

This is helpful on RISCV where i32 arguments are sign extended on RV64 and many instructions are able to produce results with 33 sign bits.

Differential Revision: https://reviews.llvm.org/D92128
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/test/CodeGen/RISCV/rv64Zbb.ll