@@ -398,3 +398,36 @@ TEST_F(AArch64GISelMITest, TestNumSignBitsTrunc) {
398398 EXPECT_EQ (8u , Info.computeNumSignBits (CopyTruncNeg1));
399399 EXPECT_EQ (5u , Info.computeNumSignBits (CopyTrunc7));
400400}
401+
402+ TEST_F (AMDGPUGISelMITest, TestNumSignBitsTrunc) {
403+ StringRef MIRString =
404+ " %3:_(<4 x s32>) = G_IMPLICIT_DEF\n "
405+ " %4:_(s32) = G_IMPLICIT_DEF\n "
406+ " %5:_(s32) = G_AMDGPU_BUFFER_LOAD_UBYTE %3, %4, %4, %4, 0, 0, 0 :: (load 1)\n "
407+ " %6:_(s32) = COPY %5\n "
408+
409+ " %7:_(s32) = G_AMDGPU_BUFFER_LOAD_SBYTE %3, %4, %4, %4, 0, 0, 0 :: (load 1)\n "
410+ " %8:_(s32) = COPY %7\n "
411+
412+ " %9:_(s32) = G_AMDGPU_BUFFER_LOAD_USHORT %3, %4, %4, %4, 0, 0, 0 :: (load 2)\n "
413+ " %10:_(s32) = COPY %9\n "
414+
415+ " %11:_(s32) = G_AMDGPU_BUFFER_LOAD_SSHORT %3, %4, %4, %4, 0, 0, 0 :: (load 2)\n "
416+ " %12:_(s32) = COPY %11\n " ;
417+
418+ setUp (MIRString);
419+ if (!TM)
420+ return ;
421+
422+ Register CopyLoadUByte = Copies[Copies.size () - 4 ];
423+ Register CopyLoadSByte = Copies[Copies.size () - 3 ];
424+ Register CopyLoadUShort = Copies[Copies.size () - 2 ];
425+ Register CopyLoadSShort = Copies[Copies.size () - 1 ];
426+
427+ GISelKnownBits Info (*MF);
428+
429+ EXPECT_EQ (24u , Info.computeNumSignBits (CopyLoadUByte));
430+ EXPECT_EQ (25u , Info.computeNumSignBits (CopyLoadSByte));
431+ EXPECT_EQ (16u , Info.computeNumSignBits (CopyLoadUShort));
432+ EXPECT_EQ (17u , Info.computeNumSignBits (CopyLoadSShort));
433+ }
0 commit comments