2016-04-26 06:54:09 +08:00
|
|
|
; RUN: llc < %s -march=sparc -mattr=hard-quad-float | FileCheck %s --check-prefix=CHECK --check-prefix=HARD --check-prefix=BE
|
|
|
|
; RUN: llc < %s -march=sparcel -mattr=hard-quad-float | FileCheck %s --check-prefix=CHECK --check-prefix=HARD --check-prefix=EL
|
2019-12-03 18:19:16 +08:00
|
|
|
; RUN: llc < %s -march=sparc -mattr=-hard-quad-float -verify-machineinstrs | FileCheck %s --check-prefix=CHECK --check-prefix=SOFT --check-prefix=BE
|
2016-04-26 06:54:09 +08:00
|
|
|
; RUN: llc < %s -march=sparcel -mattr=-hard-quad-float | FileCheck %s --check-prefix=CHECK --check-prefix=SOFT --check-prefix=EL
|
2013-09-03 12:11:59 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_ops:
|
|
|
|
; CHECK: ldd
|
|
|
|
; CHECK: ldd
|
|
|
|
; CHECK: ldd
|
|
|
|
; CHECK: ldd
|
2013-09-03 12:11:59 +08:00
|
|
|
; HARD: faddq [[R0:.+]], [[R1:.+]], [[R2:.+]]
|
|
|
|
; HARD: fsubq [[R2]], [[R3:.+]], [[R4:.+]]
|
|
|
|
; HARD: fmulq [[R4]], [[R5:.+]], [[R6:.+]]
|
|
|
|
; HARD: fdivq [[R6]], [[R2]]
|
|
|
|
; SOFT: call _Q_add
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2013-09-03 12:11:59 +08:00
|
|
|
; SOFT: call _Q_sub
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2013-09-03 12:11:59 +08:00
|
|
|
; SOFT: call _Q_mul
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2013-09-03 12:11:59 +08:00
|
|
|
; SOFT: call _Q_div
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK: std
|
|
|
|
; CHECK: std
|
2013-08-26 02:30:06 +08:00
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @f128_ops(fp128* noalias sret(fp128) %scalar.result, fp128* byval(fp128) %a, fp128* byval(fp128) %b, fp128* byval(fp128) %c, fp128* byval(fp128) %d) {
|
2013-08-26 02:30:06 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %a, align 8
|
|
|
|
%1 = load fp128, fp128* %b, align 8
|
|
|
|
%2 = load fp128, fp128* %c, align 8
|
|
|
|
%3 = load fp128, fp128* %d, align 8
|
2013-08-26 02:30:06 +08:00
|
|
|
%4 = fadd fp128 %0, %1
|
|
|
|
%5 = fsub fp128 %4, %2
|
|
|
|
%6 = fmul fp128 %5, %3
|
|
|
|
%7 = fdiv fp128 %6, %4
|
|
|
|
store fp128 %7, fp128* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|
2013-09-03 02:32:45 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_spill:
|
|
|
|
; CHECK: std %f{{.+}}, [%[[S0:.+]]]
|
|
|
|
; CHECK: std %f{{.+}}, [%[[S1:.+]]]
|
|
|
|
; CHECK-DAG: ldd [%[[S0]]], %f{{.+}}
|
|
|
|
; CHECK-DAG: ldd [%[[S1]]], %f{{.+}}
|
|
|
|
; CHECK: jmp {{%[oi]7}}+12
|
2013-09-03 02:32:45 +08:00
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @f128_spill(fp128* noalias sret(fp128) %scalar.result, fp128* byval(fp128) %a) {
|
2013-09-03 02:32:45 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %a, align 8
|
2013-09-03 02:32:45 +08:00
|
|
|
call void asm sideeffect "", "~{f0},~{f1},~{f2},~{f3},~{f4},~{f5},~{f6},~{f7},~{f8},~{f9},~{f10},~{f11},~{f12},~{f13},~{f14},~{f15},~{f16},~{f17},~{f18},~{f19},~{f20},~{f21},~{f22},~{f23},~{f24},~{f25},~{f26},~{f27},~{f28},~{f29},~{f30},~{f31}"()
|
|
|
|
store fp128 %0, fp128* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|
2013-09-03 12:11:59 +08:00
|
|
|
|
[Sparc] Fix incorrect MI insertion position for spilling f128.
Summary:
Obviously, new built MI (sethi+add or sethi+xor+add) for constructing large offset
should be inserted before new created MI for storing even register into memory.
So the insertion position should be *StMI instead of II.
before fixed:
std %f0, [%g1+80]
sethi 4, %g1 <<<
add %g1, %sp, %g1 <<< this two instructions should be put before "std %f0, [%g1+80]".
sethi 4, %g1
add %g1, %sp, %g1
std %f2, [%g1+88]
after fixed:
sethi 4, %g1
add %g1, %sp, %g1
std %f0, [%g1+80]
sethi 4, %g1
add %g1, %sp, %g1
std %f2, [%g1+88]
Reviewers: venkatra, jyknight
Reviewed By: jyknight
Subscribers: jyknight, fedor.sergeev, jrtc27, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60397
llvm-svn: 358042
2019-04-10 09:56:32 +08:00
|
|
|
; CHECK-LABEL: f128_spill_large:
|
|
|
|
; CHECK: sethi 4, %g1
|
|
|
|
; CHECK: sethi 4, %g1
|
|
|
|
; CHECK-NEXT: add %g1, %sp, %g1
|
|
|
|
; CHECK-NEXT: std %f{{.+}}, [%g1]
|
|
|
|
; CHECK: sethi 4, %g1
|
|
|
|
; CHECK-NEXT: add %g1, %sp, %g1
|
|
|
|
; CHECK-NEXT: std %f{{.+}}, [%g1+8]
|
|
|
|
; CHECK: sethi 4, %g1
|
|
|
|
; CHECK-NEXT: add %g1, %sp, %g1
|
|
|
|
; CHECK-NEXT: ldd [%g1], %f{{.+}}
|
|
|
|
; CHECK: sethi 4, %g1
|
|
|
|
; CHECK-NEXT: add %g1, %sp, %g1
|
|
|
|
; CHECK-NEXT: ldd [%g1+8], %f{{.+}}
|
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @f128_spill_large(<251 x fp128>* noalias sret(<251 x fp128>) %scalar.result, <251 x fp128>* byval(<251 x fp128>) %a) {
|
[Sparc] Fix incorrect MI insertion position for spilling f128.
Summary:
Obviously, new built MI (sethi+add or sethi+xor+add) for constructing large offset
should be inserted before new created MI for storing even register into memory.
So the insertion position should be *StMI instead of II.
before fixed:
std %f0, [%g1+80]
sethi 4, %g1 <<<
add %g1, %sp, %g1 <<< this two instructions should be put before "std %f0, [%g1+80]".
sethi 4, %g1
add %g1, %sp, %g1
std %f2, [%g1+88]
after fixed:
sethi 4, %g1
add %g1, %sp, %g1
std %f0, [%g1+80]
sethi 4, %g1
add %g1, %sp, %g1
std %f2, [%g1+88]
Reviewers: venkatra, jyknight
Reviewed By: jyknight
Subscribers: jyknight, fedor.sergeev, jrtc27, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60397
llvm-svn: 358042
2019-04-10 09:56:32 +08:00
|
|
|
entry:
|
|
|
|
%0 = load <251 x fp128>, <251 x fp128>* %a, align 8
|
|
|
|
call void asm sideeffect "", "~{f0},~{f1},~{f2},~{f3},~{f4},~{f5},~{f6},~{f7},~{f8},~{f9},~{f10},~{f11},~{f12},~{f13},~{f14},~{f15},~{f16},~{f17},~{f18},~{f19},~{f20},~{f21},~{f22},~{f23},~{f24},~{f25},~{f26},~{f27},~{f28},~{f29},~{f30},~{f31}"()
|
|
|
|
store <251 x fp128> %0, <251 x fp128>* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_compare:
|
2013-09-03 12:11:59 +08:00
|
|
|
; HARD: fcmpq
|
2013-10-06 15:06:44 +08:00
|
|
|
; HARD-NEXT: nop
|
2013-09-03 12:11:59 +08:00
|
|
|
; SOFT: _Q_cmp
|
|
|
|
|
2020-11-20 23:52:27 +08:00
|
|
|
define i32 @f128_compare(fp128* byval(fp128) %f0, fp128* byval(fp128) %f1, i32 %a, i32 %b) {
|
2013-09-03 12:11:59 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %f0, align 8
|
|
|
|
%1 = load fp128, fp128* %f1, align 8
|
2013-09-03 12:11:59 +08:00
|
|
|
%cond = fcmp ult fp128 %0, %1
|
|
|
|
%ret = select i1 %cond, i32 %a, i32 %b
|
|
|
|
ret i32 %ret
|
|
|
|
}
|
2013-09-04 23:15:20 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_compare2:
|
|
|
|
; HARD: fcmpq
|
|
|
|
; HARD: fb{{ule|g}}
|
2013-09-04 23:15:20 +08:00
|
|
|
; SOFT: _Q_cmp
|
|
|
|
; SOFT: cmp
|
|
|
|
|
2020-11-20 23:52:27 +08:00
|
|
|
define i32 @f128_compare2(fp128* byval(fp128) %f0) {
|
2013-09-04 23:15:20 +08:00
|
|
|
entry:
|
2019-04-05 22:56:21 +08:00
|
|
|
%0 = load fp128, fp128* %f0, align 8
|
|
|
|
%1 = fcmp ogt fp128 %0, 0xL00000000000000000000000000000000
|
|
|
|
br i1 %1, label %"5", label %"7"
|
2013-09-04 23:15:20 +08:00
|
|
|
|
|
|
|
"5": ; preds = %entry
|
|
|
|
ret i32 0
|
|
|
|
|
|
|
|
"7": ; preds = %entry
|
|
|
|
ret i32 1
|
|
|
|
}
|
2013-09-22 07:51:08 +08:00
|
|
|
|
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_abs:
|
|
|
|
; CHECK: ldd [%o0], %f0
|
|
|
|
; CHECK: ldd [%o0+8], %f2
|
|
|
|
; BE: fabss %f0, %f0
|
|
|
|
; EL: fabss %f3, %f3
|
2013-09-22 07:51:08 +08:00
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @f128_abs(fp128* noalias sret(fp128) %scalar.result, fp128* byval(fp128) %a) {
|
2013-09-22 07:51:08 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %a, align 8
|
2013-09-22 07:51:08 +08:00
|
|
|
%1 = tail call fp128 @llvm.fabs.f128(fp128 %0)
|
|
|
|
store fp128 %1, fp128* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare fp128 @llvm.fabs.f128(fp128) nounwind readonly
|
2013-10-05 08:31:41 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: int_to_f128:
|
2013-10-05 08:31:41 +08:00
|
|
|
; HARD: fitoq
|
|
|
|
; SOFT: _Q_itoq
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2013-10-05 08:31:41 +08:00
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @int_to_f128(fp128* noalias sret(fp128) %scalar.result, i32 %i) {
|
2013-10-05 08:31:41 +08:00
|
|
|
entry:
|
|
|
|
%0 = sitofp i32 %i to fp128
|
|
|
|
store fp128 %0, fp128* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|
2013-10-05 10:29:47 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: fp128_unaligned:
|
|
|
|
; CHECK: ldub
|
|
|
|
; HARD: faddq
|
2013-10-05 10:29:47 +08:00
|
|
|
; SOFT: call _Q_add
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK: stb
|
|
|
|
; CHECK: ret
|
2013-10-05 10:29:47 +08:00
|
|
|
|
|
|
|
define void @fp128_unaligned(fp128* %a, fp128* %b, fp128* %c) {
|
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %a, align 1
|
|
|
|
%1 = load fp128, fp128* %b, align 1
|
2013-10-05 10:29:47 +08:00
|
|
|
%2 = fadd fp128 %0, %1
|
|
|
|
store fp128 %2, fp128* %c, align 1
|
|
|
|
ret void
|
|
|
|
}
|
2013-11-03 16:00:19 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: uint_to_f128:
|
2013-11-03 16:00:19 +08:00
|
|
|
; HARD: fdtoq
|
|
|
|
; SOFT: _Q_utoq
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT: unimp 16
|
2013-11-03 16:00:19 +08:00
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @uint_to_f128(fp128* noalias sret(fp128) %scalar.result, i32 %i) {
|
2013-11-03 16:00:19 +08:00
|
|
|
entry:
|
|
|
|
%0 = uitofp i32 %i to fp128
|
|
|
|
store fp128 %0, fp128* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_to_i32:
|
2013-11-03 16:00:19 +08:00
|
|
|
; HARD: fqtoi
|
|
|
|
; HARD: fqtoi
|
|
|
|
; SOFT: call _Q_qtou
|
|
|
|
; SOFT: call _Q_qtoi
|
|
|
|
|
|
|
|
|
|
|
|
define i32 @f128_to_i32(fp128* %a, fp128* %b) {
|
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %a, align 8
|
|
|
|
%1 = load fp128, fp128* %b, align 8
|
2013-11-03 16:00:19 +08:00
|
|
|
%2 = fptoui fp128 %0 to i32
|
|
|
|
%3 = fptosi fp128 %1 to i32
|
|
|
|
%4 = add i32 %2, %3
|
|
|
|
ret i32 %4
|
|
|
|
}
|
2013-11-03 20:28:40 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: test_itoq_qtoi
|
2015-02-17 05:47:58 +08:00
|
|
|
; HARD-DAG: call _Q_lltoq
|
|
|
|
; HARD-DAG: call _Q_qtoll
|
|
|
|
; HARD-DAG: fitoq
|
|
|
|
; HARD-DAG: fqtoi
|
|
|
|
; SOFT-DAG: call _Q_lltoq
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT-DAG: unimp 16
|
2015-02-17 05:47:58 +08:00
|
|
|
; SOFT-DAG: call _Q_qtoll
|
|
|
|
; SOFT-DAG: call _Q_itoq
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT-DAG: unimp 16
|
2015-02-17 05:47:58 +08:00
|
|
|
; SOFT-DAG: call _Q_qtoi
|
2013-11-03 20:28:40 +08:00
|
|
|
|
2015-02-17 05:47:58 +08:00
|
|
|
define void @test_itoq_qtoi(i64 %a, i32 %b, fp128* %c, fp128* %d, i64* %ptr0, fp128* %ptr1) {
|
2013-11-03 20:28:40 +08:00
|
|
|
entry:
|
|
|
|
%0 = sitofp i64 %a to fp128
|
|
|
|
store fp128 %0, fp128* %ptr1, align 8
|
2015-02-28 05:17:42 +08:00
|
|
|
%cval = load fp128, fp128* %c, align 8
|
2015-02-17 05:47:58 +08:00
|
|
|
%1 = fptosi fp128 %cval to i64
|
2013-11-03 20:28:40 +08:00
|
|
|
store i64 %1, i64* %ptr0, align 8
|
|
|
|
%2 = sitofp i32 %b to fp128
|
|
|
|
store fp128 %2, fp128* %ptr1, align 8
|
2015-02-28 05:17:42 +08:00
|
|
|
%dval = load fp128, fp128* %d, align 8
|
2015-02-17 05:47:58 +08:00
|
|
|
%3 = fptosi fp128 %dval to i32
|
2013-11-03 20:28:40 +08:00
|
|
|
%4 = bitcast i64* %ptr0 to i32*
|
|
|
|
store i32 %3, i32* %4, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: test_utoq_qtou:
|
|
|
|
; CHECK-DAG: call _Q_ulltoq
|
|
|
|
; CHECK-DAG: call _Q_qtoull
|
2013-11-03 20:28:40 +08:00
|
|
|
; HARD-DAG: fdtoq
|
|
|
|
; HARD-DAG: fqtoi
|
|
|
|
; SOFT-DAG: call _Q_utoq
|
2018-08-17 18:40:00 +08:00
|
|
|
; SOFT-DAG: unimp 16
|
2013-11-03 20:28:40 +08:00
|
|
|
; SOFT-DAG: call _Q_qtou
|
|
|
|
|
2015-02-17 05:47:58 +08:00
|
|
|
define void @test_utoq_qtou(i64 %a, i32 %b, fp128* %c, fp128* %d, i64* %ptr0, fp128* %ptr1) {
|
2013-11-03 20:28:40 +08:00
|
|
|
entry:
|
|
|
|
%0 = uitofp i64 %a to fp128
|
|
|
|
store fp128 %0, fp128* %ptr1, align 8
|
2015-02-28 05:17:42 +08:00
|
|
|
%cval = load fp128, fp128* %c, align 8
|
2015-02-17 05:47:58 +08:00
|
|
|
%1 = fptoui fp128 %cval to i64
|
2013-11-03 20:28:40 +08:00
|
|
|
store i64 %1, i64* %ptr0, align 8
|
|
|
|
%2 = uitofp i32 %b to fp128
|
|
|
|
store fp128 %2, fp128* %ptr1, align 8
|
2015-02-28 05:17:42 +08:00
|
|
|
%dval = load fp128, fp128* %d, align 8
|
2015-02-17 05:47:58 +08:00
|
|
|
%3 = fptoui fp128 %dval to i32
|
2013-11-03 20:28:40 +08:00
|
|
|
%4 = bitcast i64* %ptr0 to i32*
|
|
|
|
store i32 %3, i32* %4, align 8
|
|
|
|
ret void
|
|
|
|
}
|
2014-02-28 03:26:29 +08:00
|
|
|
|
2016-04-26 06:54:09 +08:00
|
|
|
; CHECK-LABEL: f128_neg:
|
|
|
|
; CHECK: ldd [%o0], %f0
|
|
|
|
; CHECK: ldd [%o0+8], %f2
|
|
|
|
; BE: fnegs %f0, %f0
|
|
|
|
; EL: fnegs %f3, %f3
|
2014-02-28 03:26:29 +08:00
|
|
|
|
2020-11-21 03:07:11 +08:00
|
|
|
define void @f128_neg(fp128* noalias sret(fp128) %scalar.result, fp128* byval(fp128) %a) {
|
2014-02-28 03:26:29 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load fp128, fp128* %a, align 8
|
2014-02-28 03:26:29 +08:00
|
|
|
%1 = fsub fp128 0xL00000000000000008000000000000000, %0
|
|
|
|
store fp128 %1, fp128* %scalar.result, align 8
|
|
|
|
ret void
|
|
|
|
}
|