[PATCH] D86323: [GISel] Correct the known bits of G_ANYEXT
Justin Bogner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 17:17:22 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1283dca0076b: [GISel] Correct the known bits of G_ANYEXT (authored by bogner).
Changed prior to commit:
https://reviews.llvm.org/D86323?vs=286924&id=286925#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86323/new/
https://reviews.llvm.org/D86323
Files:
llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
Index: llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
===================================================================
--- llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
+++ llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
@@ -511,3 +511,47 @@
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());
+}
Index: llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
+++ llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
@@ -316,7 +316,7 @@
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: {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86323.286925.patch
Type: text/x-patch
Size: 2561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200821/59b8c6fd/attachment.bin>
More information about the llvm-commits
mailing list