2018-04-12 13:36:44 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc -mtriple=riscv32 -mattr=+d -verify-machineinstrs < %s \
|
|
|
|
; RUN: | FileCheck -check-prefix=RV32IFD %s
|
2019-02-01 11:53:30 +08:00
|
|
|
; RUN: llc -mtriple=riscv64 -mattr=+d -verify-machineinstrs < %s \
|
|
|
|
; RUN: | FileCheck -check-prefix=RV64IFD %s
|
2018-04-12 13:36:44 +08:00
|
|
|
|
|
|
|
define double @double_imm() nounwind {
|
2019-02-01 11:53:30 +08:00
|
|
|
; TODO: Should probably prefer fld or ld on RV64 rather than materialising an
|
|
|
|
; expensive constant.
|
|
|
|
;
|
2018-04-12 13:36:44 +08:00
|
|
|
; RV32IFD-LABEL: double_imm:
|
|
|
|
; RV32IFD: # %bb.0:
|
2019-03-30 17:15:47 +08:00
|
|
|
; RV32IFD-NEXT: lui a0, 345155
|
|
|
|
; RV32IFD-NEXT: addi a0, a0, -744
|
|
|
|
; RV32IFD-NEXT: lui a1, 262290
|
|
|
|
; RV32IFD-NEXT: addi a1, a1, 507
|
2018-04-12 13:36:44 +08:00
|
|
|
; RV32IFD-NEXT: ret
|
2019-02-01 11:53:30 +08:00
|
|
|
;
|
|
|
|
; RV64IFD-LABEL: double_imm:
|
|
|
|
; RV64IFD: # %bb.0:
|
|
|
|
; RV64IFD-NEXT: lui a0, 512
|
|
|
|
; RV64IFD-NEXT: addiw a0, a0, 1169
|
|
|
|
; RV64IFD-NEXT: slli a0, a0, 15
|
|
|
|
; RV64IFD-NEXT: addi a0, a0, -299
|
|
|
|
; RV64IFD-NEXT: slli a0, a0, 14
|
|
|
|
; RV64IFD-NEXT: addi a0, a0, 1091
|
|
|
|
; RV64IFD-NEXT: slli a0, a0, 12
|
|
|
|
; RV64IFD-NEXT: addi a0, a0, -744
|
|
|
|
; RV64IFD-NEXT: ret
|
2018-04-12 13:36:44 +08:00
|
|
|
ret double 3.1415926535897931159979634685441851615905761718750
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @double_imm_op(double %a) nounwind {
|
|
|
|
; RV32IFD-LABEL: double_imm_op:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -16
|
|
|
|
; RV32IFD-NEXT: sw a0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a1, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: lui a0, %hi(.LCPI1_0)
|
|
|
|
; RV32IFD-NEXT: addi a0, a0, %lo(.LCPI1_0)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 0(a0)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft0, ft1
|
|
|
|
; RV32IFD-NEXT: fsd ft0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: lw a0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: lw a1, 12(sp)
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, 16
|
|
|
|
; RV32IFD-NEXT: ret
|
2019-02-01 11:53:30 +08:00
|
|
|
;
|
|
|
|
; RV64IFD-LABEL: double_imm_op:
|
|
|
|
; RV64IFD: # %bb.0:
|
|
|
|
; RV64IFD-NEXT: fmv.d.x ft0, a0
|
|
|
|
; RV64IFD-NEXT: lui a0, %hi(.LCPI1_0)
|
|
|
|
; RV64IFD-NEXT: addi a0, a0, %lo(.LCPI1_0)
|
|
|
|
; RV64IFD-NEXT: fld ft1, 0(a0)
|
|
|
|
; RV64IFD-NEXT: fadd.d ft0, ft0, ft1
|
|
|
|
; RV64IFD-NEXT: fmv.x.d a0, ft0
|
|
|
|
; RV64IFD-NEXT: ret
|
2018-04-12 13:36:44 +08:00
|
|
|
%1 = fadd double %a, 1.0
|
|
|
|
ret double %1
|
|
|
|
}
|