mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
[GISel] Correct the known bits of G_ANYEXT
Known bits for G_ANYEXT was incorrectly using KnownBits::zext, causing us to treat the high bits as zero even though they're (by definition) unknown. Differential Revision: https://reviews.llvm.org/D86323
This commit is contained in:
parent
4d9361b2f3
commit
5b1cb91987
@ -316,7 +316,7 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
|
||||
case TargetOpcode::G_ANYEXT: {
|
||||
computeKnownBitsImpl(MI.getOperand(1).getReg(), Known, DemandedElts,
|
||||
Depth + 1);
|
||||
Known = Known.zext(BitWidth);
|
||||
Known = Known.anyext(BitWidth);
|
||||
break;
|
||||
}
|
||||
case TargetOpcode::G_LOAD: {
|
||||
|
@ -511,3 +511,47 @@ TEST_F(AArch64GISelMITest, TestMetadata) {
|
||||
Mask.flipAllBits();
|
||||
EXPECT_EQ(Mask.getZExtValue(), Res.Zero.getZExtValue());
|
||||
}
|
||||
|
||||
TEST_F(AArch64GISelMITest, TestKnownBitsExt) {
|
||||
StringRef MIRString = " %c1:_(s16) = G_CONSTANT i16 1\n"
|
||||
" %x:_(s16) = G_IMPLICIT_DEF\n"
|
||||
" %y:_(s16) = G_AND %x, %c1\n"
|
||||
" %anyext:_(s32) = G_ANYEXT %y(s16)\n"
|
||||
" %r1:_(s32) = COPY %anyext\n"
|
||||
" %zext:_(s32) = G_ZEXT %y(s16)\n"
|
||||
" %r2:_(s32) = COPY %zext\n"
|
||||
" %sext:_(s32) = G_SEXT %y(s16)\n"
|
||||
" %r3:_(s32) = COPY %sext\n";
|
||||
setUp(MIRString);
|
||||
if (!TM)
|
||||
return;
|
||||
Register CopyRegAny = Copies[Copies.size() - 3];
|
||||
Register CopyRegZ = Copies[Copies.size() - 2];
|
||||
Register CopyRegS = Copies[Copies.size() - 1];
|
||||
|
||||
GISelKnownBits Info(*MF);
|
||||
MachineInstr *Copy;
|
||||
Register SrcReg;
|
||||
KnownBits Res;
|
||||
|
||||
Copy = MRI->getVRegDef(CopyRegAny);
|
||||
SrcReg = Copy->getOperand(1).getReg();
|
||||
Res = Info.getKnownBits(SrcReg);
|
||||
EXPECT_EQ((uint64_t)32, Res.getBitWidth());
|
||||
EXPECT_EQ((uint64_t)0, Res.One.getZExtValue());
|
||||
EXPECT_EQ((uint64_t)0x0000fffe, Res.Zero.getZExtValue());
|
||||
|
||||
Copy = MRI->getVRegDef(CopyRegZ);
|
||||
SrcReg = Copy->getOperand(1).getReg();
|
||||
Res = Info.getKnownBits(SrcReg);
|
||||
EXPECT_EQ((uint64_t)32, Res.getBitWidth());
|
||||
EXPECT_EQ((uint64_t)0, Res.One.getZExtValue());
|
||||
EXPECT_EQ((uint64_t)0xfffffffe, Res.Zero.getZExtValue());
|
||||
|
||||
Copy = MRI->getVRegDef(CopyRegS);
|
||||
SrcReg = Copy->getOperand(1).getReg();
|
||||
Res = Info.getKnownBits(SrcReg);
|
||||
EXPECT_EQ((uint64_t)32, Res.getBitWidth());
|
||||
EXPECT_EQ((uint64_t)0, Res.One.getZExtValue());
|
||||
EXPECT_EQ((uint64_t)0xfffffffe, Res.Zero.getZExtValue());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user