[KnownBits][RISCV] Improve known bits for srem.
authorCraig Topper <craig.topper@sifive.com>
Sun, 21 Feb 2021 22:48:27 +0000 (14:48 -0800)
committerCraig Topper <craig.topper@sifive.com>
Sun, 21 Feb 2021 22:48:29 +0000 (14:48 -0800)
commit183bbad1d78a4bf445ec4db1ce01673f6a7feb37
tree931fc3087d975d0492d100c4c1d7f29d2f0cd6d6
parent6c9541d4ddfdab0dcb11436485b466a759c3126c
[KnownBits][RISCV] Improve known bits for srem.

The result must be less than or equal to the LHS side, so any
leading zeros in the left hand side must also exist in the result.
This is stronger than the previous behavior where we only considered
the sign bit being 0.

The affected test case used the sign bit being known 0 to change
a sign extend to a zero extend pre type legalization. After type
legalization the types were promoted to i64, but we no longer
knew bit 31 was zero. This shifts are are the equivalent of an
AND with 0xffffffff or zext_inreg X, i32. This patch allows us to
see that bit 31 is zero and remove the shifts.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D97124
llvm/lib/Support/KnownBits.cpp
llvm/test/CodeGen/RISCV/rv64m-exhaustive-w-insts.ll