OSDN Git Service

[X86] Use APInt::isSignedIntN instead of isIntN for 64-bit ANDs in X86DAGToDAGISel...
authorCraig Topper <craig.topper@sifive.com>
Wed, 9 Dec 2020 18:21:40 +0000 (10:21 -0800)
committerCraig Topper <craig.topper@sifive.com>
Wed, 9 Dec 2020 21:39:07 +0000 (13:39 -0800)
commit5ff5cf8e057782e3e648ecf5ccf1d9990b53ee90
tree57addf2db064e757f241c139b0928c92520f0766
parentc8466a57310a0f10563e4a5a511e8c6386599cfe
[X86] Use APInt::isSignedIntN instead of isIntN for 64-bit ANDs in X86DAGToDAGISel::IsProfitableToFold

Pretty sure we meant to be checking signed 32 immediates here
rather than unsigned 32 bit. I suspect I messed this up because
in MathExtras.h we have isIntN and isUIntN so isIntN differs in
signedness depending on whether you're using APInt or plain integers.

This fixes a case where we didn't fold a constant created
by shrinkAndImmediate. Since shrinkAndImmediate doesn't topologically
sort constants it creates, we can fail to convert the Constant
to a TargetConstant. This leads to very strange behavior later.

Fixes PR48458.
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/test/CodeGen/X86/pr48458.ll [new file with mode: 0644]