[llvm] [RISCV][GISel] Fold G_FCONSTANT 0.0 store into G_CONSTANT x0 (PR #163008)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 14 09:47:36 PDT 2025
================
@@ -0,0 +1,196 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -global-isel -mtriple=riscv32 -mattr=+f,+zfh < %s \
+; RUN: | FileCheck %s --check-prefix=RV32
+; RUN: llc -global-isel -mtriple=riscv64 -mattr=+d,+zfh < %s \
+; RUN: | FileCheck %s --check-prefix=RV64
+
+define void @zero_f16(ptr %i) {
+; RV32-LABEL: zero_f16:
+; RV32: # %bb.0: # %entry
+; RV32-NEXT: sh zero, 0(a0)
+; RV32-NEXT: ret
+;
+; RV64-LABEL: zero_f16:
+; RV64: # %bb.0: # %entry
+; RV64-NEXT: sh zero, 0(a0)
+; RV64-NEXT: ret
+entry:
+ store half 0.0, ptr %i, align 4
+ ret void
+}
+
+define void @zero_bf16(ptr %i) {
+; RV32-LABEL: zero_bf16:
+; RV32: # %bb.0: # %entry
+; RV32-NEXT: sh zero, 0(a0)
+; RV32-NEXT: ret
+;
+; RV64-LABEL: zero_bf16:
+; RV64: # %bb.0: # %entry
+; RV64-NEXT: sh zero, 0(a0)
+; RV64-NEXT: ret
+entry:
+ store bfloat 0.0, ptr %i, align 4
+ ret void
+}
+
+define void @zero_f32(ptr %i) {
+; RV32-LABEL: zero_f32:
+; RV32: # %bb.0: # %entry
+; RV32-NEXT: sw zero, 0(a0)
+; RV32-NEXT: ret
+;
+; RV64-LABEL: zero_f32:
+; RV64: # %bb.0: # %entry
+; RV64-NEXT: sw zero, 0(a0)
+; RV64-NEXT: ret
+entry:
+ store float 0.0, ptr %i, align 4
+ ret void
+}
+
+
+define void @zero_f64(ptr %i) {
----------------
topperc wrote:
This test gives an error on riscv32 with `-mattr=+d`.
```
LLVM ERROR: instruction is not legal: G_STORE %2:_(s32), %0:_(p0) :: (store (s64) into %ir.i) (in function: zero_f64)
```
https://github.com/llvm/llvm-project/pull/163008
More information about the llvm-commits
mailing list