[PATCH] D146321: [RISCV] Add isReMaterializable to FLI instructions.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 17 12:05:12 PDT 2023
craig.topper updated this revision to Diff 506166.
craig.topper added a comment.
Regenerate the test to show the correct codegen. I think I regenerated the test with a stale build.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146321/new/
https://reviews.llvm.org/D146321
Files:
llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
llvm/test/CodeGen/RISCV/float-zfa.ll
Index: llvm/test/CodeGen/RISCV/float-zfa.ll
===================================================================
--- llvm/test/CodeGen/RISCV/float-zfa.ll
+++ llvm/test/CodeGen/RISCV/float-zfa.ll
@@ -227,3 +227,16 @@
%2 = zext i1 %1 to i32
ret i32 %2
}
+
+declare void @foo(float, float)
+
+; Make sure we use two fli instructions instead of copying.
+define void @fli_remat() {
+; CHECK-LABEL: fli_remat:
+; CHECK: # %bb.0:
+; CHECK-NEXT: fli.s fa0, 1.0
+; CHECK-NEXT: fli.s fa1, 1.0
+; CHECK-NEXT: tail foo at plt
+ tail call void @foo(float 1.000000e+00, float 1.000000e+00)
+ ret void
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
@@ -93,7 +93,7 @@
//===----------------------------------------------------------------------===//
let Predicates = [HasStdExtZfa] in {
-let isAsCheapAsAMove = 1 in
+let isReMaterializable = 1, isAsCheapAsAMove = 1 in
def FLI_S : FPUnaryOp_imm<0b1111000, 0b00001, 0b000, OPC_OP_FP, (outs FPR32:$rd),
(ins loadfp32imm:$imm), "fli.s", "$rd, $imm">;
@@ -108,7 +108,7 @@
} // Predicates = [HasStdExtZfa]
let Predicates = [HasStdExtZfa, HasStdExtD] in {
-let isAsCheapAsAMove = 1 in
+let isReMaterializable = 1, isAsCheapAsAMove = 1 in
def FLI_D : FPUnaryOp_imm<0b1111001, 0b00001, 0b000, OPC_OP_FP, (outs FPR64:$rd),
(ins loadfp64imm:$imm), "fli.d", "$rd, $imm">;
@@ -138,7 +138,7 @@
} // Predicates = [HasStdExtZfa, HasStdExtD, IsRV32]
let Predicates = [HasStdExtZfa, HasStdExtZfhOrZvfh] in
-let isAsCheapAsAMove = 1 in
+let isReMaterializable = 1, isAsCheapAsAMove = 1 in
def FLI_H : FPUnaryOp_imm<0b1111010, 0b00001, 0b000, OPC_OP_FP, (outs FPR16:$rd),
(ins loadfp16imm:$imm), "fli.h", "$rd, $imm">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146321.506166.patch
Type: text/x-patch
Size: 1882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230317/caec6acc/attachment.bin>
More information about the llvm-commits
mailing list