[llvm] [RISCV][GISel] Add regbank and instruction selection tests for f16 load/store. NFC (PR #116101)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 12:14:44 PST 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/116101

The legalizer doesn't think these are legal yet so I had to disable the legality check.

>From 2e7652f93c0e98e04fe3b3d821c3f393bc37a0c2 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 13 Nov 2024 12:12:58 -0800
Subject: [PATCH] [RISCV][GISel] Add regbank and instruction selection tests
 for f16 load/store. NFC

The legalizer doesn't think these are legal yet so I had to disable
the legality check.
---
 .../instruction-select/fp-load-store.mir      | 53 +++++++++++++++--
 .../regbankselect/fp-load-store.mir           | 58 +++++++++++++++++--
 2 files changed, 103 insertions(+), 8 deletions(-)

diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fp-load-store.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fp-load-store.mir
index 23640d39be4d33..5441d7c6673bc7 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fp-load-store.mir
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fp-load-store.mir
@@ -1,8 +1,8 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-# RUN: llc -mtriple=riscv32 -mattr=+d -run-pass=instruction-select %s -o - \
-# RUN: | FileCheck %s
-# RUN: llc -mtriple=riscv64 -mattr=+d -run-pass=instruction-select %s -o - \
-# RUN: | FileCheck %s
+# RUN: llc -mtriple=riscv32 -mattr=+d,+zfh -run-pass=instruction-select %s -o - \
+# RUN:   -disable-gisel-legality-check | FileCheck %s
+# RUN: llc -mtriple=riscv64 -mattr=+d,+zfh -run-pass=instruction-select %s -o - \
+# RUN:   -disable-gisel-legality-check | FileCheck %s
 
 ---
 name:            fp_store_f32
@@ -93,3 +93,48 @@ body:             |
     PseudoRET implicit $f10_d
 
 ...
+---
+name:            fp_store_f16
+legalized:       true
+regBankSelected: true
+selected:        false
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    liveins: $x10, $f10_h
+
+    ; CHECK-LABEL: name: fp_store_f16
+    ; CHECK: liveins: $x10, $f10_h
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
+    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f10_h
+    ; CHECK-NEXT: FSH [[COPY1]], [[COPY]], 0 :: (store (s16))
+    ; CHECK-NEXT: PseudoRET
+    %0:gprb(p0) = COPY $x10
+    %1:fprb(s16) = COPY $f10_h
+    G_STORE %1(s16), %0(p0) :: (store (s16))
+    PseudoRET
+
+...
+---
+name:            fp_load_f16
+legalized:       true
+regBankSelected: true
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    liveins: $x10
+
+    ; CHECK-LABEL: name: fp_load_f16
+    ; CHECK: liveins: $x10
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
+    ; CHECK-NEXT: [[FLH:%[0-9]+]]:fpr16 = FLH [[COPY]], 0 :: (load (s16))
+    ; CHECK-NEXT: $f10_h = COPY [[FLH]]
+    ; CHECK-NEXT: PseudoRET implicit $f10_h
+    %0:gprb(p0) = COPY $x10
+    %1:fprb(s16) = G_LOAD %0(p0) :: (load (s16))
+    $f10_h = COPY %1(s16)
+    PseudoRET implicit $f10_h
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fp-load-store.mir b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fp-load-store.mir
index 50a8faa2504f38..f74362298a6cb9 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fp-load-store.mir
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fp-load-store.mir
@@ -1,9 +1,9 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-# RUN: llc -mtriple=riscv32 -mattr=+d -run-pass=regbankselect \
-# RUN:   -simplify-mir -verify-machineinstrs %s \
+# RUN: llc -mtriple=riscv32 -mattr=+d,+zfh -run-pass=regbankselect \
+# RUN:   -disable-gisel-legality-check -simplify-mir -verify-machineinstrs %s \
 # RUN:   -o - | FileCheck %s --check-prefixes=CHECK
-# RUN: llc -mtriple=riscv64 -mattr=+d -run-pass=regbankselect \
-# RUN:   -simplify-mir -verify-machineinstrs %s \
+# RUN: llc -mtriple=riscv64 -mattr=+d,+zfh -run-pass=regbankselect \
+# RUN:   -disable-gisel-legality-check -simplify-mir -verify-machineinstrs %s \
 # RUN:   -o - | FileCheck %s --check-prefixes=CHECK
 
 ---
@@ -150,3 +150,53 @@ body:             |
     PseudoRET implicit $f10_d
 
 ...
+---
+name:            fp_store_fp_def_f16
+legalized:       true
+tracksRegLiveness: true
+body:             |
+  bb.1:
+    liveins: $x10, $f10_h, $f11_h
+
+    ; CHECK-LABEL: name: fp_store_fp_def_f16
+    ; CHECK: liveins: $x10, $f10_h, $f11_h
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gprb(p0) = COPY $x10
+    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fprb(s16) = COPY $f10_h
+    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:fprb(s16) = COPY $f11_h
+    ; CHECK-NEXT: [[FADD:%[0-9]+]]:fprb(s16) = G_FADD [[COPY1]], [[COPY2]]
+    ; CHECK-NEXT: G_STORE [[FADD]](s16), [[COPY]](p0) :: (store (s16))
+    ; CHECK-NEXT: PseudoRET
+    %0:_(p0) = COPY $x10
+    %1:_(s16) = COPY $f10_h
+    %2:_(s16) = COPY $f11_h
+    %3:_(s16) = G_FADD %1, %2
+    G_STORE %3(s16), %0(p0) :: (store (s16))
+    PseudoRET
+
+...
+---
+name:            fp_load_fp_use_f16
+legalized:       true
+tracksRegLiveness: true
+body:             |
+  bb.1:
+    liveins: $x10, $f10_h
+
+    ; CHECK-LABEL: name: fp_load_fp_use_f16
+    ; CHECK: liveins: $x10, $f10_h
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gprb(p0) = COPY $x10
+    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fprb(s16) = COPY $f10_h
+    ; CHECK-NEXT: [[LOAD:%[0-9]+]]:fprb(s16) = G_LOAD [[COPY]](p0) :: (load (s16))
+    ; CHECK-NEXT: [[FADD:%[0-9]+]]:fprb(s16) = G_FADD [[LOAD]], [[COPY1]]
+    ; CHECK-NEXT: $f10_h = COPY [[FADD]](s16)
+    ; CHECK-NEXT: PseudoRET implicit $f10_h
+    %0:_(p0) = COPY $x10
+    %1:_(s16) = COPY $f10_h
+    %2:_(s16) = G_LOAD %0(p0) :: (load (s16))
+    %3:_(s16) = G_FADD %2, %1
+    $f10_h = COPY %3(s16)
+    PseudoRET implicit $f10_h
+
+...



More information about the llvm-commits mailing list