AArch64: make inexact signalling on round Darwin-specific

C11 leaves the choice on whether round-to-integer operations set the inexact
flag implementation-defined. Darwin does expect it to be set, but this seems to
be against the intent of the IEEE document and slower to implement anyway. So
it should be opt-in.

llvm-svn: 242446
This commit is contained in:
Tim Northover 2015-07-16 21:30:21 +00:00
parent 9e694e590c
commit ca0ffc3561
3 changed files with 147 additions and 76 deletions

View File

@ -2062,7 +2062,7 @@ SDNode *AArch64DAGToDAGISel::SelectLIBM(SDNode *N) {
SmallVector<SDValue, 2> Ops;
Ops.push_back(In);
if (!TM.Options.UnsafeFPMath) {
if (Subtarget->isTargetDarwin() && !TM.Options.UnsafeFPMath) {
SDNode *FRINTX = CurDAG->getMachineNode(FRINTXOpc, dl, VT, MVT::Glue, In);
Ops.push_back(SDValue(FRINTX, 1));
}

View File

@ -1,10 +1,13 @@
; RUN: llc -O3 < %s -mcpu=cyclone | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32:64"
target triple = "arm64-apple-ios6.0.0"
; RUN: llc -O3 < %s -mtriple=arm64-apple-ios7.0 | FileCheck %s --check-prefix=CHECK-INEXACT
; RUN: llc -O3 < %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefix=CHECK-FAST
; CHECK: test1
; CHECK: frintx
; CHECK: frintm
; CHECK-INEXACT-LABEL: test1:
; CHECK-INEXACT-DAG: frintm
; CHECK-INEXACT-DAG: frintx
; CHECK-FAST-LABEL: test1:
; CHECK-FAST: frintm
; CHECK-FAST-NOT: frintx
define float @test1(float %a) #0 {
entry:
%call = tail call float @floorf(float %a) nounwind readnone
@ -13,9 +16,13 @@ entry:
declare float @floorf(float) nounwind readnone
; CHECK: test2
; CHECK: frintx
; CHECK: frintm
; CHECK-INEXACT-LABEL: test2:
; CHECK-INEXACT: frintm
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test2:
; CHECK-FAST: frintm
; CHECK-FAST-NOT: frintx
define double @test2(double %a) #0 {
entry:
%call = tail call double @floor(double %a) nounwind readnone
@ -24,8 +31,11 @@ entry:
declare double @floor(double) nounwind readnone
; CHECK: test3
; CHECK: frinti
; CHECK-INEXACT-LABEL: test3:
; CHECK-INEXACT: frinti
; CHECK-FAST-LABEL: test3:
; CHECK-FAST: frinti
define float @test3(float %a) #0 {
entry:
%call = tail call float @nearbyintf(float %a) nounwind readnone
@ -34,8 +44,11 @@ entry:
declare float @nearbyintf(float) nounwind readnone
; CHECK: test4
; CHECK: frinti
; CHECK-INEXACT-LABEL: test4:
; CHECK-INEXACT: frinti
; CHECK-FAST-LABEL: test4:
; CHECK-FAST: frinti
define double @test4(double %a) #0 {
entry:
%call = tail call double @nearbyint(double %a) nounwind readnone
@ -44,9 +57,13 @@ entry:
declare double @nearbyint(double) nounwind readnone
; CHECK: test5
; CHECK: frintx
; CHECK: frintp
; CHECK-INEXACT-LABEL: test5:
; CHECK-INEXACT: frintp
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test5:
; CHECK-FAST: frintp
; CHECK-FAST-NOT: frintx
define float @test5(float %a) #0 {
entry:
%call = tail call float @ceilf(float %a) nounwind readnone
@ -55,9 +72,13 @@ entry:
declare float @ceilf(float) nounwind readnone
; CHECK: test6
; CHECK: frintx
; CHECK: frintp
; CHECK-INEXACT-LABEL: test6:
; CHECK-INEXACT: frintp
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test6:
; CHECK-FAST: frintp
; CHECK-FAST-NOT: frintx
define double @test6(double %a) #0 {
entry:
%call = tail call double @ceil(double %a) nounwind readnone
@ -66,8 +87,11 @@ entry:
declare double @ceil(double) nounwind readnone
; CHECK: test7
; CHECK: frintx
; CHECK-INEXACT-LABEL: test7:
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test7:
; CHECK-FAST: frintx
define float @test7(float %a) #0 {
entry:
%call = tail call float @rintf(float %a) nounwind readnone
@ -76,8 +100,11 @@ entry:
declare float @rintf(float) nounwind readnone
; CHECK: test8
; CHECK: frintx
; CHECK-INEXACT-LABEL: test8:
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test8:
; CHECK-FAST: frintx
define double @test8(double %a) #0 {
entry:
%call = tail call double @rint(double %a) nounwind readnone
@ -86,9 +113,13 @@ entry:
declare double @rint(double) nounwind readnone
; CHECK: test9
; CHECK: frintx
; CHECK: frintz
; CHECK-INEXACT-LABEL: test9:
; CHECK-INEXACT: frintz
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test9:
; CHECK-FAST: frintz
; CHECK-FAST-NOT: frintx
define float @test9(float %a) #0 {
entry:
%call = tail call float @truncf(float %a) nounwind readnone
@ -97,9 +128,13 @@ entry:
declare float @truncf(float) nounwind readnone
; CHECK: test10
; CHECK: frintx
; CHECK: frintz
; CHECK-INEXACT-LABEL: test10:
; CHECK-INEXACT: frintz
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test10:
; CHECK-FAST: frintz
; CHECK-FAST-NOT: frintx
define double @test10(double %a) #0 {
entry:
%call = tail call double @trunc(double %a) nounwind readnone
@ -108,9 +143,13 @@ entry:
declare double @trunc(double) nounwind readnone
; CHECK: test11
; CHECK: frintx
; CHECK: frinta
; CHECK-INEXACT-LABEL: test11:
; CHECK-INEXACT: frinta
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test11:
; CHECK-FAST: frinta
; CHECK-FAST-NOT: frintx
define float @test11(float %a) #0 {
entry:
%call = tail call float @roundf(float %a) nounwind readnone
@ -119,9 +158,13 @@ entry:
declare float @roundf(float %a) nounwind readnone
; CHECK: test12
; CHECK: frintx
; CHECK: frinta
; CHECK-INEXACT-LABEL: test12:
; CHECK-INEXACT: frinta
; CHECK-INEXACT: frintx
; CHECK-FAST-LABEL: test12:
; CHECK-FAST: frinta
; CHECK-FAST-NOT: frintx
define double @test12(double %a) #0 {
entry:
%call = tail call double @round(double %a) nounwind readnone
@ -130,72 +173,104 @@ entry:
declare double @round(double %a) nounwind readnone
; CHECK: test13
; CHECK-NOT: frintx
; CHECK: frintm
; CHECK-INEXACT-LABEL: test13:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frintm
; CHECK-FAST-LABEL: test13:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frintm
define float @test13(float %a) #1 {
entry:
%call = tail call float @floorf(float %a) nounwind readnone
ret float %call
}
; CHECK: test14
; CHECK-NOT: frintx
; CHECK: frintm
; CHECK-INEXACT-LABEL: test14:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frintm
; CHECK-FAST-LABEL: test14:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frintm
define double @test14(double %a) #1 {
entry:
%call = tail call double @floor(double %a) nounwind readnone
ret double %call
}
; CHECK: test15
; CHECK-NOT: frintx
; CHECK: frintp
; CHECK-INEXACT-LABEL: test15:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frintp
; CHECK-FAST-LABEL: test15:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frintp
define float @test15(float %a) #1 {
entry:
%call = tail call float @ceilf(float %a) nounwind readnone
ret float %call
}
; CHECK: test16
; CHECK-NOT: frintx
; CHECK: frintp
; CHECK-INEXACT-LABEL: test16:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frintp
; CHECK-FAST-LABEL: test16:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frintp
define double @test16(double %a) #1 {
entry:
%call = tail call double @ceil(double %a) nounwind readnone
ret double %call
}
; CHECK: test17
; CHECK-NOT: frintx
; CHECK: frintz
; CHECK-INEXACT-LABEL: test17:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frintz
; CHECK-FAST-LABEL: test17:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frintz
define float @test17(float %a) #1 {
entry:
%call = tail call float @truncf(float %a) nounwind readnone
ret float %call
}
; CHECK: test18
; CHECK-NOT: frintx
; CHECK: frintz
; CHECK-INEXACT-LABEL: test18:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frintz
; CHECK-FAST-LABEL: test18:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frintz
define double @test18(double %a) #1 {
entry:
%call = tail call double @trunc(double %a) nounwind readnone
ret double %call
}
; CHECK: test19
; CHECK-NOT: frintx
; CHECK: frinta
; CHECK-INEXACT-LABEL: test19:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frinta
; CHECK-FAST-LABEL: test19:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frinta
define float @test19(float %a) #1 {
entry:
%call = tail call float @roundf(float %a) nounwind readnone
ret float %call
}
; CHECK: test20
; CHECK-NOT: frintx
; CHECK: frinta
; CHECK-INEXACT-LABEL: test20:
; CHECK-INEXACT-NOT: frintx
; CHECK-INEXACT: frinta
; CHECK-FAST-LABEL: test20:
; CHECK-FAST-NOT: frintx
; CHECK-FAST: frinta
define double @test20(double %a) #1 {
entry:
%call = tail call double @round(double %a) nounwind readnone

