[llvm-branch-commits] [llvm] 52510d8 - [GlobalISel] Bail on G_PHI narrowing of odd types (PR48188)

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Mar 5 09:28:49 PST 2021


Author: Nikita Popov
Date: 2021-03-05T09:28:34-08:00
New Revision: 52510d84802b55ecd80a904ca259adfecffc5be1

URL: https://github.com/llvm/llvm-project/commit/52510d84802b55ecd80a904ca259adfecffc5be1
DIFF: https://github.com/llvm/llvm-project/commit/52510d84802b55ecd80a904ca259adfecffc5be1.diff

LOG: [GlobalISel] Bail on G_PHI narrowing of odd types (PR48188)

The current narrowing code for G_PHI can only handle the case
where the size is a multiple of the narrow size. If this is not
the case, fall back to SDAG instead of asserting.

Original patch by shepmaster.

Differential Revision: https://reviews.llvm.org/D92446

(cherry picked from commit c35761db0f078f74550ef56bfc0745c162d76967)

Added: 
    llvm/test/CodeGen/AArch64/pr48188.ll

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index e7f40523efaf..3178ee16af2b 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -1063,6 +1063,11 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
     Observer.changedInstr(MI);
     return Legalized;
   case TargetOpcode::G_PHI: {
+    // FIXME: add support for when SizeOp0 isn't an exact multiple of
+    // NarrowSize.
+    if (SizeOp0 % NarrowSize != 0)
+      return UnableToLegalize;
+
     unsigned NumParts = SizeOp0 / NarrowSize;
     SmallVector<Register, 2> DstRegs(NumParts);
     SmallVector<SmallVector<Register, 2>, 2> SrcRegs(MI.getNumOperands() / 2);

diff  --git a/llvm/test/CodeGen/AArch64/pr48188.ll b/llvm/test/CodeGen/AArch64/pr48188.ll
new file mode 100644
index 000000000000..2da02e640ec1
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/pr48188.ll
@@ -0,0 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -O0 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
+
+; GlobalISel cannot legalize this phi, so we fall back to SDAG.
+define void @test() nounwind {
+; CHECK-LABEL: test:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    sub sp, sp, #16 // =16
+; CHECK-NEXT:    mov x1, xzr
+; CHECK-NEXT:    mov x0, x1
+; CHECK-NEXT:    str x1, [sp] // 8-byte Folded Spill
+; CHECK-NEXT:    str x0, [sp, #8] // 8-byte Folded Spill
+; CHECK-NEXT:    b .LBB0_1
+; CHECK-NEXT:  .LBB0_1: // %loop
+; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:    ldr x0, [sp, #8] // 8-byte Folded Reload
+; CHECK-NEXT:    ldr x1, [sp] // 8-byte Folded Reload
+; CHECK-NEXT:    str x1, [sp] // 8-byte Folded Spill
+; CHECK-NEXT:    str x0, [sp, #8] // 8-byte Folded Spill
+; CHECK-NEXT:    b .LBB0_1
+entry:
+  br label %loop
+
+loop:
+  %p = phi i72 [ 0, %entry ], [ %p, %loop ]
+  br label %loop
+}


        


More information about the llvm-branch-commits mailing list