[llvm] [GISel][RISCV] Add legalizer & selector support for G_FREEZE. (PR #92744)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 09:12:31 PDT 2024
================
@@ -0,0 +1,60 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=riscv32 -mattr=+f,+m,+v -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,RV32
+; RUN: llc -mtriple=riscv64 -mattr=+f,+m,+v -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,RV64
+
+define i32 @freeze_int(i32 %x) {
+; RV32-LABEL: freeze_int:
+; RV32: # %bb.0:
+; RV32-NEXT: mul a0, a0, a0
+; RV32-NEXT: ret
+;
+; RV64-LABEL: freeze_int:
+; RV64: # %bb.0:
+; RV64-NEXT: mulw a0, a0, a0
+; RV64-NEXT: ret
+ %y1 = freeze i32 %x
+ %t1 = mul i32 %y1, %y1
+ ret i32 %t1
+}
+
+define i5 @freeze_int2(i5 %x) {
+; RV32-LABEL: freeze_int2:
+; RV32: # %bb.0:
+; RV32-NEXT: mul a0, a0, a0
+; RV32-NEXT: ret
+;
+; RV64-LABEL: freeze_int2:
+; RV64: # %bb.0:
+; RV64-NEXT: mulw a0, a0, a0
+; RV64-NEXT: ret
+ %y1 = freeze i5 %x
+ %t1 = mul i5 %y1, %y1
+ ret i5 %t1
+}
+
+define float @freeze_float(float %x) {
+; CHECK-LABEL: freeze_float:
+; CHECK: # %bb.0:
+; CHECK-NEXT: fadd.s fa0, fa0, fa0
+; CHECK-NEXT: ret
+ %y1 = freeze float %x
+ %t1 = fadd float %y1, %y1
+ ret float %t1
+}
+
+; TODO: Support vector calling conv.
+; define <2 x i32> @freeze_ivec(<2 x i32> %x) {
----------------
dtcxzyw wrote:
> Could just load from memory instead
I still have trouble in legalizing G_FREEZE with fixed-length vectors :(
https://github.com/llvm/llvm-project/pull/92744
More information about the llvm-commits
mailing list