[llvm] r370847 - [GlobalISel] Fix G_SEXT narrowScalar to bail out of unsupported type combination.

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 00:58:46 PDT 2019


Author: aemerson
Date: Wed Sep  4 00:58:45 2019
New Revision: 370847

URL: http://llvm.org/viewvc/llvm-project?rev=370847&view=rev
Log:
[GlobalISel] Fix G_SEXT narrowScalar to bail out of unsupported type combination.

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.

Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp?rev=370847&r1=370846&r2=370847&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp Wed Sep  4 00:58:45 2019
@@ -619,13 +619,17 @@ LegalizerHelper::LegalizeResult Legalize
     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);




More information about the llvm-commits mailing list