diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td @@ -93,6 +93,7 @@ //===----------------------------------------------------------------------===// let Predicates = [HasStdExtZfa] in { +let isAsCheapAsAMove = 1 in def FLI_S : FPUnaryOp_imm<0b1111000, 0b00001, 0b000, OPC_OP_FP, (outs FPR32:$rd), (ins loadfp32imm:$imm), "fli.s", "$rd, $imm">; @@ -107,6 +108,7 @@ } // Predicates = [HasStdExtZfa] let Predicates = [HasStdExtZfa, HasStdExtD] in { +let isAsCheapAsAMove = 1 in def FLI_D : FPUnaryOp_imm<0b1111001, 0b00001, 0b000, OPC_OP_FP, (outs FPR64:$rd), (ins loadfp64imm:$imm), "fli.d", "$rd, $imm">; @@ -136,6 +138,7 @@ } // Predicates = [HasStdExtZfa, HasStdExtD, IsRV32] let Predicates = [HasStdExtZfa, HasStdExtZfhOrZvfh] in +let isAsCheapAsAMove = 1 in def FLI_H : FPUnaryOp_imm<0b1111010, 0b00001, 0b000, OPC_OP_FP, (outs FPR16:$rd), (ins loadfp16imm:$imm), "fli.h", "$rd, $imm">; diff --git a/llvm/test/CodeGen/RISCV/fli-licm.ll b/llvm/test/CodeGen/RISCV/fli-licm.ll --- a/llvm/test/CodeGen/RISCV/fli-licm.ll +++ b/llvm/test/CodeGen/RISCV/fli-licm.ll @@ -15,14 +15,12 @@ ; RV32-NEXT: addi sp, sp, -16 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill ; RV32-NEXT: sw s0, 8(sp) # 4-byte Folded Spill -; RV32-NEXT: fsw fs0, 4(sp) # 4-byte Folded Spill ; RV32-NEXT: beqz a0, .LBB0_3 ; RV32-NEXT: # %bb.1: # %loop.preheader ; RV32-NEXT: mv s0, a0 -; RV32-NEXT: fli.s fs0, 1.0 ; RV32-NEXT: .LBB0_2: # %loop ; RV32-NEXT: # =>This Inner Loop Header: Depth=1 -; RV32-NEXT: fmv.s fa0, fs0 +; RV32-NEXT: fli.s fa0, 1.0 ; RV32-NEXT: mv a0, s0 ; RV32-NEXT: call do_it@plt ; RV32-NEXT: lw s0, 0(s0) @@ -30,32 +28,28 @@ ; RV32-NEXT: .LBB0_3: # %exit ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32-NEXT: lw s0, 8(sp) # 4-byte Folded Reload -; RV32-NEXT: flw fs0, 4(sp) # 4-byte Folded Reload ; RV32-NEXT: addi sp, sp, 16 ; RV32-NEXT: ret ; ; RV64-LABEL: process_nodes: ; RV64: # %bb.0: # %entry -; RV64-NEXT: addi sp, sp, -32 -; RV64-NEXT: sd ra, 24(sp) # 8-byte Folded Spill -; RV64-NEXT: sd s0, 16(sp) # 8-byte Folded Spill -; RV64-NEXT: fsw fs0, 12(sp) # 4-byte Folded Spill +; RV64-NEXT: addi sp, sp, -16 +; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill +; RV64-NEXT: sd s0, 0(sp) # 8-byte Folded Spill ; RV64-NEXT: beqz a0, .LBB0_3 ; RV64-NEXT: # %bb.1: # %loop.preheader ; RV64-NEXT: mv s0, a0 -; RV64-NEXT: fli.s fs0, 1.0 ; RV64-NEXT: .LBB0_2: # %loop ; RV64-NEXT: # =>This Inner Loop Header: Depth=1 -; RV64-NEXT: fmv.s fa0, fs0 +; RV64-NEXT: fli.s fa0, 1.0 ; RV64-NEXT: mv a0, s0 ; RV64-NEXT: call do_it@plt ; RV64-NEXT: ld s0, 0(s0) ; RV64-NEXT: bnez s0, .LBB0_2 ; RV64-NEXT: .LBB0_3: # %exit -; RV64-NEXT: ld ra, 24(sp) # 8-byte Folded Reload -; RV64-NEXT: ld s0, 16(sp) # 8-byte Folded Reload -; RV64-NEXT: flw fs0, 12(sp) # 4-byte Folded Reload -; RV64-NEXT: addi sp, sp, 32 +; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload +; RV64-NEXT: ld s0, 0(sp) # 8-byte Folded Reload +; RV64-NEXT: addi sp, sp, 16 ; RV64-NEXT: ret entry: %1 = icmp eq ptr %0, null