[RISCV] Add test case showing unnecessary extend after i32 smax on rv64. NFC
authorCraig Topper <craig.topper@sifive.com>
Thu, 2 Jun 2022 16:37:05 +0000 (09:37 -0700)
committerCraig Topper <craig.topper@sifive.com>
Thu, 2 Jun 2022 16:58:11 +0000 (09:58 -0700)
commit01ba470826a84a8d73e88916605b838bb962f52a
tree8fb1a3ee8f6a8d31225c1594244d44c7704353b8
parent3da4f9c57b15b3d76b8acbaa8c2b420ad525fa25
[RISCV] Add test case showing unnecessary extend after i32 smax on rv64. NFC

One of the operands of the smax is a positive value so computeKnownBits
determines the result of the smax must always be positive. This allows
DAG combiner to convert the sign extend to zero extend before type
legalization.

After type legalization the smax is promoted to i64 by sign extending
its inputs and the zero extend becomes an AND instruction. We are unable
to remove the AND at this point and it becomes a pair of shifts or a
zext.w.

The result of smax has as many sign bits as the minimum of its inputs.
Had we kept the sign extend instead of turning it into a zero extend
it would be removed by DAG combiner after type legalization.
llvm/test/CodeGen/RISCV/min-max.ll