View File

@ -684,10 +684,9 @@ define half @test_copysign(half %a, half %b) #0 {
}
; CHECK-LABEL: test_floor:
; CHECK-NEXT: fcvt s1, h0
; CHECK-NEXT: frintm s0, s1
; CHECK-NEXT: fcvt h0, s0
; CHECK-NEXT: frintx s1, s1
; CHECK-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
; CHECK-NEXT: frintm [[INT32:s[0-9]+]], [[FLOAT32]]
; CHECK-NEXT: fcvt h0, [[INT32]]
; CHECK-NEXT: ret
define half @test_floor(half %a) #0 {
%r = call half @llvm.floor.f16(half %a)
@ -695,10 +694,9 @@ define half @test_floor(half %a) #0 {
}
; CHECK-LABEL: test_ceil:
; CHECK-NEXT: fcvt s1, h0
; CHECK-NEXT: frintp s0, s1
; CHECK-NEXT: fcvt h0, s0
; CHECK-NEXT: frintx s1, s1
; CHECK-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
; CHECK-NEXT: frintp [[INT32:s[0-9]+]], [[FLOAT32]]
; CHECK-NEXT: fcvt h0, [[INT32]]
; CHECK-NEXT: ret
define half @test_ceil(half %a) #0 {
%r = call half @llvm.ceil.f16(half %a)
@ -706,10 +704,9 @@ define half @test_ceil(half %a) #0 {
}
; CHECK-LABEL: test_trunc:
; CHECK-NEXT: fcvt s1, h0
; CHECK-NEXT: frintz s0, s1
; CHECK-NEXT: fcvt h0, s0
; CHECK-NEXT: frintx s1, s1
; CHECK-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
; CHECK-NEXT: frintz [[INT32:s[0-9]+]], [[FLOAT32]]
; CHECK-NEXT: fcvt h0, [[INT32]]
; CHECK-NEXT: ret
define half @test_trunc(half %a) #0 {
%r = call half @llvm.trunc.f16(half %a)
@ -737,10 +734,9 @@ define half @test_nearbyint(half %a) #0 {
}
; CHECK-LABEL: test_round:
; CHECK-NEXT: fcvt s1, h0
; CHECK-NEXT: frinta s0, s1
; CHECK-NEXT: fcvt h0, s0
; CHECK-NEXT: frintx s1, s1
; CHECK-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
; CHECK-NEXT: frinta [[INT32:s[0-9]+]], [[FLOAT32]]
; CHECK-NEXT: fcvt h0, [[INT32]]
; CHECK-NEXT: ret
define half @test_round(half %a) #0 {
%r = call half @llvm.round.f16(half %a)