diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -97,8 +97,8 @@ getActionDefinitionsBuilder(G_PHI).legalFor({p0, s16, s32, s64}) .legalFor(PackedVectorAllTypeList) - .clampScalar(0, s16, s64) - .widenScalarToNextPow2(0); + .widenScalarToNextPow2(0) + .clampScalar(0, s16, s64); getActionDefinitionsBuilder(G_BSWAP) .legalFor({s32, s64, v4s32, v2s32, v2s64}) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir @@ -624,3 +624,44 @@ $q0 = COPY %3(<16 x s8>) RET_ReallyLR ... +--- +name: s88 +tracksRegLiveness: true +liveins: +body: | + ; CHECK-LABEL: name: s88 + ; CHECK: bb.0: + ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000) + ; CHECK: liveins: $x0 + ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF + ; CHECK: G_BRCOND %cond(s1), %bb.1 + ; CHECK: G_BR %bb.2 + ; CHECK: bb.1: + ; CHECK: successors: %bb.3(0x80000000) + ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF + ; CHECK: G_BR %bb.3 + ; CHECK: bb.2: + ; CHECK: successors: %bb.3(0x80000000) + ; CHECK: [[DEF1:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF + ; CHECK: bb.3: + ; CHECK: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.1, [[DEF1]](s64), %bb.2 + ; CHECK: $x0 = COPY [[PHI]](s64) + ; CHECK: RET_ReallyLR implicit $x0 + bb.0: + successors: %bb.1(0x40000000), %bb.2(0x40000000) + liveins: $x0 + %cond:_(s1) = G_IMPLICIT_DEF + G_BRCOND %cond(s1), %bb.1 + G_BR %bb.2 + bb.1: + successors: %bb.3(0x80000000) + %imp_1:_(s88) = G_IMPLICIT_DEF + G_BR %bb.3 + bb.2: + successors: %bb.3(0x80000000) + %imp_2:_(s88) = G_IMPLICIT_DEF + bb.3: + %phi:_(s88) = G_PHI %imp_1:_(s88), %bb.1, %imp_2:_(s88), %bb.2 + %trunc:_(s64) = G_TRUNC %phi + $x0 = COPY %trunc + RET_ReallyLR implicit $x0 diff --git a/llvm/test/CodeGen/AArch64/pr48188.ll b/llvm/test/CodeGen/AArch64/pr48188.ll --- a/llvm/test/CodeGen/AArch64/pr48188.ll +++ b/llvm/test/CodeGen/AArch64/pr48188.ll @@ -1,23 +1,40 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -O0 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -O0 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefix=GISEL +; RUN: llc -O0 -global-isel=0 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefix=SDAG -; GlobalISel cannot legalize this phi, so we fall back to SDAG. +; Verify that GISel and SDAG do the same thing for this phi (modulo regalloc) define void @test() nounwind { -; CHECK-LABEL: test: -; CHECK: // %bb.0: // %entry -; CHECK-NEXT: sub sp, sp, #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 +; GISEL-LABEL: test: +; GISEL: // %bb.0: // %entry +; GISEL-NEXT: sub sp, sp, #16 +; GISEL-NEXT: mov x8, xzr +; GISEL-NEXT: mov x9, x8 +; GISEL-NEXT: str x9, [sp] // 8-byte Folded Spill +; GISEL-NEXT: str x8, [sp, #8] // 8-byte Folded Spill +; GISEL-NEXT: b .LBB0_1 +; GISEL-NEXT: .LBB0_1: // %loop +; GISEL-NEXT: // =>This Inner Loop Header: Depth=1 +; GISEL-NEXT: ldr x8, [sp, #8] // 8-byte Folded Reload +; GISEL-NEXT: ldr x9, [sp] // 8-byte Folded Reload +; GISEL-NEXT: str x9, [sp] // 8-byte Folded Spill +; GISEL-NEXT: str x8, [sp, #8] // 8-byte Folded Spill +; GISEL-NEXT: b .LBB0_1 +; +; SDAG-LABEL: test: +; SDAG: // %bb.0: // %entry +; SDAG-NEXT: sub sp, sp, #16 +; SDAG-NEXT: mov x1, xzr +; SDAG-NEXT: mov x0, x1 +; SDAG-NEXT: str x1, [sp] // 8-byte Folded Spill +; SDAG-NEXT: str x0, [sp, #8] // 8-byte Folded Spill +; SDAG-NEXT: b .LBB0_1 +; SDAG-NEXT: .LBB0_1: // %loop +; SDAG-NEXT: // =>This Inner Loop Header: Depth=1 +; SDAG-NEXT: ldr x0, [sp, #8] // 8-byte Folded Reload +; SDAG-NEXT: ldr x1, [sp] // 8-byte Folded Reload +; SDAG-NEXT: str x1, [sp] // 8-byte Folded Spill +; SDAG-NEXT: str x0, [sp, #8] // 8-byte Folded Spill +; SDAG-NEXT: b .LBB0_1 entry: br label %loop