1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/CodeGen/AArch64/GlobalISel/load-wro-addressing-modes.mir
Jessica Paquette 8a964bb5a4 [AArch64][GlobalISel] Avoid copies to target register bank for subregister copies
Previously for any copy from a register bigger than the destination:

Copied to a same-sized register in the destination register bank.
Subregister copy of that to the destination.
This fails for copies from 128-bit FPRs to GPRs because the GPR register bank
can't accomodate 128-bit values.

Instead of special-casing such copies to perform the truncation beforehand in
the source register bank, generalize this:
a) Perform a subregister copy straight from source register whenever possible.
This results in shorter MIR and fixes the above problem.

b) Perform a full copy to target bank and then do a subregister copy only if
source bank can't support target's size. E.g. GPR to 8-bit FPR copy.

Patch by Raul Tambre (tambre)!

Differential Revision: https://reviews.llvm.org/D75421
2020-03-05 11:13:02 -08:00

431 lines
12 KiB
YAML

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=aarch64-unknown-unknown -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
...
---
name: shl_gep_sext_ldrwrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0
; We should be able to fold a shift + extend into the pattern.
; In this case, we should get a roW load with two 1s, representing a shift
; plus sign extend.
; CHECK-LABEL: name: shl_gep_sext_ldrwrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr32 = LDRWroW %base, %foo, 1, 1 :: (load 4)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_SEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 2
%offset:gpr(s64) = G_SHL %ext, %c
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 4)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: shl_gep_zext_ldrwrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0
; We should be able to fold a shift + extend into the pattern.
; In this case, we should get a roW load with a 0 representing a zero-extend
; and a 1 representing a shift.
; CHECK-LABEL: name: shl_gep_zext_ldrwrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr32 = LDRWroW %base, %foo, 0, 1 :: (load 4)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_ZEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 2
%offset:gpr(s64) = G_SHL %ext, %c
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 4)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: shl_gep_anyext_ldrwrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0
; We should be able to fold a shift + extend into the pattern.
; In this case, we should get a roW load with a 0 representing a zero-extend
; and a 1 representing a shift.
; CHECK-LABEL: name: shl_gep_anyext_ldrwrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr32 = LDRWroW %base, %foo, 0, 1 :: (load 4)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_ANYEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 2
%offset:gpr(s64) = G_SHL %ext, %c
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 4)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: mul_gep_sext_ldrwrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
; We should be able to do the same with multiplies as with shifts.
liveins: $w1, $x0
; CHECK-LABEL: name: mul_gep_sext_ldrwrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr32 = LDRWroW %base, %foo, 1, 1 :: (load 4)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_SEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 4
%offset:gpr(s64) = G_MUL %c, %ext
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 4)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: mul_gep_zext_ldrwrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0
; We should be able to do the same with multiplies as with shifts.
; CHECK-LABEL: name: mul_gep_zext_ldrwrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr32 = LDRWroW %base, %foo, 0, 1 :: (load 4)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_ZEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 4
%offset:gpr(s64) = G_MUL %c, %ext
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 4)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: mul_gep_anyext_ldrwrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0
; We should be able to do the same with multiplies as with shifts.
; CHECK-LABEL: name: mul_gep_anyext_ldrwrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr32 = LDRWroW %base, %foo, 0, 1 :: (load 4)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_ANYEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 4
%offset:gpr(s64) = G_MUL %c, %ext
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 4)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: ldrdrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0, $d0
; Verify that we can select LDRDroW.
; CHECK-LABEL: name: ldrdrow
; CHECK: liveins: $w1, $x0, $d0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:fpr64 = LDRDroW %base, %foo, 1, 1 :: (load 8)
; CHECK: $x0 = COPY %load
; CHECK: RET_ReallyLR implicit $x0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_SEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 8
%offset:gpr(s64) = G_MUL %c, %ext
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:fpr(<2 x s32>) = G_LOAD %ptr(p0) :: (load 8)
$x0 = COPY %load(<2 x s32>)
RET_ReallyLR implicit $x0
...
---
name: ldrxrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.0:
liveins: $w1, $x0, $d0
; Verify that we can select LDRXroW.
; CHECK-LABEL: name: ldrxrow
; CHECK: liveins: $w1, $x0, $d0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:gpr64 = LDRXroW %base, %foo, 1, 1 :: (load 8)
; CHECK: $x0 = COPY %load
; CHECK: RET_ReallyLR implicit $x0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_SEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 8
%offset:gpr(s64) = G_MUL %c, %ext
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:gpr(s64) = G_LOAD %ptr(p0) :: (load 8)
$x0 = COPY %load(s64)
RET_ReallyLR implicit $x0
...
---
name: ldrbbrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.1.entry:
liveins: $x0, $w0, $w1
; Verify that we can select LDRBBroW. Note that there is no shift here,
; but we still fold the extend into the addressing mode.
; CHECK-LABEL: name: ldrbbrow
; CHECK: liveins: $x0, $w0, $w1
; CHECK: %val:gpr32 = COPY $w1
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %load:gpr32 = LDRBBroW %base, %val, 1, 0 :: (load 1)
; CHECK: $w0 = COPY %load
; CHECK: RET_ReallyLR implicit $w0
%val:gpr(s32) = COPY $w1
%base:gpr(p0) = COPY $x0
%ext:gpr(s64) = G_SEXT %val(s32)
%ptr:gpr(p0) = G_PTR_ADD %base, %ext(s64)
%load:gpr(s32) = G_LOAD %ptr(p0) :: (load 1)
$w0 = COPY %load(s32)
RET_ReallyLR implicit $w0
...
---
name: ldrhrow
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
machineFunctionInfo: {}
body: |
bb.1.entry:
liveins: $w1, $x0
; Verify that we can select ldrhrow.
; CHECK-LABEL: name: ldrhrow
; CHECK: liveins: $w1, $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %foo:gpr32 = COPY $w1
; CHECK: %load:fpr16 = LDRHroW %base, %foo, 1, 1 :: (load 2)
; CHECK: $h0 = COPY %load
; CHECK: RET_ReallyLR implicit $h0
%base:gpr(p0) = COPY $x0
%foo:gpr(s32) = COPY $w1
%ext:gpr(s64) = G_SEXT %foo(s32)
%c:gpr(s64) = G_CONSTANT i64 2
%offset:gpr(s64) = G_MUL %c, %ext
%ptr:gpr(p0) = G_PTR_ADD %base, %offset(s64)
%load:fpr(s16) = G_LOAD %ptr(p0) :: (load 2)
$h0 = COPY %load(s16)
RET_ReallyLR implicit $h0
...
---
name: bad_and_mask_1
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
body: |
bb.0:
liveins: $x0
; We should get a roX load here, not a roW load. We can't use the mask in
; this test for an extend.
; CHECK-LABEL: name: bad_and_mask_1
; CHECK: liveins: $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %imp:gpr64 = IMPLICIT_DEF
; CHECK: %and:gpr64common = ANDXri %imp, 4103
; CHECK: %load:gpr64 = LDRXroX %base, %and, 0, 1 :: (load 8)
; CHECK: $x1 = COPY %load
; CHECK: RET_ReallyLR implicit $x1
%base:gpr(p0) = COPY $x0
%imp:gpr(s64) = G_IMPLICIT_DEF
%bad_mask:gpr(s64) = G_CONSTANT i64 255
%and:gpr(s64) = G_AND %imp, %bad_mask
%c:gpr(s64) = G_CONSTANT i64 8
%mul:gpr(s64) = G_MUL %c, %and
%ptr:gpr(p0) = G_PTR_ADD %base, %mul(s64)
%load:gpr(s64) = G_LOAD %ptr(p0) :: (load 8)
$x1 = COPY %load(s64)
RET_ReallyLR implicit $x1
...
---
name: bad_and_mask_2
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
body: |
bb.0:
liveins: $x0
; We should get a roX load here, not a roW load. We can't use the mask in
; this test for an extend.
; CHECK-LABEL: name: bad_and_mask_2
; CHECK: liveins: $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %imp:gpr64 = IMPLICIT_DEF
; CHECK: %and:gpr64common = ANDXri %imp, 4111
; CHECK: %load:gpr64 = LDRXroX %base, %and, 0, 1 :: (load 8)
; CHECK: $x1 = COPY %load
; CHECK: RET_ReallyLR implicit $x1
%base:gpr(p0) = COPY $x0
%imp:gpr(s64) = G_IMPLICIT_DEF
%bad_mask:gpr(s64) = G_CONSTANT i64 65535
%and:gpr(s64) = G_AND %imp, %bad_mask
%c:gpr(s64) = G_CONSTANT i64 8
%mul:gpr(s64) = G_MUL %c, %and
%ptr:gpr(p0) = G_PTR_ADD %base, %mul(s64)
%load:gpr(s64) = G_LOAD %ptr(p0) :: (load 8)
$x1 = COPY %load(s64)
RET_ReallyLR implicit $x1
...
---
name: and_uxtw
alignment: 4
legalized: true
regBankSelected: true
tracksRegLiveness: true
frameInfo:
maxAlignment: 1
body: |
bb.0:
liveins: $x0
; The mask used for the AND here is legal for producing a roW load.
; CHECK-LABEL: name: and_uxtw
; CHECK: liveins: $x0
; CHECK: %base:gpr64sp = COPY $x0
; CHECK: %imp:gpr64 = IMPLICIT_DEF
; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %imp.sub_32
; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
; CHECK: %load:gpr64 = LDRXroW %base, [[COPY1]], 0, 1 :: (load 8)
; CHECK: $x1 = COPY %load
; CHECK: RET_ReallyLR implicit $x1
%base:gpr(p0) = COPY $x0
%imp:gpr(s64) = G_IMPLICIT_DEF
%mask:gpr(s64) = G_CONSTANT i64 4294967295
%and:gpr(s64) = G_AND %imp, %mask
%c:gpr(s64) = G_CONSTANT i64 8
%mul:gpr(s64) = G_MUL %c, %and
%ptr:gpr(p0) = G_PTR_ADD %base, %mul(s64)
%load:gpr(s64) = G_LOAD %ptr(p0) :: (load 8)
$x1 = COPY %load(s64)
RET_ReallyLR implicit $x1
...