Skip to content

Commit dbbc95e

Browse files
committed
[RISCV] Use softPromoteHalf legalization for fp16 without Zfh rather than PromoteFloat.
The default legalization strategy is PromoteFloat which keeps half in single precision format through multiple floating point operations. Conversion to/from float is done at loads, stores, bitcasts, and other places that care about the exact size being 16 bits. This patches switches to the alternative method softPromoteHalf. This aims to keep the type in 16-bit format between every operation. So we promote to float and immediately round for any arithmetic operation. This should be closer to the IR semantics since we are rounding after each operation and not accumulating extra precision across multiple operations. X86 is the only other target that enables this today. See https://reviews.llvm.org/D73749 I had to update getRegisterTypeForCallingConv to force f16 to use f32 when the F extension is enabled. This way we can still pass it in the lower bits of an FPR for ilp32f and lp64f ABIs. The softPromoteHalf would otherwise always give i16 as the argument type. Reviewed By: asb, frasercrmck Differential Revision: https://reviews.llvm.org/D99148
1 parent d4e9fe8 commit dbbc95e

7 files changed

+156
-194
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,28 @@ bool RISCVTargetLowering::hasBitPreservingFPLogic(EVT VT) const {
858858
(VT == MVT::f64 && Subtarget.hasStdExtD());
859859
}
860860

861+
MVT RISCVTargetLowering::getRegisterTypeForCallingConv(LLVMContext &Context,
862+
CallingConv::ID CC,
863+
EVT VT) const {
864+
// Use f32 to pass f16 if it is legal and Zfh is not enabled. We might still
865+
// end up using a GPR but that will be decided based on ABI.
866+
if (VT == MVT::f16 && Subtarget.hasStdExtF() && !Subtarget.hasStdExtZfh())
867+
return MVT::f32;
868+
869+
return TargetLowering::getRegisterTypeForCallingConv(Context, CC, VT);
870+
}
871+
872+
unsigned RISCVTargetLowering::getNumRegistersForCallingConv(LLVMContext &Context,
873+
CallingConv::ID CC,
874+
EVT VT) const {
875+
// Use f32 to pass f16 if it is legal and Zfh is not enabled. We might still
876+
// end up using a GPR but that will be decided based on ABI.
877+
if (VT == MVT::f16 && Subtarget.hasStdExtF() && !Subtarget.hasStdExtZfh())
878+
return 1;
879+
880+
return TargetLowering::getNumRegistersForCallingConv(Context, CC, VT);
881+
}
882+
861883
// Changes the condition code and swaps operands if necessary, so the SetCC
862884
// operation matches one of the comparisons supported directly by branches
863885
// in the RISC-V ISA. May adjust compares to favor compare with 0 over compare

llvm/lib/Target/RISCV/RISCVISelLowering.h

+13
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,19 @@ class RISCVTargetLowering : public TargetLowering {
261261
bool isFPImmLegal(const APFloat &Imm, EVT VT,
262262
bool ForCodeSize) const override;
263263

264+
bool softPromoteHalfType() const override { return true; }
265+
266+
/// Return the register type for a given MVT, ensuring vectors are treated
267+
/// as a series of gpr sized integers.
268+
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC,
269+
EVT VT) const override;
270+
271+
/// Return the number of registers for a given MVT, ensuring vectors are
272+
/// treated as a series of gpr sized integers.
273+
unsigned getNumRegistersForCallingConv(LLVMContext &Context,
274+
CallingConv::ID CC,
275+
EVT VT) const override;
276+
264277
/// Return true if the given shuffle mask can be codegen'd directly, or if it
265278
/// should be stack expanded.
266279
bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;

llvm/test/CodeGen/RISCV/calling-conv-half.ll

