From db1d817deeafd0b589003c3b87b2888c5ca9d14e Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Sun, 2 Aug 2015 15:04:29 +0300 Subject: [PATCH 1/2] Remove 'readnone' attribute away from non-readnone sincos() --- builtins/svml.m4 | 8 ++++---- builtins/target-generic-1.ll | 4 ++-- builtins/target-nvptx.ll | 8 ++++---- builtins/util-nvptx.m4 | 8 ++++---- builtins/util.m4 | 16 ++++++++-------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/builtins/svml.m4 b/builtins/svml.m4 index d8670915..5c95f0cb 100644 --- a/builtins/svml.m4 +++ b/builtins/svml.m4 @@ -40,7 +40,7 @@ define(`svml_stubs',` declare <$3 x $1> @__svml_sin$2(<$3 x $1>) nounwind readnone alwaysinline declare <$3 x $1> @__svml_asin$2(<$3 x $1>) nounwind readnone alwaysinline declare <$3 x $1> @__svml_cos$2(<$3 x $1>) nounwind readnone alwaysinline - declare void @__svml_sincos$2(<$3 x $1>, <$3 x $1> *, <$3 x $1> *) nounwind readnone alwaysinline + declare void @__svml_sincos$2(<$3 x $1>, <$3 x $1> *, <$3 x $1> *) nounwind alwaysinline declare <$3 x $1> @__svml_tan$2(<$3 x $1>) nounwind readnone alwaysinline declare <$3 x $1> @__svml_atan$2(<$3 x $1>) nounwind readnone alwaysinline declare <$3 x $1> @__svml_atan2$2(<$3 x $1>, <$3 x $1>) nounwind readnone alwaysinline @@ -90,7 +90,7 @@ define(`svml_define',` ret <$3 x $1> %ret } - define void @__svml_sincos$4(<$3 x $1>, <$3 x $1> *, <$3 x $1> *) nounwind readnone alwaysinline { + define void @__svml_sincos$4(<$3 x $1>, <$3 x $1> *, <$3 x $1> *) nounwind alwaysinline { %s = call <$3 x $1> @__svml_sincos$2(<$3 x $1> * %2, <$3 x $1> %0) store <$3 x $1> %s, <$3 x $1> * %1 ret void @@ -140,7 +140,7 @@ define(`svml_define',` ;; *todo*: in sincos call use __svml_sincos[f][2,4,8,16] call, e.g. ;;define void @__svml_sincosf(<8 x float>, <8 x float> *, -;; <8 x float> *) nounwind readnone alwaysinline { +;; <8 x float> *) nounwind alwaysinline { ;; ; call svml_sincosf4 two times with the two 4-wide sub-vectors ;; %a = shufflevector <8 x float> %0, <8 x float> undef, ;; <4 x i32> @@ -180,7 +180,7 @@ define(`svml_define_x',` unary$3to$5(ret, $1, @__svml_cos$2, %0) ret <$5 x $1> %ret } - define void @__svml_sincos$4(<$5 x $1>,<$5 x $1>*,<$5 x $1>*) nounwind readnone alwaysinline + define void @__svml_sincos$4(<$5 x $1>,<$5 x $1>*,<$5 x $1>*) nounwind alwaysinline { %s = call <$5 x $1> @__svml_sin$4(<$5 x $1> %0) %c = call <$5 x $1> @__svml_cos$4(<$5 x $1> %0) diff --git a/builtins/target-generic-1.ll b/builtins/target-generic-1.ll index b98154ee..8af53831 100644 --- a/builtins/target-generic-1.ll +++ b/builtins/target-generic-1.ll @@ -690,7 +690,7 @@ define <1 x float> @__rsqrt_varying_float(<1 x float> %v) nounwind readonly alw declare <1 x float> @__svml_sind(<1 x float>) nounwind readnone alwaysinline declare <1 x float> @__svml_asind(<1 x float>) nounwind readnone alwaysinline declare <1 x float> @__svml_cosd(<1 x float>) nounwind readnone alwaysinline -declare void @__svml_sincosd(<1 x float>, <1 x double> *, <1 x double> *) nounwind readnone alwaysinline +declare void @__svml_sincosd(<1 x float>, <1 x double> *, <1 x double> *) nounwind alwaysinline declare <1 x float> @__svml_tand(<1 x float>) nounwind readnone alwaysinline declare <1 x float> @__svml_atand(<1 x float>) nounwind readnone alwaysinline declare <1 x float> @__svml_atan2d(<1 x float>, <1 x float>) nounwind readnone alwaysinline @@ -731,7 +731,7 @@ define <1 x float> @__svml_cosf(<1 x float>) nounwind readnone alwaysinline { } -define void @__svml_sincosf(<1 x float>, <1 x float> *, <1 x float> *) nounwind readnone alwaysinline { +define void @__svml_sincosf(<1 x float>, <1 x float> *, <1 x float> *) nounwind alwaysinline { ; %s = call <1 x float> @__svml_sincosf4(<1 x float> * %2, <1 x float> %0) ; store <1 x float> %s, <1 x float> * %1 ; ret void diff --git a/builtins/target-nvptx.ll b/builtins/target-nvptx.ll index 14b39bd1..965310ef 100644 --- a/builtins/target-nvptx.ll +++ b/builtins/target-nvptx.ll @@ -2364,8 +2364,8 @@ transcendentals1(__nv_acos, double, __acos) transcendentals1(__nv_atan, double, __atan) transcendentals2(__nv_atan2, double, __atan2) -declare void @__sincos_uniform_float(float, float*, float*) nounwind readnone -declare void @__sincos_varying_float(, *, *) nounwind readnone -declare void @__sincos_uniform_double(double, double*, double*) nounwind readnone -declare void @__sincos_varying_double(, *, *) nounwind readnone +declare void @__sincos_uniform_float(float, float*, float*) nounwind +declare void @__sincos_varying_float(, *, *) nounwind +declare void @__sincos_uniform_double(double, double*, double*) nounwind +declare void @__sincos_varying_double(, *, *) nounwind diff --git a/builtins/util-nvptx.m4 b/builtins/util-nvptx.m4 index 86f42b20..6b61b850 100644 --- a/builtins/util-nvptx.m4 +++ b/builtins/util-nvptx.m4 @@ -2288,7 +2288,7 @@ m4exit(`1') declare float @sinf(float) nounwind readnone declare float @cosf(float) nounwind readnone -declare void @sincosf(float, float *, float *) nounwind readnone +declare void @sincosf(float, float *, float *) nounwind declare float @asinf(float) nounwind readnone declare float @acosf(float) nounwind readnone declare float @tanf(float) nounwind readnone @@ -2308,7 +2308,7 @@ define float @__stdlib_cosf(float) nounwind readnone alwaysinline { ret float %r } -define void @__stdlib_sincosf(float, float *, float *) nounwind readnone alwaysinline { +define void @__stdlib_sincosf(float, float *, float *) nounwind alwaysinline { call void @sincosf(float %0, float *%1, float *%2) ret void } @@ -2356,7 +2356,7 @@ define float @__stdlib_powf(float, float) nounwind readnone alwaysinline { declare double @sin(double) nounwind readnone declare double @asin(double) nounwind readnone declare double @cos(double) nounwind readnone -declare void @sincos(double, double *, double *) nounwind readnone +declare void @sincos(double, double *, double *) nounwind declare double @tan(double) nounwind readnone declare double @atan(double) nounwind readnone declare double @atan2(double, double) nounwind readnone @@ -2379,7 +2379,7 @@ define double @__stdlib_cos(double) nounwind readnone alwaysinline { ret double %r } -define void @__stdlib_sincos(double, double *, double *) nounwind readnone alwaysinline { +define void @__stdlib_sincos(double, double *, double *) nounwind alwaysinline { call void @sincos(double %0, double *%1, double *%2) ret void } diff --git a/builtins/util.m4 b/builtins/util.m4 index cf211abd..7c952ceb 100644 --- a/builtins/util.m4 +++ b/builtins/util.m4 @@ -3719,7 +3719,7 @@ define i64 @__clock() nounwind { declare float @sinf(float) nounwind readnone declare float @cosf(float) nounwind readnone -declare void @sincosf(float, float *, float *) nounwind readnone +declare void @sincosf(float, float *, float *) nounwind declare float @asinf(float) nounwind readnone declare float @acosf(float) nounwind readnone declare float @tanf(float) nounwind readnone @@ -3739,7 +3739,7 @@ define float @__stdlib_cosf(float) nounwind readnone alwaysinline { ret float %r } -define void @__stdlib_sincosf(float, float *, float *) nounwind readnone alwaysinline { +define void @__stdlib_sincosf(float, float *, float *) nounwind alwaysinline { call void @sincosf(float %0, float *%1, float *%2) ret void } @@ -3787,7 +3787,7 @@ define float @__stdlib_powf(float, float) nounwind readnone alwaysinline { declare double @sin(double) nounwind readnone declare double @asin(double) nounwind readnone declare double @cos(double) nounwind readnone -declare void @sincos(double, double *, double *) nounwind readnone +declare void @sincos(double, double *, double *) nounwind declare double @tan(double) nounwind readnone declare double @atan(double) nounwind readnone declare double @atan2(double, double) nounwind readnone @@ -3810,7 +3810,7 @@ define double @__stdlib_cos(double) nounwind readnone alwaysinline { ret double %r } -define void @__stdlib_sincos(double, double *, double *) nounwind readnone alwaysinline { +define void @__stdlib_sincos(double, double *, double *) nounwind alwaysinline { call void @sincos(double %0, double *%1, double *%2) ret void } @@ -5103,7 +5103,7 @@ define(`trigonometry_decl',` declare @__asin_varying_float() nounwind readnone declare @__cos_varying_float() nounwind readnone declare @__acos_varying_float() nounwind readnone - declare void @__sincos_varying_float(, *, *) nounwind readnone + declare void @__sincos_varying_float(, *, *) nounwind declare @__tan_varying_float() nounwind readnone declare @__atan_varying_float() nounwind readnone declare @__atan2_varying_float(,) nounwind readnone @@ -5112,7 +5112,7 @@ define(`trigonometry_decl',` declare float @__asin_uniform_float(float) nounwind readnone declare float @__cos_uniform_float(float) nounwind readnone declare float @__acos_uniform_float(float) nounwind readnone - declare void @__sincos_uniform_float(float, float*, float*) nounwind readnone + declare void @__sincos_uniform_float(float, float*, float*) nounwind declare float @__tan_uniform_float(float) nounwind readnone declare float @__atan_uniform_float(float) nounwind readnone declare float @__atan2_uniform_float(float,float) nounwind readnone @@ -5121,7 +5121,7 @@ define(`trigonometry_decl',` declare @__asin_varying_double() nounwind readnone declare @__cos_varying_double() nounwind readnone declare @__acos_varying_double() nounwind readnone - declare void @__sincos_varying_double(, *, *) nounwind readnone + declare void @__sincos_varying_double(, *, *) nounwind declare @__tan_varying_double() nounwind readnone declare @__atan_varying_double() nounwind readnone declare @__atan2_varying_double(,) nounwind readnone @@ -5130,7 +5130,7 @@ define(`trigonometry_decl',` declare double @__asin_uniform_double(double) nounwind readnone declare double @__cos_uniform_double(double) nounwind readnone declare double @__acos_uniform_double(double) nounwind readnone - declare void @__sincos_uniform_double(double, double*, double*) nounwind readnone + declare void @__sincos_uniform_double(double, double*, double*) nounwind declare double @__tan_uniform_double(double) nounwind readnone declare double @__atan_uniform_double(double) nounwind readnone declare double @__atan2_uniform_double(double,double) nounwind readnone From 9bfc3850c766bddc5c723aaf233c07d89772dedb Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Sun, 2 Aug 2015 15:46:15 +0300 Subject: [PATCH 2/2] new test file for double sin/cos/sincos --- tests/transcendentals-10-0.ispc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/transcendentals-10-0.ispc diff --git a/tests/transcendentals-10-0.ispc b/tests/transcendentals-10-0.ispc new file mode 100644 index 00000000..dbe7015b --- /dev/null +++ b/tests/transcendentals-10-0.ispc @@ -0,0 +1,27 @@ + +export uniform int width() { return programCount; } + +export void f_du(uniform float RET[], uniform double aFOO[], uniform double b) { + double a = aFOO[programIndex]; + uniform double sin_a[] = {0.8414709848078965, 0.9092974268256817, 0.1411200080598672, -0.7568024953079282, -0.9589242746631385, + -0.27941549819892586, 0.6569865987187891, 0.9893582466233818, 0.4121184852417566, -0.5440211108893698, + -0.9999902065507035, -0.5365729180004349, 0.4201670368266409, 0.9906073556948704, 0.6502878401571168, + -0.2879033166650653}; + uniform double cos_a[] = {0.5403023058681398, -0.4161468365471424, -0.9899924966004454, -0.6536436208636119, 0.28366218546322625, + 0.960170286650366, 0.7539022543433046, -0.14550003380861354, -0.9111302618846769, -0.8390715290764524, + 0.004425697988050785, 0.8438539587324921, 0.9074467814501962, 0.1367372182078336, -0.7596879128588213, + -0.9576594803233847}; + + RET[programIndex] = abs(sin(a) - sin_a[programIndex]) < 1d-7 ? 0 : 1; + RET[programIndex] += abs(cos(a) - cos_a[programIndex]) < 1d-7 ? 0 : 1; + + double sincos_s, sincos_c; + sincos(a, &sincos_s, &sincos_c); + + RET[programIndex] = abs(sincos_s - sin_a[programIndex]) < 1d-7 ? 0 : 1; + RET[programIndex] += abs(sincos_c - cos_a[programIndex]) < 1d-7 ? 0 : 1; +} + +export void result(uniform float RET[]) { + RET[programCount] = 0; +}