[RISCV] Prevent infinite loop after D129980.
authorCraig Topper <craig.topper@sifive.com>
Wed, 3 Aug 2022 22:19:03 +0000 (15:19 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 3 Aug 2022 22:19:07 +0000 (15:19 -0700)
commit53d560b22f5b5d91ae5296f030e0ca75a5d2c625
tree2ab0d24e4ea433f349220712de7eb57a93e93906
parent26dd42705c2af0b8f6e5d6cdb32c9bd5ed9524eb
[RISCV] Prevent infinite loop after D129980.

D129980 converts (seteq (i64 (and X, 0xffffffff)), C1) into
(seteq (i64 (sext_inreg X, i32)), C1). If bit 31 of X is 0, it
will be turned back into an 'and' by SimplifyDemandedBits which
can cause an infinite loop.

To prevent this, check if bit 31 is 0 with computeKnownBits before
doing the transformation.

Fixes PR56905.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D131113
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/i64-icmp.ll