]> granicus.if.org Git - llvm/commitdiff
[GlobalISel] Fix G_SEXT narrowScalar to bail out of unsupported type combination.
authorAmara Emerson <aemerson@apple.com>
Wed, 4 Sep 2019 07:58:45 +0000 (07:58 +0000)
committerAmara Emerson <aemerson@apple.com>
Wed, 4 Sep 2019 07:58:45 +0000 (07:58 +0000)
Similar to the issue with G_ZEXT that was fixed earlier, this is a quick
to fall back if the source type is not exactly half of the dest type.

Fixes the clang-cmake-aarch64-lld bot build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370847 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalISel/LegalizerHelper.cpp

index abbab01303bfbdabdb6dfff01d888a1dfe88c107..6bb65642956aacf0a4469ddd27091d83c87c3255 100644 (file)
@@ -619,13 +619,17 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
     if (TypeIdx != 0)
       return UnableToLegalize;
 
-    if (NarrowTy.getSizeInBits() != SizeOp0 / 2) {
+    Register SrcReg = MI.getOperand(1).getReg();
+    LLT SrcTy = MRI.getType(SrcReg);
+
+    // FIXME: support the general case where the requested NarrowTy may not be
+    // the same as the source type. E.g. s128 = sext(s32)
+    if ((SrcTy.getSizeInBits() != SizeOp0 / 2) ||
+        SrcTy.getSizeInBits() != NarrowTy.getSizeInBits()) {
       LLVM_DEBUG(dbgs() << "Can't narrow sext to type " << NarrowTy << "\n");
       return UnableToLegalize;
     }
 
-    Register SrcReg = MI.getOperand(1).getReg();
-
     // Shift the sign bit of the low register through the high register.
     auto ShiftAmt =
         MIRBuilder.buildConstant(LLT::scalar(64), NarrowTy.getSizeInBits() - 1);