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
|
|
|
|
|
|
|
|
define double @fld(double *%a) nounwind {
|
|
|
|
; RV32IFD-LABEL: fld:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -16
|
|
|
|
; RV32IFD-NEXT: fld ft0, 24(a0)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 0(a0)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft1, ft0
|
|
|
|
; 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
|
|
|
|
%1 = load double, double* %a
|
|
|
|
%2 = getelementptr double, double* %a, i32 3
|
|
|
|
%3 = load double, double* %2
|
|
|
|
; Use both loaded values in an FP op to ensure an fld is used, even for the
|
|
|
|
; soft float ABI
|
|
|
|
%4 = fadd double %1, %3
|
|
|
|
ret double %4
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @fsd(double *%a, double %b, double %c) nounwind {
|
|
|
|
; RV32IFD-LABEL: fsd:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -16
|
|
|
|
; RV32IFD-NEXT: sw a3, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a4, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a1, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a2, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 8(sp)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft1, ft0
|
|
|
|
; RV32IFD-NEXT: fsd ft0, 64(a0)
|
|
|
|
; RV32IFD-NEXT: fsd ft0, 0(a0)
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, 16
|
|
|
|
; RV32IFD-NEXT: ret
|
|
|
|
; Use %b and %c in an FP op to ensure floating point registers are used, even
|
|
|
|
; for the soft float ABI
|
|
|
|
%1 = fadd double %b, %c
|
|
|
|
store double %1, double* %a
|
|
|
|
%2 = getelementptr double, double* %a, i32 8
|
|
|
|
store double %1, double* %2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Check load and store to a global
|
|
|
|
@G = global double 0.0
|
|
|
|
|
|
|
|
define double @fld_fsd_global(double %a, double %b) nounwind {
|
|
|
|
; RV32IFD-LABEL: fld_fsd_global:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -16
|
|
|
|
; RV32IFD-NEXT: sw a2, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a3, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a1, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 8(sp)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft1, ft0
|
|
|
|
; RV32IFD-NEXT: lui a0, %hi(G)
|
|
|
|
; RV32IFD-NEXT: fld ft1, %lo(G)(a0)
|
|
|
|
; RV32IFD-NEXT: fsd ft0, %lo(G)(a0)
|
[RISCV] Separate base from offset in lowerGlobalAddress
Summary:
When lowering global address, lower the base as a TargetGlobal first then
create an SDNode for the offset separately and chain it to the address calculation
This optimization will create a DAG where the base address of a global access will
be reused between different access. The offset can later be folded into the immediate
part of the memory access instruction.
With this optimization we generate:
lui a0, %hi(s)
addi a0, a0, %lo(s) ; shared base address.
addi a1, zero, 20 ; 2 instructions per access.
sw a1, 44(a0)
addi a1, zero, 10
sw a1, 8(a0)
addi a1, zero, 30
sw a1, 80(a0)
Instead of:
lui a0, %hi(s+44) ; 3 instructions per access.
addi a1, zero, 20
sw a1, %lo(s+44)(a0)
lui a0, %hi(s+8)
addi a1, zero, 10
sw a1, %lo(s+8)(a0)
lui a0, %hi(s+80)
addi a1, zero, 30
sw a1, %lo(s+80)(a0)
Which will save one instruction per access.
Reviewers: asb, apazos
Reviewed By: asb
Subscribers: rbar, johnrusso, simoncook, jordy.potman.lists, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, apazos, asb, llvm-commits
Differential Revision: https://reviews.llvm.org/D46989
llvm-svn: 332641
2018-05-18 02:14:53 +08:00
|
|
|
; RV32IFD-NEXT: addi a0, a0, %lo(G)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 72(a0)
|
|
|
|
; RV32IFD-NEXT: fsd ft0, 72(a0)
|
2018-04-12 13:36:44 +08:00
|
|
|
; 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
|
|
|
|
; Use %a and %b in an FP op to ensure floating point registers are used, even
|
|
|
|
; for the soft float ABI
|
|
|
|
%1 = fadd double %a, %b
|
|
|
|
%2 = load volatile double, double* @G
|
|
|
|
store double %1, double* @G
|
|
|
|
%3 = getelementptr double, double* @G, i32 9
|
|
|
|
%4 = load volatile double, double* %3
|
|
|
|
store double %1, double* %3
|
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; Ensure that 1 is added to the high 20 bits if bit 11 of the low part is 1
|
|
|
|
define double @fld_fsd_constant(double %a) nounwind {
|
|
|
|
; RV32IFD-LABEL: fld_fsd_constant:
|
|
|
|
; 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, 912092
|
|
|
|
; RV32IFD-NEXT: fld ft1, -273(a0)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft0, ft1
|
|
|
|
; RV32IFD-NEXT: fsd ft0, -273(a0)
|
|
|
|
; 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
|
|
|
|
%1 = inttoptr i32 3735928559 to double*
|
|
|
|
%2 = load volatile double, double* %1
|
|
|
|
%3 = fadd double %a, %2
|
|
|
|
store double %3, double* %1
|
|
|
|
ret double %3
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @notdead(i8*)
|
|
|
|
|
|
|
|
define double @fld_stack(double %a) nounwind {
|
|
|
|
; RV32IFD-LABEL: fld_stack:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -32
|
|
|
|
; RV32IFD-NEXT: sw ra, 28(sp)
|
|
|
|
; RV32IFD-NEXT: sw s1, 24(sp)
|
|
|
|
; RV32IFD-NEXT: sw s2, 20(sp)
|
|
|
|
; RV32IFD-NEXT: mv s1, a1
|
|
|
|
; RV32IFD-NEXT: mv s2, a0
|
|
|
|
; RV32IFD-NEXT: addi a0, sp, 8
|
2018-04-25 22:19:12 +08:00
|
|
|
; RV32IFD-NEXT: call notdead
|
2018-04-12 13:36:44 +08:00
|
|
|
; RV32IFD-NEXT: sw s2, 0(sp)
|
|
|
|
; RV32IFD-NEXT: sw s1, 4(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft0, 0(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 8(sp)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft1, ft0
|
|
|
|
; RV32IFD-NEXT: fsd ft0, 0(sp)
|
|
|
|
; RV32IFD-NEXT: lw a0, 0(sp)
|
|
|
|
; RV32IFD-NEXT: lw a1, 4(sp)
|
|
|
|
; RV32IFD-NEXT: lw s2, 20(sp)
|
|
|
|
; RV32IFD-NEXT: lw s1, 24(sp)
|
|
|
|
; RV32IFD-NEXT: lw ra, 28(sp)
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, 32
|
|
|
|
; RV32IFD-NEXT: ret
|
|
|
|
%1 = alloca double, align 8
|
|
|
|
%2 = bitcast double* %1 to i8*
|
|
|
|
call void @notdead(i8* %2)
|
|
|
|
%3 = load double, double* %1
|
|
|
|
%4 = fadd double %3, %a ; force load in to FPR64
|
|
|
|
ret double %4
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @fsd_stack(double %a, double %b) nounwind {
|
|
|
|
; RV32IFD-LABEL: fsd_stack:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -32
|
|
|
|
; RV32IFD-NEXT: sw ra, 28(sp)
|
|
|
|
; RV32IFD-NEXT: sw a2, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a3, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a1, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft1, 8(sp)
|
|
|
|
; RV32IFD-NEXT: fadd.d ft0, ft1, ft0
|
|
|
|
; RV32IFD-NEXT: fsd ft0, 16(sp)
|
|
|
|
; RV32IFD-NEXT: addi a0, sp, 16
|
2018-04-25 22:19:12 +08:00
|
|
|
; RV32IFD-NEXT: call notdead
|
2018-04-12 13:36:44 +08:00
|
|
|
; RV32IFD-NEXT: lw ra, 28(sp)
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, 32
|
|
|
|
; RV32IFD-NEXT: ret
|
|
|
|
%1 = fadd double %a, %b ; force store from FPR64
|
|
|
|
%2 = alloca double, align 8
|
|
|
|
store double %1, double* %2
|
|
|
|
%3 = bitcast double* %2 to i8*
|
|
|
|
call void @notdead(i8* %3)
|
|
|
|
ret void
|
|
|
|
}
|
2018-04-12 13:47:15 +08:00
|
|
|
|
|
|
|
; Test selection of store<ST4[%a], trunc to f32>, ..
|
|
|
|
define void @fsd_trunc(float* %a, double %b) nounwind noinline optnone {
|
|
|
|
; RV32IFD-LABEL: fsd_trunc:
|
|
|
|
; RV32IFD: # %bb.0:
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, -16
|
|
|
|
; RV32IFD-NEXT: sw a1, 8(sp)
|
|
|
|
; RV32IFD-NEXT: sw a2, 12(sp)
|
|
|
|
; RV32IFD-NEXT: fld ft0, 8(sp)
|
|
|
|
; RV32IFD-NEXT: fcvt.s.d ft0, ft0
|
|
|
|
; RV32IFD-NEXT: fsw ft0, 0(a0)
|
|
|
|
; RV32IFD-NEXT: addi sp, sp, 16
|
|
|
|
; RV32IFD-NEXT: ret
|
|
|
|
%1 = fptrunc double %b to float
|
|
|
|
store float %1, float* %a, align 4
|
|
|
|
ret void
|
|
|
|
}
|