[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.
parent
3da4f9c5
Please register or sign in to comment