+4-4
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ define i32 @callee_half_on_stack(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
191191
; RV32I-NEXT: addi sp, sp, -16
192192
; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
193193
; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
194-
; RV32I-NEXT: mv s0, a7
195194
; RV32I-NEXT: lhu a0, 16(sp)
195+
; RV32I-NEXT: mv s0, a7
196196
; RV32I-NEXT: call __gnu_h2f_ieee@plt
197197
; RV32I-NEXT: call __fixsfsi@plt
198198
; RV32I-NEXT: add a0, s0, a0
@@ -206,8 +206,8 @@ define i32 @callee_half_on_stack(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
206206
; RV64I-NEXT: addi sp, sp, -16
207207
; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
208208
; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
209-
; RV64I-NEXT: mv s0, a7
210209
; RV64I-NEXT: lhu a0, 16(sp)
210+
; RV64I-NEXT: mv s0, a7
211211
; RV64I-NEXT: call __gnu_h2f_ieee@plt
212212
; RV64I-NEXT: call __fixsfdi@plt
213213
; RV64I-NEXT: addw a0, s0, a0
@@ -221,8 +221,8 @@ define i32 @callee_half_on_stack(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
221221
; RV32IF-NEXT: addi sp, sp, -16
222222
; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
223223
; RV32IF-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
224-
; RV32IF-NEXT: mv s0, a7
225224
; RV32IF-NEXT: lhu a0, 16(sp)
225+
; RV32IF-NEXT: mv s0, a7
226226
; RV32IF-NEXT: call __gnu_h2f_ieee@plt
227227
; RV32IF-NEXT: fmv.w.x ft0, a0
228228
; RV32IF-NEXT: fcvt.w.s a0, ft0, rtz
@@ -237,8 +237,8 @@ define i32 @callee_half_on_stack(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f,
237237
; RV64IF-NEXT: addi sp, sp, -16
238238
; RV64IF-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
239239
; RV64IF-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
240-
; RV64IF-NEXT: mv s0, a7
241240
; RV64IF-NEXT: lhu a0, 16(sp)
241+
; RV64IF-NEXT: mv s0, a7
242242
; RV64IF-NEXT: call __gnu_h2f_ieee@plt
243243
; RV64IF-NEXT: fmv.w.x ft0, a0
244244
; RV64IF-NEXT: fcvt.l.s a0, ft0, rtz

llvm/test/CodeGen/RISCV/copysign-casts.ll

+79-132
Original file line numberDiff line numberDiff line change
@@ -340,98 +340,73 @@ define float @fold_demote_s_d(float %a, double %b) nounwind {
340340
define half @fold_demote_h_s(half %a, float %b) nounwind {
341341
; RV32I-LABEL: fold_demote_h_s:
342342
; RV32I: # %bb.0:
343-
; RV32I-NEXT: addi sp, sp, -16
344-
; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
345-
; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
346-
; RV32I-NEXT: mv s0, a1
347-
; RV32I-NEXT: lui a1, 16
348-
; RV32I-NEXT: addi a1, a1, -1
349-
; RV32I-NEXT: and a0, a0, a1
350-
; RV32I-NEXT: call __gnu_h2f_ieee@plt
351-
; RV32I-NEXT: lui a1, 524288
352-
; RV32I-NEXT: and a2, s0, a1
353-
; RV32I-NEXT: addi a1, a1, -1
354-
; RV32I-NEXT: and a0, a0, a1
355-
; RV32I-NEXT: or a0, a0, a2
356-
; RV32I-NEXT: call __gnu_f2h_ieee@plt
357-
; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
358-
; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
359-
; RV32I-NEXT: addi sp, sp, 16
343+
; RV32I-NEXT: lui a2, 8
344+
; RV32I-NEXT: addi a2, a2, -1
345+
; RV32I-NEXT: and a0, a0, a2
346+
; RV32I-NEXT: lui a2, 524288
347+
; RV32I-NEXT: and a1, a1, a2
348+
; RV32I-NEXT: srli a1, a1, 16
349+
; RV32I-NEXT: or a0, a0, a1
360350
; RV32I-NEXT: ret
361351
;
362352
; RV64I-LABEL: fold_demote_h_s:
363353
; RV64I: # %bb.0:
364-
; RV64I-NEXT: addi sp, sp, -16
365-
; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
366-
; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
367-
; RV64I-NEXT: mv s0, a1
368-
; RV64I-NEXT: lui a1, 16
369-
; RV64I-NEXT: addiw a1, a1, -1
370-
; RV64I-NEXT: and a0, a0, a1
371-
; RV64I-NEXT: call __gnu_h2f_ieee@plt
372-
; RV64I-NEXT: lui a1, 524288
373-
; RV64I-NEXT: and a2, s0, a1
374-
; RV64I-NEXT: addiw a1, a1, -1
375-
; RV64I-NEXT: and a0, a0, a1
376-
; RV64I-NEXT: or a0, a0, a2
377-
; RV64I-NEXT: call __gnu_f2h_ieee@plt
378-
; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
379-
; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
380-
; RV64I-NEXT: addi sp, sp, 16
354+
; RV64I-NEXT: lui a2, 8
355+
; RV64I-NEXT: addiw a2, a2, -1
356+
; RV64I-NEXT: and a0, a0, a2
357+
; RV64I-NEXT: addi a2, zero, 1
358+
; RV64I-NEXT: slli a2, a2, 31
359+
; RV64I-NEXT: and a1, a1, a2
360+
; RV64I-NEXT: srli a1, a1, 16
361+
; RV64I-NEXT: or a0, a0, a1
381362
; RV64I-NEXT: ret
382363
;
383364
; RV32IF-LABEL: fold_demote_h_s:
384365
; RV32IF: # %bb.0:
385-
; RV32IF-NEXT: addi sp, sp, -16
386-
; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
387-
; RV32IF-NEXT: fsw fs0, 8(sp) # 4-byte Folded Spill
388-
; RV32IF-NEXT: fmv.s fs0, fa1
389-
; RV32IF-NEXT: fmv.x.w a0, fa0
390-
; RV32IF-NEXT: call __gnu_h2f_ieee@plt
391-
; RV32IF-NEXT: fsgnj.s fa0, fa0, fs0
392-
; RV32IF-NEXT: call __gnu_f2h_ieee@plt
366+
; RV32IF-NEXT: fmv.x.w a0, fa1
367+
; RV32IF-NEXT: fmv.x.w a1, fa0
368+
; RV32IF-NEXT: lui a2, 8
369+
; RV32IF-NEXT: addi a2, a2, -1
370+
; RV32IF-NEXT: and a1, a1, a2
371+
; RV32IF-NEXT: lui a2, 524288
372+
; RV32IF-NEXT: and a0, a0, a2
373+
; RV32IF-NEXT: srli a0, a0, 16
374+
; RV32IF-NEXT: or a0, a1, a0
393375
; RV32IF-NEXT: lui a1, 1048560
394376
; RV32IF-NEXT: or a0, a0, a1
395377
; RV32IF-NEXT: fmv.w.x fa0, a0
396-
; RV32IF-NEXT: flw fs0, 8(sp) # 4-byte Folded Reload
397-
; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
398-
; RV32IF-NEXT: addi sp, sp, 16
399378
; RV32IF-NEXT: ret
400379
;
401380
; RV32IFD-LABEL: fold_demote_h_s:
402381
; RV32IFD: # %bb.0:
403-
; RV32IFD-NEXT: addi sp, sp, -16
404-
; RV32IFD-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
405-
; RV32IFD-NEXT: fsd fs0, 0(sp) # 8-byte Folded Spill
406-
; RV32IFD-NEXT: fmv.s fs0, fa1
407-
; RV32IFD-NEXT: fmv.x.w a0, fa0
408-
; RV32IFD-NEXT: call __gnu_h2f_ieee@plt
409-
; RV32IFD-NEXT: fsgnj.s fa0, fa0, fs0
410-
; RV32IFD-NEXT: call __gnu_f2h_ieee@plt
382+
; RV32IFD-NEXT: fmv.x.w a0, fa1
383+
; RV32IFD-NEXT: fmv.x.w a1, fa0
384+
; RV32IFD-NEXT: lui a2, 8
385+
; RV32IFD-NEXT: addi a2, a2, -1
386+
; RV32IFD-NEXT: and a1, a1, a2
387+
; RV32IFD-NEXT: lui a2, 524288
388+
; RV32IFD-NEXT: and a0, a0, a2
389+
; RV32IFD-NEXT: srli a0, a0, 16
390+
; RV32IFD-NEXT: or a0, a1, a0
411391
; RV32IFD-NEXT: lui a1, 1048560
412392
; RV32IFD-NEXT: or a0, a0, a1
413393
; RV32IFD-NEXT: fmv.w.x fa0, a0
414-
; RV32IFD-NEXT: fld fs0, 0(sp) # 8-byte Folded Reload
415-
; RV32IFD-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
416-
; RV32IFD-NEXT: addi sp, sp, 16
417394
; RV32IFD-NEXT: ret
418395
;
419396
; RV64IFD-LABEL: fold_demote_h_s:
420397
; RV64IFD: # %bb.0:
421-
; RV64IFD-NEXT: addi sp, sp, -16
422-
; RV64IFD-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
423-
; RV64IFD-NEXT: fsd fs0, 0(sp) # 8-byte Folded Spill
424-
; RV64IFD-NEXT: fmv.s fs0, fa1
425-
; RV64IFD-NEXT: fmv.x.w a0, fa0
426-
; RV64IFD-NEXT: call __gnu_h2f_ieee@plt
427-
; RV64IFD-NEXT: fsgnj.s fa0, fa0, fs0
428-
; RV64IFD-NEXT: call __gnu_f2h_ieee@plt
398+
; RV64IFD-NEXT: fmv.x.w a0, fa1
399+
; RV64IFD-NEXT: fmv.x.w a1, fa0
400+
; RV64IFD-NEXT: lui a2, 8
401+
; RV64IFD-NEXT: addiw a2, a2, -1
402+
; RV64IFD-NEXT: and a1, a1, a2
403+
; RV64IFD-NEXT: lui a2, 524288
404+
; RV64IFD-NEXT: and a0, a0, a2
405+
; RV64IFD-NEXT: srli a0, a0, 16
406+
; RV64IFD-NEXT: or a0, a1, a0
429407
; RV64IFD-NEXT: lui a1, 1048560
430408
; RV64IFD-NEXT: or a0, a0, a1
431409
; RV64IFD-NEXT: fmv.w.x fa0, a0
432-
; RV64IFD-NEXT: fld fs0, 0(sp) # 8-byte Folded Reload
433-
; RV64IFD-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
434-
; RV64IFD-NEXT: addi sp, sp, 16
435410
; RV64IFD-NEXT: ret
436411
;
437412
; RV32IFZFH-LABEL: fold_demote_h_s:
@@ -459,104 +434,76 @@ define half @fold_demote_h_s(half %a, float %b) nounwind {
459434
define half @fold_demote_h_d(half %a, double %b) nounwind {
460435
; RV32I-LABEL: fold_demote_h_d:
461436
; RV32I: # %bb.0:
462-
; RV32I-NEXT: addi sp, sp, -16
463-
; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
464-
; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
465-
; RV32I-NEXT: mv s0, a2
466-
; RV32I-NEXT: lui a1, 16
437+
; RV32I-NEXT: lui a1, 8
467438
; RV32I-NEXT: addi a1, a1, -1
468439
; RV32I-NEXT: and a0, a0, a1
469-
; RV32I-NEXT: call __gnu_h2f_ieee@plt
470440
; RV32I-NEXT: lui a1, 524288
471-
; RV32I-NEXT: and a2, s0, a1
472-
; RV32I-NEXT: addi a1, a1, -1
473-
; RV32I-NEXT: and a0, a0, a1
474-
; RV32I-NEXT: or a0, a0, a2
475-
; RV32I-NEXT: call __gnu_f2h_ieee@plt
476-
; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
477-
; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
478-
; RV32I-NEXT: addi sp, sp, 16
441+
; RV32I-NEXT: and a1, a2, a1
442+
; RV32I-NEXT: srli a1, a1, 16
443+
; RV32I-NEXT: or a0, a0, a1
479444
; RV32I-NEXT: ret
480445
;
481446
; RV64I-LABEL: fold_demote_h_d:
482447
; RV64I: # %bb.0:
483-
; RV64I-NEXT: addi sp, sp, -16
484-
; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
485-
; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
486-
; RV64I-NEXT: mv s0, a1
487-
; RV64I-NEXT: lui a1, 16
488-
; RV64I-NEXT: addiw a1, a1, -1
489-
; RV64I-NEXT: and a0, a0, a1
490-
; RV64I-NEXT: call __gnu_h2f_ieee@plt
491-
; RV64I-NEXT: lui a1, 524288
492-
; RV64I-NEXT: addiw a1, a1, -1
493-
; RV64I-NEXT: and a0, a0, a1
494-
; RV64I-NEXT: addi a1, zero, -1
495-
; RV64I-NEXT: slli a1, a1, 63
496-
; RV64I-NEXT: and a1, s0, a1
497-
; RV64I-NEXT: srli a1, a1, 32
448+
; RV64I-NEXT: lui a2, 8
449+
; RV64I-NEXT: addiw a2, a2, -1
450+
; RV64I-NEXT: and a0, a0, a2
451+
; RV64I-NEXT: addi a2, zero, -1
452+
; RV64I-NEXT: slli a2, a2, 63
453+
; RV64I-NEXT: and a1, a1, a2
454+
; RV64I-NEXT: srli a1, a1, 48
498455
; RV64I-NEXT: or a0, a0, a1
499-
; RV64I-NEXT: call __gnu_f2h_ieee@plt
500-
; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
501-
; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
502-
; RV64I-NEXT: addi sp, sp, 16
503456
; RV64I-NEXT: ret
504457
;
505458
; RV32IF-LABEL: fold_demote_h_d:
506459
; RV32IF: # %bb.0:
507-
; RV32IF-NEXT: addi sp, sp, -16
508-
; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
509-
; RV32IF-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
510-
; RV32IF-NEXT: mv s0, a1
511460
; RV32IF-NEXT: fmv.x.w a0, fa0
512-
; RV32IF-NEXT: call __gnu_h2f_ieee@plt
513-
; RV32IF-NEXT: fmv.w.x ft0, s0
514-
; RV32IF-NEXT: fsgnj.s fa0, fa0, ft0
515-
; RV32IF-NEXT: call __gnu_f2h_ieee@plt
461+
; RV32IF-NEXT: lui a2, 8
462+
; RV32IF-NEXT: addi a2, a2, -1
463+
; RV32IF-NEXT: and a0, a0, a2
464+
; RV32IF-NEXT: lui a2, 524288
465+
; RV32IF-NEXT: and a1, a1, a2
466+
; RV32IF-NEXT: srli a1, a1, 16
467+
; RV32IF-NEXT: or a0, a0, a1
516468
; RV32IF-NEXT: lui a1, 1048560
517469
; RV32IF-NEXT: or a0, a0, a1
518470
; RV32IF-NEXT: fmv.w.x fa0, a0
519-
; RV32IF-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
520-
; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
521-
; RV32IF-NEXT: addi sp, sp, 16
522471
; RV32IF-NEXT: ret
523472
;
524473
; RV32IFD-LABEL: fold_demote_h_d:
525474
; RV32IFD: # %bb.0:
526475
; RV32IFD-NEXT: addi sp, sp, -16
527-
; RV32IFD-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
528-
; RV32IFD-NEXT: fsd fs0, 0(sp) # 8-byte Folded Spill
529-
; RV32IFD-NEXT: fmv.d fs0, fa1
476+
; RV32IFD-NEXT: fsd fa1, 8(sp)
530477
; RV32IFD-NEXT: fmv.x.w a0, fa0
531-
; RV32IFD-NEXT: call __gnu_h2f_ieee@plt
532-
; RV32IFD-NEXT: fcvt.s.d ft0, fs0
533-
; RV32IFD-NEXT: fsgnj.s fa0, fa0, ft0
534-
; RV32IFD-NEXT: call __gnu_f2h_ieee@plt
478+
; RV32IFD-NEXT: lw a1, 12(sp)
479+
; RV32IFD-NEXT: lui a2, 8
480+
; RV32IFD-NEXT: addi a2, a2, -1
481+
; RV32IFD-NEXT: and a0, a0, a2
482+
; RV32IFD-NEXT: lui a2, 524288
483+
; RV32IFD-NEXT: and a1, a1, a2
484+
; RV32IFD-NEXT: srli a1, a1, 16
485+
; RV32IFD-NEXT: or a0, a0, a1
535486
; RV32IFD-NEXT: lui a1, 1048560
536487
; RV32IFD-NEXT: or a0, a0, a1
537488
; RV32IFD-NEXT: fmv.w.x fa0, a0
538-
; RV32IFD-NEXT: fld fs0, 0(sp) # 8-byte Folded Reload
539-
; RV32IFD-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
540489
; RV32IFD-NEXT: addi sp, sp, 16
541490
; RV32IFD-NEXT: ret
542491
;
543492
; RV64IFD-LABEL: fold_demote_h_d:
544493
; RV64IFD: # %bb.0:
545-
; RV64IFD-NEXT: addi sp, sp, -16
546-
; RV64IFD-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
547-
; RV64IFD-NEXT: fsd fs0, 0(sp) # 8-byte Folded Spill
548-
; RV64IFD-NEXT: fmv.d fs0, fa1
549-
; RV64IFD-NEXT: fmv.x.w a0, fa0
550-
; RV64IFD-NEXT: call __gnu_h2f_ieee@plt
551-
; RV64IFD-NEXT: fcvt.s.d ft0, fs0
552-
; RV64IFD-NEXT: fsgnj.s fa0, fa0, ft0
553-
; RV64IFD-NEXT: call __gnu_f2h_ieee@plt
494+
; RV64IFD-NEXT: fmv.x.d a0, fa1
495+
; RV64IFD-NEXT: fmv.x.w a1, fa0
496+
; RV64IFD-NEXT: lui a2, 8
497+
; RV64IFD-NEXT: addiw a2, a2, -1
498+
; RV64IFD-NEXT: and a1, a1, a2
499+
; RV64IFD-NEXT: addi a2, zero, -1
500+
; RV64IFD-NEXT: slli a2, a2, 63
501+
; RV64IFD-NEXT: and a0, a0, a2
502+
; RV64IFD-NEXT: srli a0, a0, 48
503+
; RV64IFD-NEXT: or a0, a1, a0
554504
; RV64IFD-NEXT: lui a1, 1048560
555505
; RV64IFD-NEXT: or a0, a0, a1
556506
; RV64IFD-NEXT: fmv.w.x fa0, a0
557-
; RV64IFD-NEXT: fld fs0, 0(sp) # 8-byte Folded Reload
558-
; RV64IFD-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
559-
; RV64IFD-NEXT: addi sp, sp, 16
560507
; RV64IFD-NEXT: ret
561508
;
562509
; RV32IFZFH-LABEL: fold_demote_h_d:

0 commit comments

Comments
 (0)