34 changes: 34 additions & 0 deletions llvm/test/CodeGen/LoongArch/cfr-copy.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
# RUN: llc --mtriple=loongarch64 --mattr=+d %s -o - | FileCheck %s

## Check the PseudoCopyCFR instruction expand.

--- |
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
target triple = "loongarch64"

define void @test() {
; CHECK-LABEL: test:
; CHECK: # %bb.0:
; CHECK-NEXT: fcmp.caf.s $fcc1, $fa0, $fa0
; CHECK-NEXT: bceqz $fcc0, .LBB0_2
; CHECK-NEXT: # %bb.1:
; CHECK-NEXT: fcmp.cueq.s $fcc1, $fa0, $fa0
; CHECK-NEXT: .LBB0_2:
; CHECK-NEXT: movcf2gr $a0, $fcc1
; CHECK-NEXT: ret
ret void
}
...
---
name: test
tracksRegLiveness: true
body: |
bb.0:
liveins: $fcc0
$fcc1 = COPY $fcc0
$r4 = COPY $fcc1
PseudoRET implicit killed $r4
...
26 changes: 26 additions & 0 deletions llvm/test/CodeGen/LoongArch/cfr-pseudo-copy.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc --mtriple=loongarch64 --mattr=+d --stop-after=postrapseudos %s \
# RUN: -o - | FileCheck %s

## Check the COPY instruction between CFRs.
## A pseudo (PseudoCopyCFR) is generated after postrapseudos pass.

...
---
name: test
tracksRegLiveness: true
body: |
bb.0.entry:
liveins: $fcc0
; CHECK-LABEL: name: test
; CHECK: liveins: $fcc0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $fcc1 = PseudoCopyCFR $fcc0
; CHECK-NEXT: $r4 = MOVCF2GR killed $fcc1
; CHECK-NEXT: PseudoRET implicit killed $r4
$fcc1 = COPY $fcc0
$r4 = COPY $fcc1
PseudoRET implicit killed $r4
...
13 changes: 6 additions & 7 deletions llvm/test/CodeGen/LoongArch/inline-asm-clobbers-fcc.mir
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc --mtriple=loongarch64 --mattr=+d --run-pass=greedy %s -o - | FileCheck %s
# RUN: llc --mtriple=loongarch64 --mattr=+d --regalloc=fast \
# RUN: --stop-before=postra-machine-sink %s -o - | FileCheck %s

## Check that fcc register clobbered by inlineasm is correctly saved by examing
## a pair of pseudos (PseudoST_CFR and PseudoLD_CFR) are generated before and
Expand All @@ -15,13 +16,11 @@ body: |
; CHECK-LABEL: name: test
; CHECK: liveins: $f0_64, $f1_64
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $f1_64
; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr64 = COPY $f0_64
; CHECK-NEXT: [[FCMP_CLT_D:%[0-9]+]]:cfr = FCMP_CLT_D [[COPY]], [[COPY1]]
; CHECK-NEXT: PseudoST_CFR [[FCMP_CLT_D]], %stack.0, 0 :: (store (s64) into %stack.0)
; CHECK-NEXT: renamable $fcc0 = FCMP_CLT_D renamable $f1_64, renamable $f0_64
; CHECK-NEXT: PseudoST_CFR $fcc0, %stack.0, 0 :: (store (s64) into %stack.0)
; CHECK-NEXT: INLINEASM &nop, 1 /* sideeffect attdialect */, 12 /* clobber */, implicit-def dead early-clobber $fcc0
; CHECK-NEXT: [[PseudoLD_CFR:%[0-9]+]]:cfr = PseudoLD_CFR %stack.0, 0 :: (load (s64) from %stack.0)
; CHECK-NEXT: $r4 = COPY [[PseudoLD_CFR]]
; CHECK-NEXT: $fcc0 = PseudoLD_CFR %stack.0, 0 :: (load (s64) from %stack.0)
; CHECK-NEXT: $r4 = COPY killed renamable $fcc0
; CHECK-NEXT: PseudoRET implicit killed $r4
%1:fpr64 = COPY $f1_64
%0:fpr64 = COPY $f0_64
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/LoongArch/opt-pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
; CHECK-NEXT: Lazy Machine Block Frequency Analysis
; CHECK-NEXT: Machine Optimization Remark Emitter
; CHECK-NEXT: Stack Frame Layout Analysis
; CHECK-NEXT: LoongArch pseudo instruction expansion pass
; CHECK-NEXT: LoongArch atomic pseudo instruction expansion pass
; CHECK-NEXT: Lazy Machine Block Frequency Analysis
; CHECK-NEXT: Machine Optimization Remark Emitter
Expand Down