forked from OSchip/llvm-project
[AArch64][GlobalISel] Widen G_PHI before clamping it during legalization
This allows us to handle weird types like s88; we first widen to s128, then clamp back down to s64. https://godbolt.org/z/9xqbP46Mz Also this makes it possible for GISel to legalize the case in pr48188.ll. It now does the same thing as SDAG, although regalloc chooses different registers. Differential Revision: https://reviews.llvm.org/D107417
This commit is contained in:
parent
7d97de60b3
commit
d9279843b1
|
@ -97,8 +97,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
|
|||
|
||||
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})
|
||||
|
|
|
@ -624,3 +624,44 @@ body: |
|
|||
$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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue