2017-12-11 20:49:02 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
|
|
|
|
; RUN: | FileCheck -check-prefix=RV32I %s
|
|
|
|
|
|
|
|
@x = local_unnamed_addr global fp128 0xL00000000000000007FFF000000000000, align 16
|
|
|
|
@y = local_unnamed_addr global fp128 0xL00000000000000007FFF000000000000, align 16
|
|
|
|
|
|
|
|
; Besides anything else, these tests help verify that libcall ABI lowering
|
|
|
|
; works correctly
|
|
|
|
|
|
|
|
define i32 @test_load_and_cmp() nounwind {
|
|
|
|
; RV32I-LABEL: test_load_and_cmp:
|
|
|
|
; RV32I: # %bb.0:
|
|
|
|
; RV32I-NEXT: addi sp, sp, -48
|
|
|
|
; RV32I-NEXT: sw ra, 44(sp)
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lui a0, %hi(y)
|
|
|
|
; RV32I-NEXT: lw a1, %lo(y)(a0)
|
|
|
|
; RV32I-NEXT: sw a1, 8(sp)
|
|
|
|
; RV32I-NEXT: lui a1, %hi(x)
|
|
|
|
; RV32I-NEXT: lw a2, %lo(x)(a1)
|
|
|
|
; RV32I-NEXT: sw a2, 24(sp)
|
|
|
|
; RV32I-NEXT: addi a0, a0, %lo(y)
|
|
|
|
; RV32I-NEXT: lw a2, 12(a0)
|
|
|
|
; RV32I-NEXT: sw a2, 20(sp)
|
|
|
|
; RV32I-NEXT: lw a2, 8(a0)
|
|
|
|
; RV32I-NEXT: sw a2, 16(sp)
|
|
|
|
; RV32I-NEXT: lw a0, 4(a0)
|
|
|
|
; RV32I-NEXT: sw a0, 12(sp)
|
|
|
|
; RV32I-NEXT: addi a0, a1, %lo(x)
|
|
|
|
; RV32I-NEXT: lw a1, 12(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
|
|
|
; RV32I-NEXT: sw a1, 36(sp)
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lw a1, 8(a0)
|
|
|
|
; RV32I-NEXT: sw a1, 32(sp)
|
|
|
|
; RV32I-NEXT: lw a0, 4(a0)
|
|
|
|
; RV32I-NEXT: sw a0, 28(sp)
|
2018-01-18 19:34:02 +08:00
|
|
|
; RV32I-NEXT: addi a0, sp, 24
|
|
|
|
; RV32I-NEXT: addi a1, sp, 8
|
2018-04-25 22:19:12 +08:00
|
|
|
; RV32I-NEXT: call __netf2
|
2017-12-15 17:47:01 +08:00
|
|
|
; RV32I-NEXT: snez a0, a0
|
2017-12-11 20:49:02 +08:00
|
|
|
; RV32I-NEXT: lw ra, 44(sp)
|
|
|
|
; RV32I-NEXT: addi sp, sp, 48
|
2017-12-15 17:47:01 +08:00
|
|
|
; RV32I-NEXT: ret
|
2017-12-11 20:49:02 +08:00
|
|
|
%1 = load fp128, fp128* @x, align 16
|
|
|
|
%2 = load fp128, fp128* @y, align 16
|
|
|
|
%cmp = fcmp une fp128 %1, %2
|
|
|
|
%3 = zext i1 %cmp to i32
|
|
|
|
ret i32 %3
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test_add_and_fptosi() nounwind {
|
|
|
|
; RV32I-LABEL: test_add_and_fptosi:
|
|
|
|
; RV32I: # %bb.0:
|
|
|
|
; RV32I-NEXT: addi sp, sp, -80
|
|
|
|
; RV32I-NEXT: sw ra, 76(sp)
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lui a0, %hi(y)
|
|
|
|
; RV32I-NEXT: lw a1, %lo(y)(a0)
|
|
|
|
; RV32I-NEXT: sw a1, 24(sp)
|
|
|
|
; RV32I-NEXT: lui a1, %hi(x)
|
|
|
|
; RV32I-NEXT: lw a2, %lo(x)(a1)
|
|
|
|
; RV32I-NEXT: sw a2, 40(sp)
|
|
|
|
; RV32I-NEXT: addi a0, a0, %lo(y)
|
|
|
|
; RV32I-NEXT: lw a2, 12(a0)
|
|
|
|
; RV32I-NEXT: sw a2, 36(sp)
|
|
|
|
; RV32I-NEXT: lw a2, 8(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
|
|
|
; RV32I-NEXT: sw a2, 32(sp)
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lw a0, 4(a0)
|
|
|
|
; RV32I-NEXT: sw a0, 28(sp)
|
|
|
|
; RV32I-NEXT: addi a0, a1, %lo(x)
|
|
|
|
; RV32I-NEXT: lw a1, 12(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
|
|
|
; RV32I-NEXT: sw a1, 52(sp)
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lw a1, 8(a0)
|
|
|
|
; RV32I-NEXT: sw a1, 48(sp)
|
|
|
|
; RV32I-NEXT: lw a0, 4(a0)
|
|
|
|
; RV32I-NEXT: sw a0, 44(sp)
|
2018-01-18 19:34:02 +08:00
|
|
|
; RV32I-NEXT: addi a0, sp, 56
|
|
|
|
; RV32I-NEXT: addi a1, sp, 40
|
|
|
|
; RV32I-NEXT: addi a2, sp, 24
|
2018-04-25 22:19:12 +08:00
|
|
|
; RV32I-NEXT: call __addtf3
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lw a0, 68(sp)
|
|
|
|
; RV32I-NEXT: sw a0, 20(sp)
|
|
|
|
; RV32I-NEXT: lw a0, 64(sp)
|
|
|
|
; RV32I-NEXT: sw a0, 16(sp)
|
2018-01-18 19:34:02 +08:00
|
|
|
; RV32I-NEXT: lw a0, 60(sp)
|
|
|
|
; RV32I-NEXT: sw a0, 12(sp)
|
2019-09-17 18:52:09 +08:00
|
|
|
; RV32I-NEXT: lw a0, 56(sp)
|
|
|
|
; RV32I-NEXT: sw a0, 8(sp)
|
2018-01-18 19:34:02 +08:00
|
|
|
; RV32I-NEXT: addi a0, sp, 8
|
2018-04-25 22:19:12 +08:00
|
|
|
; RV32I-NEXT: call __fixtfsi
|
2017-12-11 20:49:02 +08:00
|
|
|
; RV32I-NEXT: lw ra, 76(sp)
|
|
|
|
; RV32I-NEXT: addi sp, sp, 80
|
2017-12-15 17:47:01 +08:00
|
|
|
; RV32I-NEXT: ret
|
2017-12-11 20:49:02 +08:00
|
|
|
%1 = load fp128, fp128* @x, align 16
|
|
|
|
%2 = load fp128, fp128* @y, align 16
|
|
|
|
%3 = fadd fp128 %1, %2
|
|
|
|
%4 = fptosi fp128 %3 to i32
|
|
|
|
ret i32 %4
|
|
|
|
}
|