* [PATCH][X86] Fix rounding pattern similar to PR73350 @ 2017-06-12 13:21 Koval, Julia 2017-06-12 13:42 ` H.J. Lu 0 siblings, 1 reply; 12+ messages in thread From: Koval, Julia @ 2017-06-12 13:21 UTC (permalink / raw) To: GCC Patches; +Cc: Uros Bizjak, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 1001 bytes --] This is the same issue as PR73350 and PR80862 for disabling FP exceptions. gcc -O0 -mavx512f -mavx512er returns exception gcc -O2 -mavx512f -mavx512er returns nan For this code: #include <stdio.h> #include <math.h> #include <x86intrin.h> #include <limits.h> #include <float.h> int main(int argc, char *argv[]) { __m512 a = _mm512_set1_ps((float) -1); __m512 b = _mm512_set1_ps((float) -1); _mm_setcsr( _MM_MASK_MASK &~ (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) ); __m512 result1 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_NO_EXC ); printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, _MM_FROUND_NO_EXC); __m512 result2 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_CUR_DIRECTION); printf("%g\n", result1[0] - result2[0]); return 0; } This patch fixes the issue. gcc/ * config/i386/i386.c: Fix rounding expand for new pattern * config/i386/subst.md: Fix pattern (parallel -> unspec) Ok for trunk? Thanks, Julia [-- Attachment #2: 0001-fix.patch --] [-- Type: application/octet-stream, Size: 1527 bytes --] From 239bb8c6d285c268d8f79fe6585def844eb46f7f Mon Sep 17 00:00:00 2001 From: julia <jkoval@gkticlel801.igk.intel.com> Date: Mon, 12 Jun 2017 13:23:29 +0300 Subject: [PATCH] fix --- gcc/config/i386/i386.c | 4 ++-- gcc/config/i386/subst.md | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d5c2d46..9f7290a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -36597,8 +36597,8 @@ ix86_expand_sse_comi_round (const struct builtin_description *d, } else { - gcc_assert (GET_CODE (XVECEXP (pat, 0, 0)) == SET); - set_dst = SET_DEST (XVECEXP (pat, 0, 0)); + gcc_assert (GET_CODE (pat) == SET); + set_dst = SET_DEST (pat); } emit_insn (pat); diff --git a/gcc/config/i386/subst.md b/gcc/config/i386/subst.md index 57fb0d4..4685db3 100644 --- a/gcc/config/i386/subst.md +++ b/gcc/config/i386/subst.md @@ -177,10 +177,11 @@ [(set (match_operand:SUBST_A 0) (match_operand:SUBST_A 1))] "TARGET_AVX512F" - [(parallel[ - (set (match_dup 0) - (match_dup 1)) - (unspec [(match_operand:SI 2 "const48_operand")] UNSPEC_EMBEDDED_ROUNDING)])]) + [(set (match_dup 0) + (unspec:SUBST_A [(match_dup 1) + (match_operand:SI 2 "const48_operand")] + UNSPEC_EMBEDDED_ROUNDING)) +]) (define_subst_attr "round_expand_name" "round_expand" "" "_round") (define_subst_attr "round_expand_nimm_predicate" "round_expand" "nonimmediate_operand" "register_operand") -- 2.5.5 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-12 13:21 [PATCH][X86] Fix rounding pattern similar to PR73350 Koval, Julia @ 2017-06-12 13:42 ` H.J. Lu 2017-06-12 16:06 ` Koval, Julia 0 siblings, 1 reply; 12+ messages in thread From: H.J. Lu @ 2017-06-12 13:42 UTC (permalink / raw) To: Koval, Julia; +Cc: GCC Patches, Uros Bizjak, Kirill Yukhin On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> wrote: > This is the same issue as PR73350 and PR80862 for disabling FP exceptions. > > gcc -O0 -mavx512f -mavx512er returns exception > gcc -O2 -mavx512f -mavx512er returns nan > > For this code: > > #include <stdio.h> > #include <math.h> > #include <x86intrin.h> > #include <limits.h> > #include <float.h> > > int main(int argc, char *argv[]) { > __m512 a = _mm512_set1_ps((float) -1); > __m512 b = _mm512_set1_ps((float) -1); > _mm_setcsr( _MM_MASK_MASK &~ > (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) ); > __m512 result1 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_NO_EXC ); > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, _MM_FROUND_NO_EXC); > __m512 result2 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_CUR_DIRECTION); > > printf("%g\n", result1[0] - result2[0]); > > return 0; > } > > This patch fixes the issue. > > gcc/ > * config/i386/i386.c: Fix rounding expand for new pattern > * config/i386/subst.md: Fix pattern (parallel -> unspec) > > Ok for trunk? > Please include the testcase. Thanks. -- H.J. ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-12 13:42 ` H.J. Lu @ 2017-06-12 16:06 ` Koval, Julia 2017-06-12 16:08 ` H.J. Lu 0 siblings, 1 reply; 12+ messages in thread From: Koval, Julia @ 2017-06-12 16:06 UTC (permalink / raw) To: H.J. Lu; +Cc: GCC Patches, Uros Bizjak, Kirill Yukhin I would like to, but as far as I know the only testcase possible is below, and as far as I know there is no possibility to use dg-error for runtime exceptions(Sorry, if I'm wrong). There are only 2 versions of the flag exception or no exception and the error is, when they are combined in CSE. > -----Original Message----- > From: H.J. Lu [mailto:hjl.tools@gmail.com] > Sent: Monday, June 12, 2017 3:43 PM > To: Koval, Julia <julia.koval@intel.com> > Cc: GCC Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak > <ubizjak@gmail.com>; Kirill Yukhin <kirill.yukhin@gmail.com> > Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > > On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> wrote: > > This is the same issue as PR73350 and PR80862 for disabling FP exceptions. > > > > gcc -O0 -mavx512f -mavx512er returns exception > > gcc -O2 -mavx512f -mavx512er returns nan > > > > For this code: > > > > #include <stdio.h> > > #include <math.h> > > #include <x86intrin.h> > > #include <limits.h> > > #include <float.h> > > > > int main(int argc, char *argv[]) { > > __m512 a = _mm512_set1_ps((float) -1); > > __m512 b = _mm512_set1_ps((float) -1); > > _mm_setcsr( _MM_MASK_MASK &~ > > > (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) ); > > __m512 result1 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_NO_EXC ); > > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, > _MM_FROUND_NO_EXC); > > __m512 result2 = _mm512_rsqrt28_round_ps(a, > _MM_FROUND_CUR_DIRECTION); > > > > printf("%g\n", result1[0] - result2[0]); > > > > return 0; > > } > > > > This patch fixes the issue. > > > > gcc/ > > * config/i386/i386.c: Fix rounding expand for new pattern > > * config/i386/subst.md: Fix pattern (parallel -> unspec) > > > > Ok for trunk? > > > > Please include the testcase. > > Thanks. > > -- > H.J. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-12 16:06 ` Koval, Julia @ 2017-06-12 16:08 ` H.J. Lu 2017-06-12 16:18 ` Jakub Jelinek 0 siblings, 1 reply; 12+ messages in thread From: H.J. Lu @ 2017-06-12 16:08 UTC (permalink / raw) To: Koval, Julia; +Cc: GCC Patches, Uros Bizjak, Kirill Yukhin On Mon, Jun 12, 2017 at 9:06 AM, Koval, Julia <julia.koval@intel.com> wrote: > I would like to, but as far as I know the only testcase possible is below, and as far as I know there is no possibility to use dg-error for runtime exceptions(Sorry, if I'm wrong). There are only 2 versions of the flag exception or no exception and the error is, when they are combined in CSE. Can you use if (wrong) abort (); in testcase? >> -----Original Message----- >> From: H.J. Lu [mailto:hjl.tools@gmail.com] >> Sent: Monday, June 12, 2017 3:43 PM >> To: Koval, Julia <julia.koval@intel.com> >> Cc: GCC Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak >> <ubizjak@gmail.com>; Kirill Yukhin <kirill.yukhin@gmail.com> >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 >> >> On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> wrote: >> > This is the same issue as PR73350 and PR80862 for disabling FP exceptions. >> > >> > gcc -O0 -mavx512f -mavx512er returns exception >> > gcc -O2 -mavx512f -mavx512er returns nan >> > >> > For this code: >> > >> > #include <stdio.h> >> > #include <math.h> >> > #include <x86intrin.h> >> > #include <limits.h> >> > #include <float.h> >> > >> > int main(int argc, char *argv[]) { >> > __m512 a = _mm512_set1_ps((float) -1); >> > __m512 b = _mm512_set1_ps((float) -1); >> > _mm_setcsr( _MM_MASK_MASK &~ >> > >> (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) ); >> > __m512 result1 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_NO_EXC ); >> > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, >> _MM_FROUND_NO_EXC); >> > __m512 result2 = _mm512_rsqrt28_round_ps(a, >> _MM_FROUND_CUR_DIRECTION); >> > >> > printf("%g\n", result1[0] - result2[0]); >> > >> > return 0; >> > } >> > >> > This patch fixes the issue. >> > >> > gcc/ >> > * config/i386/i386.c: Fix rounding expand for new pattern >> > * config/i386/subst.md: Fix pattern (parallel -> unspec) >> > >> > Ok for trunk? >> > >> >> Please include the testcase. >> >> Thanks. >> >> -- >> H.J. -- H.J. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-12 16:08 ` H.J. Lu @ 2017-06-12 16:18 ` Jakub Jelinek 2017-06-12 16:50 ` Koval, Julia 0 siblings, 1 reply; 12+ messages in thread From: Jakub Jelinek @ 2017-06-12 16:18 UTC (permalink / raw) To: H.J. Lu; +Cc: Koval, Julia, GCC Patches, Uros Bizjak, Kirill Yukhin On Mon, Jun 12, 2017 at 09:08:00AM -0700, H.J. Lu wrote: > On Mon, Jun 12, 2017 at 9:06 AM, Koval, Julia <julia.koval@intel.com> wrote: > > I would like to, but as far as I know the only testcase possible is below, and as far as I know there is no possibility to use dg-error for runtime exceptions(Sorry, if I'm wrong). There are only 2 versions of the flag exception or no exception and the error is, when they are combined in CSE. > > Can you use > > if (wrong) > abort (); > > in testcase? Where wrong can also be if (__builtin_fabsf (somefloatval - expectedval) < epsilon) or similar if needed. Also, the testcase contains many unnecessary includes, if you use __builtin_abort, I'd hope you only need x86intrin.h and nothing else. And, main can be just int main (), argc and argv aren't used. > > >> -----Original Message----- > >> From: H.J. Lu [mailto:hjl.tools@gmail.com] > >> Sent: Monday, June 12, 2017 3:43 PM > >> To: Koval, Julia <julia.koval@intel.com> > >> Cc: GCC Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak > >> <ubizjak@gmail.com>; Kirill Yukhin <kirill.yukhin@gmail.com> > >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > >> > >> On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> wrote: > >> > This is the same issue as PR73350 and PR80862 for disabling FP exceptions. > >> > > >> > gcc -O0 -mavx512f -mavx512er returns exception > >> > gcc -O2 -mavx512f -mavx512er returns nan > >> > > >> > For this code: > >> > > >> > #include <stdio.h> > >> > #include <math.h> > >> > #include <x86intrin.h> > >> > #include <limits.h> > >> > #include <float.h> > >> > > >> > int main(int argc, char *argv[]) { > >> > __m512 a = _mm512_set1_ps((float) -1); > >> > __m512 b = _mm512_set1_ps((float) -1); > >> > _mm_setcsr( _MM_MASK_MASK &~ > >> > > >> (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) ); > >> > __m512 result1 = _mm512_rsqrt28_round_ps(a, _MM_FROUND_NO_EXC ); > >> > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, > >> _MM_FROUND_NO_EXC); > >> > __m512 result2 = _mm512_rsqrt28_round_ps(a, > >> _MM_FROUND_CUR_DIRECTION); > >> > > >> > printf("%g\n", result1[0] - result2[0]); > >> > > >> > return 0; > >> > } Jakub ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-12 16:18 ` Jakub Jelinek @ 2017-06-12 16:50 ` Koval, Julia 2017-06-13 8:08 ` Richard Biener 0 siblings, 1 reply; 12+ messages in thread From: Koval, Julia @ 2017-06-12 16:50 UTC (permalink / raw) To: Jakub Jelinek, H.J. Lu; +Cc: GCC Patches, Uros Bizjak, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 3283 bytes --] I'm so sorry, but I really don't get it. The right result of the test is: Floating point exception (core dumped). The wrong result of the test is: nan(no exception). If I get an exception(which is right) - the test is failed anyway. The exception is raised in one instruction, I can't get any intermediate value there.. I tried to replaced it with compile time test(attached), which shows, that both instruction are generated(not combined) - is it ok? Thanks, Julia > -----Original Message----- > From: Jakub Jelinek [mailto:jakub@redhat.com] > Sent: Monday, June 12, 2017 6:18 PM > To: H.J. Lu <hjl.tools@gmail.com> > Cc: Koval, Julia <julia.koval@intel.com>; GCC Patches <gcc- > patches@gcc.gnu.org>; Uros Bizjak <ubizjak@gmail.com>; Kirill Yukhin > <kirill.yukhin@gmail.com> > Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > > On Mon, Jun 12, 2017 at 09:08:00AM -0700, H.J. Lu wrote: > > On Mon, Jun 12, 2017 at 9:06 AM, Koval, Julia <julia.koval@intel.com> wrote: > > > I would like to, but as far as I know the only testcase possible is below, and > as far as I know there is no possibility to use dg-error for runtime > exceptions(Sorry, if I'm wrong). There are only 2 versions of the flag exception > or no exception and the error is, when they are combined in CSE. > > > > Can you use > > > > if (wrong) > > abort (); > > > > in testcase? > > Where wrong can also be if (__builtin_fabsf (somefloatval - expectedval) < > epsilon) > or similar if needed. Also, the testcase contains many unnecessary > includes, if you use __builtin_abort, I'd hope you only need x86intrin.h and > nothing else. And, main can be just int main (), argc and argv aren't used. > > > > >> -----Original Message----- > > >> From: H.J. Lu [mailto:hjl.tools@gmail.com] > > >> Sent: Monday, June 12, 2017 3:43 PM > > >> To: Koval, Julia <julia.koval@intel.com> > > >> Cc: GCC Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak > > >> <ubizjak@gmail.com>; Kirill Yukhin <kirill.yukhin@gmail.com> > > >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > > >> > > >> On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> > wrote: > > >> > This is the same issue as PR73350 and PR80862 for disabling FP > exceptions. > > >> > > > >> > gcc -O0 -mavx512f -mavx512er returns exception > > >> > gcc -O2 -mavx512f -mavx512er returns nan > > >> > > > >> > For this code: > > >> > > > >> > #include <stdio.h> > > >> > #include <math.h> > > >> > #include <x86intrin.h> > > >> > #include <limits.h> > > >> > #include <float.h> > > >> > > > >> > int main(int argc, char *argv[]) { > > >> > __m512 a = _mm512_set1_ps((float) -1); > > >> > __m512 b = _mm512_set1_ps((float) -1); > > >> > _mm_setcsr( _MM_MASK_MASK &~ > > >> > > > >> (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) > ); > > >> > __m512 result1 = _mm512_rsqrt28_round_ps(a, > _MM_FROUND_NO_EXC ); > > >> > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, > > >> _MM_FROUND_NO_EXC); > > >> > __m512 result2 = _mm512_rsqrt28_round_ps(a, > > >> _MM_FROUND_CUR_DIRECTION); > > >> > > > >> > printf("%g\n", result1[0] - result2[0]); > > >> > > > >> > return 0; > > >> > } > > Jakub [-- Attachment #2: 0001-fix.patch --] [-- Type: application/octet-stream, Size: 2684 bytes --] From 8239fd51d39ec9aac5d68d0e49c1aa074410307a Mon Sep 17 00:00:00 2001 From: julia <jkoval@gkticlel801.igk.intel.com> Date: Mon, 12 Jun 2017 13:23:29 +0300 Subject: [PATCH] fix --- gcc/config/i386/i386.c | 4 ++-- gcc/config/i386/subst.md | 9 +++++---- gcc/testsuite/gcc.target/i386/pr73350-2.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr73350-2.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d5c2d46..9f7290a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -36597,8 +36597,8 @@ ix86_expand_sse_comi_round (const struct builtin_description *d, } else { - gcc_assert (GET_CODE (XVECEXP (pat, 0, 0)) == SET); - set_dst = SET_DEST (XVECEXP (pat, 0, 0)); + gcc_assert (GET_CODE (pat) == SET); + set_dst = SET_DEST (pat); } emit_insn (pat); diff --git a/gcc/config/i386/subst.md b/gcc/config/i386/subst.md index 57fb0d4..4685db3 100644 --- a/gcc/config/i386/subst.md +++ b/gcc/config/i386/subst.md @@ -177,10 +177,11 @@ [(set (match_operand:SUBST_A 0) (match_operand:SUBST_A 1))] "TARGET_AVX512F" - [(parallel[ - (set (match_dup 0) - (match_dup 1)) - (unspec [(match_operand:SI 2 "const48_operand")] UNSPEC_EMBEDDED_ROUNDING)])]) + [(set (match_dup 0) + (unspec:SUBST_A [(match_dup 1) + (match_operand:SI 2 "const48_operand")] + UNSPEC_EMBEDDED_ROUNDING)) +]) (define_subst_attr "round_expand_name" "round_expand" "" "_round") (define_subst_attr "round_expand_nimm_predicate" "round_expand" "nonimmediate_operand" "register_operand") diff --git a/gcc/testsuite/gcc.target/i386/pr73350-2.c b/gcc/testsuite/gcc.target/i386/pr73350-2.c new file mode 100644 index 0000000..cd5d599 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr73350-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f -mavx512er" } */ +/* { dg-final { scan-assembler-times "vrsqrt28ps\[ \\t\]+\[^\{\n\]*\{sae\}\[^\n\]*%zmm\[0-9\]+\[^\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vrsqrt28ps\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ + +#include <x86intrin.h> + +void +avx512f_test (void) +{ + __m512 a = _mm512_set1_ps((float) -1); + __m512 b = _mm512_set1_ps((float) -1); + _mm_setcsr (_MM_MASK_MASK & (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO)); + __m512 result1 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_NO_EXC); + __m512 result2 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_CUR_DIRECTION); + if (result1[0] == result2[0]) + abort (); +} -- 2.5.5 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-12 16:50 ` Koval, Julia @ 2017-06-13 8:08 ` Richard Biener 2017-06-13 11:37 ` Koval, Julia 0 siblings, 1 reply; 12+ messages in thread From: Richard Biener @ 2017-06-13 8:08 UTC (permalink / raw) To: Koval, Julia Cc: Jakub Jelinek, H.J. Lu, GCC Patches, Uros Bizjak, Kirill Yukhin On Mon, Jun 12, 2017 at 6:50 PM, Koval, Julia <julia.koval@intel.com> wrote: > I'm so sorry, but I really don't get it. The right result of the test is: Floating point exception (core dumped). The wrong result of the test is: nan(no exception). If I get an exception(which is right) - the test is failed anyway. The exception is raised in one instruction, I can't get any intermediate value there.. We do have a few testcases catching these cases by installing a signal handler (grep for sigaction in testsuite/) Richard. > I tried to replaced it with compile time test(attached), which shows, that both instruction are generated(not combined) - is it ok? > > Thanks, > Julia > >> -----Original Message----- >> From: Jakub Jelinek [mailto:jakub@redhat.com] >> Sent: Monday, June 12, 2017 6:18 PM >> To: H.J. Lu <hjl.tools@gmail.com> >> Cc: Koval, Julia <julia.koval@intel.com>; GCC Patches <gcc- >> patches@gcc.gnu.org>; Uros Bizjak <ubizjak@gmail.com>; Kirill Yukhin >> <kirill.yukhin@gmail.com> >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 >> >> On Mon, Jun 12, 2017 at 09:08:00AM -0700, H.J. Lu wrote: >> > On Mon, Jun 12, 2017 at 9:06 AM, Koval, Julia <julia.koval@intel.com> wrote: >> > > I would like to, but as far as I know the only testcase possible is below, and >> as far as I know there is no possibility to use dg-error for runtime >> exceptions(Sorry, if I'm wrong). There are only 2 versions of the flag exception >> or no exception and the error is, when they are combined in CSE. >> > >> > Can you use >> > >> > if (wrong) >> > abort (); >> > >> > in testcase? >> >> Where wrong can also be if (__builtin_fabsf (somefloatval - expectedval) < >> epsilon) >> or similar if needed. Also, the testcase contains many unnecessary >> includes, if you use __builtin_abort, I'd hope you only need x86intrin.h and >> nothing else. And, main can be just int main (), argc and argv aren't used. >> > >> > >> -----Original Message----- >> > >> From: H.J. Lu [mailto:hjl.tools@gmail.com] >> > >> Sent: Monday, June 12, 2017 3:43 PM >> > >> To: Koval, Julia <julia.koval@intel.com> >> > >> Cc: GCC Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak >> > >> <ubizjak@gmail.com>; Kirill Yukhin <kirill.yukhin@gmail.com> >> > >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 >> > >> >> > >> On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> >> wrote: >> > >> > This is the same issue as PR73350 and PR80862 for disabling FP >> exceptions. >> > >> > >> > >> > gcc -O0 -mavx512f -mavx512er returns exception >> > >> > gcc -O2 -mavx512f -mavx512er returns nan >> > >> > >> > >> > For this code: >> > >> > >> > >> > #include <stdio.h> >> > >> > #include <math.h> >> > >> > #include <x86intrin.h> >> > >> > #include <limits.h> >> > >> > #include <float.h> >> > >> > >> > >> > int main(int argc, char *argv[]) { >> > >> > __m512 a = _mm512_set1_ps((float) -1); >> > >> > __m512 b = _mm512_set1_ps((float) -1); >> > >> > _mm_setcsr( _MM_MASK_MASK &~ >> > >> > >> > >> (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) >> ); >> > >> > __m512 result1 = _mm512_rsqrt28_round_ps(a, >> _MM_FROUND_NO_EXC ); >> > >> > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, >> > >> _MM_FROUND_NO_EXC); >> > >> > __m512 result2 = _mm512_rsqrt28_round_ps(a, >> > >> _MM_FROUND_CUR_DIRECTION); >> > >> > >> > >> > printf("%g\n", result1[0] - result2[0]); >> > >> > >> > >> > return 0; >> > >> > } >> >> Jakub ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-13 8:08 ` Richard Biener @ 2017-06-13 11:37 ` Koval, Julia 2017-06-14 9:54 ` Uros Bizjak 0 siblings, 1 reply; 12+ messages in thread From: Koval, Julia @ 2017-06-13 11:37 UTC (permalink / raw) To: Richard Biener Cc: Jakub Jelinek, H.J. Lu, GCC Patches, Uros Bizjak, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 4498 bytes --] Thank you for your help. I fixed the test similar to existing sigaction tests. gcc/ * config/i386/i386.c: Fix rounding expand for new pattern. * config/i386/subst.md: Fix pattern (parallel -> unspec). gcc/testsuite/ * gcc.target/i386/pr73350-2.c: New test. Thanks, Julia > -----Original Message----- > From: Richard Biener [mailto:richard.guenther@gmail.com] > Sent: Tuesday, June 13, 2017 10:09 AM > To: Koval, Julia <julia.koval@intel.com> > Cc: Jakub Jelinek <jakub@redhat.com>; H.J. Lu <hjl.tools@gmail.com>; GCC > Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak <ubizjak@gmail.com>; Kirill > Yukhin <kirill.yukhin@gmail.com> > Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > > On Mon, Jun 12, 2017 at 6:50 PM, Koval, Julia <julia.koval@intel.com> wrote: > > I'm so sorry, but I really don't get it. The right result of the test is: Floating > point exception (core dumped). The wrong result of the test is: nan(no > exception). If I get an exception(which is right) - the test is failed anyway. The > exception is raised in one instruction, I can't get any intermediate value there.. > > We do have a few testcases catching these cases by installing a signal > handler (grep for sigaction in testsuite/) > > Richard. > > > I tried to replaced it with compile time test(attached), which shows, that both > instruction are generated(not combined) - is it ok? > > > > Thanks, > > Julia > > > >> -----Original Message----- > >> From: Jakub Jelinek [mailto:jakub@redhat.com] > >> Sent: Monday, June 12, 2017 6:18 PM > >> To: H.J. Lu <hjl.tools@gmail.com> > >> Cc: Koval, Julia <julia.koval@intel.com>; GCC Patches <gcc- > >> patches@gcc.gnu.org>; Uros Bizjak <ubizjak@gmail.com>; Kirill Yukhin > >> <kirill.yukhin@gmail.com> > >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > >> > >> On Mon, Jun 12, 2017 at 09:08:00AM -0700, H.J. Lu wrote: > >> > On Mon, Jun 12, 2017 at 9:06 AM, Koval, Julia <julia.koval@intel.com> > wrote: > >> > > I would like to, but as far as I know the only testcase possible is below, > and > >> as far as I know there is no possibility to use dg-error for runtime > >> exceptions(Sorry, if I'm wrong). There are only 2 versions of the flag > exception > >> or no exception and the error is, when they are combined in CSE. > >> > > >> > Can you use > >> > > >> > if (wrong) > >> > abort (); > >> > > >> > in testcase? > >> > >> Where wrong can also be if (__builtin_fabsf (somefloatval - expectedval) < > >> epsilon) > >> or similar if needed. Also, the testcase contains many unnecessary > >> includes, if you use __builtin_abort, I'd hope you only need x86intrin.h and > >> nothing else. And, main can be just int main (), argc and argv aren't used. > >> > > >> > >> -----Original Message----- > >> > >> From: H.J. Lu [mailto:hjl.tools@gmail.com] > >> > >> Sent: Monday, June 12, 2017 3:43 PM > >> > >> To: Koval, Julia <julia.koval@intel.com> > >> > >> Cc: GCC Patches <gcc-patches@gcc.gnu.org>; Uros Bizjak > >> > >> <ubizjak@gmail.com>; Kirill Yukhin <kirill.yukhin@gmail.com> > >> > >> Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > >> > >> > >> > >> On Mon, Jun 12, 2017 at 6:21 AM, Koval, Julia <julia.koval@intel.com> > >> wrote: > >> > >> > This is the same issue as PR73350 and PR80862 for disabling FP > >> exceptions. > >> > >> > > >> > >> > gcc -O0 -mavx512f -mavx512er returns exception > >> > >> > gcc -O2 -mavx512f -mavx512er returns nan > >> > >> > > >> > >> > For this code: > >> > >> > > >> > >> > #include <stdio.h> > >> > >> > #include <math.h> > >> > >> > #include <x86intrin.h> > >> > >> > #include <limits.h> > >> > >> > #include <float.h> > >> > >> > > >> > >> > int main(int argc, char *argv[]) { > >> > >> > __m512 a = _mm512_set1_ps((float) -1); > >> > >> > __m512 b = _mm512_set1_ps((float) -1); > >> > >> > _mm_setcsr( _MM_MASK_MASK &~ > >> > >> > > >> > >> > (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) > >> ); > >> > >> > __m512 result1 = _mm512_rsqrt28_round_ps(a, > >> _MM_FROUND_NO_EXC ); > >> > >> > printf("%d %d\n", _MM_FROUND_CUR_DIRECTION, > >> > >> _MM_FROUND_NO_EXC); > >> > >> > __m512 result2 = _mm512_rsqrt28_round_ps(a, > >> > >> _MM_FROUND_CUR_DIRECTION); > >> > >> > > >> > >> > printf("%g\n", result1[0] - result2[0]); > >> > >> > > >> > >> > return 0; > >> > >> > } > >> > >> Jakub [-- Attachment #2: 0001-fix.patch --] [-- Type: application/octet-stream, Size: 2753 bytes --] From 7844ba15defae9fb4c276cb796158d5a60938d18 Mon Sep 17 00:00:00 2001 From: julia <jkoval@gkticlel801.igk.intel.com> Date: Mon, 12 Jun 2017 13:23:29 +0300 Subject: [PATCH] fix --- gcc/config/i386/i386.c | 4 ++-- gcc/config/i386/subst.md | 9 +++++---- gcc/testsuite/gcc.target/i386/pr73350-2.c | 33 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr73350-2.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d5c2d46..9f7290a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -36597,8 +36597,8 @@ ix86_expand_sse_comi_round (const struct builtin_description *d, } else { - gcc_assert (GET_CODE (XVECEXP (pat, 0, 0)) == SET); - set_dst = SET_DEST (XVECEXP (pat, 0, 0)); + gcc_assert (GET_CODE (pat) == SET); + set_dst = SET_DEST (pat); } emit_insn (pat); diff --git a/gcc/config/i386/subst.md b/gcc/config/i386/subst.md index 57fb0d4..4685db3 100644 --- a/gcc/config/i386/subst.md +++ b/gcc/config/i386/subst.md @@ -177,10 +177,11 @@ [(set (match_operand:SUBST_A 0) (match_operand:SUBST_A 1))] "TARGET_AVX512F" - [(parallel[ - (set (match_dup 0) - (match_dup 1)) - (unspec [(match_operand:SI 2 "const48_operand")] UNSPEC_EMBEDDED_ROUNDING)])]) + [(set (match_dup 0) + (unspec:SUBST_A [(match_dup 1) + (match_operand:SI 2 "const48_operand")] + UNSPEC_EMBEDDED_ROUNDING)) +]) (define_subst_attr "round_expand_name" "round_expand" "" "_round") (define_subst_attr "round_expand_nimm_predicate" "round_expand" "nonimmediate_operand" "register_operand") diff --git a/gcc/testsuite/gcc.target/i386/pr73350-2.c b/gcc/testsuite/gcc.target/i386/pr73350-2.c new file mode 100644 index 0000000..e7137f7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr73350-2.c @@ -0,0 +1,33 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* } } */ +/* { dg-options "-O2 -mavx512f -mavx512er" } */ +/* { dg-require-effective-target avx512f } */ + +#include <x86intrin.h> +#include <unistd.h> +#include <signal.h> +#include <stdlib.h> + +void do_exit (int i) +{ + exit (0); +} + +void +main (void) +{ + struct sigaction s; + sigemptyset (&s.sa_mask); + s.sa_handler = do_exit; + s.sa_flags = 0; + sigaction (SIGFPE, &s, NULL); + alarm (1); + + __m512 a = _mm512_set1_ps ((float) -1); + __m512 b = _mm512_set1_ps ((float) -1); + _mm_setcsr ( _MM_MASK_MASK &~ (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) ); + __m512 result1 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_NO_EXC); + __m512 result2 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_CUR_DIRECTION); + + if (result1[0] + result2[0]) + abort (); +} -- 2.5.5 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-13 11:37 ` Koval, Julia @ 2017-06-14 9:54 ` Uros Bizjak 2017-06-16 6:46 ` Koval, Julia 0 siblings, 1 reply; 12+ messages in thread From: Uros Bizjak @ 2017-06-14 9:54 UTC (permalink / raw) To: Koval, Julia Cc: Richard Biener, Jakub Jelinek, H.J. Lu, GCC Patches, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 478 bytes --] On Tue, Jun 13, 2017 at 1:37 PM, Koval, Julia <julia.koval@intel.com> wrote: > Thank you for your help. I fixed the test similar to existing sigaction tests. > > gcc/ > * config/i386/i386.c: Fix rounding expand for new pattern. > * config/i386/subst.md: Fix pattern (parallel -> unspec). > gcc/testsuite/ > * gcc.target/i386/pr73350-2.c: New test. The test will fail at runtime on non-avx512er targets. Can you please test the attached testcase? Uros. [-- Attachment #2: t.c --] [-- Type: text/x-csrc, Size: 729 bytes --] /* { dg-do run { target *-*-linux* *-*-gnu* } } */ /* { dg-options "-O2 -mavx512er" } */ /* { dg-require-effective-target avx512er } */ #include "avx512er-check.h" #include <x86intrin.h> #include <unistd.h> #include <signal.h> static int counter; void handler (int i) { counter++; } static void avx512er_test (void) { struct sigaction s; sigemptyset (&s.sa_mask); s.sa_handler = handler; s.sa_flags = 0; sigaction (SIGFPE, &s, NULL); __m512 a = _mm512_set1_ps (-1.f); _mm_setcsr ( _MM_MASK_MASK & ~_MM_MASK_INVALID ); volatile __m512 r1 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_NO_EXC); volatile __m512 r2 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_CUR_DIRECTION); if (counter != 1) abort (); } ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-14 9:54 ` Uros Bizjak @ 2017-06-16 6:46 ` Koval, Julia 2017-06-16 7:05 ` Uros Bizjak 0 siblings, 1 reply; 12+ messages in thread From: Koval, Julia @ 2017-06-16 6:46 UTC (permalink / raw) To: Uros Bizjak Cc: Richard Biener, Jakub Jelinek, H.J. Lu, GCC Patches, Kirill Yukhin [-- Attachment #1: Type: text/plain, Size: 1305 bytes --] Hi, This test hangs on avx512er, maybe that's why: > According to POSIX, the behavior of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by kill(2) or raise(3). And volatile make it work even without a patch(r1 and r2 are not combined then). Added other changes. Thanks, Julia > -----Original Message----- > From: Uros Bizjak [mailto:ubizjak@gmail.com] > Sent: Wednesday, June 14, 2017 11:54 AM > To: Koval, Julia <julia.koval@intel.com> > Cc: Richard Biener <richard.guenther@gmail.com>; Jakub Jelinek > <jakub@redhat.com>; H.J. Lu <hjl.tools@gmail.com>; GCC Patches <gcc- > patches@gcc.gnu.org>; Kirill Yukhin <kirill.yukhin@gmail.com> > Subject: Re: [PATCH][X86] Fix rounding pattern similar to PR73350 > > On Tue, Jun 13, 2017 at 1:37 PM, Koval, Julia <julia.koval@intel.com> wrote: > > Thank you for your help. I fixed the test similar to existing sigaction tests. > > > > gcc/ > > * config/i386/i386.c: Fix rounding expand for new pattern. > > * config/i386/subst.md: Fix pattern (parallel -> unspec). > > gcc/testsuite/ > > * gcc.target/i386/pr73350-2.c: New test. > > The test will fail at runtime on non-avx512er targets. Can you please > test the attached testcase? > > Uros. [-- Attachment #2: 0001-fix.patch --] [-- Type: application/octet-stream, Size: 2675 bytes --] From aa67411b55098487c22d9ea86a51377ec5514743 Mon Sep 17 00:00:00 2001 From: julia <jkoval@gkticlel801.igk.intel.com> Date: Mon, 12 Jun 2017 13:23:29 +0300 Subject: [PATCH] fix --- gcc/config/i386/i386.c | 4 ++-- gcc/config/i386/subst.md | 9 ++++---- gcc/testsuite/gcc.target/i386/pr73350-2.c | 35 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr73350-2.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d5c2d46..9f7290a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -36597,8 +36597,8 @@ ix86_expand_sse_comi_round (const struct builtin_description *d, } else { - gcc_assert (GET_CODE (XVECEXP (pat, 0, 0)) == SET); - set_dst = SET_DEST (XVECEXP (pat, 0, 0)); + gcc_assert (GET_CODE (pat) == SET); + set_dst = SET_DEST (pat); } emit_insn (pat); diff --git a/gcc/config/i386/subst.md b/gcc/config/i386/subst.md index 57fb0d4..4685db3 100644 --- a/gcc/config/i386/subst.md +++ b/gcc/config/i386/subst.md @@ -177,10 +177,11 @@ [(set (match_operand:SUBST_A 0) (match_operand:SUBST_A 1))] "TARGET_AVX512F" - [(parallel[ - (set (match_dup 0) - (match_dup 1)) - (unspec [(match_operand:SI 2 "const48_operand")] UNSPEC_EMBEDDED_ROUNDING)])]) + [(set (match_dup 0) + (unspec:SUBST_A [(match_dup 1) + (match_operand:SI 2 "const48_operand")] + UNSPEC_EMBEDDED_ROUNDING)) +]) (define_subst_attr "round_expand_name" "round_expand" "" "_round") (define_subst_attr "round_expand_nimm_predicate" "round_expand" "nonimmediate_operand" "register_operand") diff --git a/gcc/testsuite/gcc.target/i386/pr73350-2.c b/gcc/testsuite/gcc.target/i386/pr73350-2.c new file mode 100644 index 0000000..c1faab4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr73350-2.c @@ -0,0 +1,35 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* } } */ +/* { dg-options "-O2 -mavx512er" } */ +/* { dg-require-effective-target avx512er } */ + +#include "avx512er-check.h" + +#include <x86intrin.h> +#include <unistd.h> +#include <signal.h> + +static int counter; + +void handler (int i) +{ + exit (0); +} + +static void +avx512er_test (void) +{ + struct sigaction s; + sigemptyset (&s.sa_mask); + s.sa_handler = handler; + s.sa_flags = 0; + sigaction (SIGFPE, &s, NULL); + + __m512 a = _mm512_set1_ps (-1.f); + + _mm_setcsr ( _MM_MASK_MASK & ~_MM_MASK_INVALID ); + __m512 r1 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_NO_EXC); + __m512 r2 = _mm512_rsqrt28_round_ps (a, _MM_FROUND_CUR_DIRECTION); + + if (r1[0] + r2[0]) + abort (); +} -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-16 6:46 ` Koval, Julia @ 2017-06-16 7:05 ` Uros Bizjak 2017-06-20 18:26 ` Kirill Yukhin 0 siblings, 1 reply; 12+ messages in thread From: Uros Bizjak @ 2017-06-16 7:05 UTC (permalink / raw) To: Koval, Julia Cc: Richard Biener, Jakub Jelinek, H.J. Lu, GCC Patches, Kirill Yukhin On Fri, Jun 16, 2017 at 8:46 AM, Koval, Julia <julia.koval@intel.com> wrote: > Hi, > > This test hangs on avx512er, maybe that's why: >> According to POSIX, the behavior of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by kill(2) or raise(3). > > And volatile make it work even without a patch(r1 and r2 are not combined then). > > Added other changes. The testcase LGTM. I'll leave the final approval to Kirill. Uros. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][X86] Fix rounding pattern similar to PR73350 2017-06-16 7:05 ` Uros Bizjak @ 2017-06-20 18:26 ` Kirill Yukhin 0 siblings, 0 replies; 12+ messages in thread From: Kirill Yukhin @ 2017-06-20 18:26 UTC (permalink / raw) To: Uros Bizjak Cc: Koval, Julia, Richard Biener, Jakub Jelinek, H.J. Lu, GCC Patches Hello Julia, Uroš, On 16 Jun 09:05, Uros Bizjak wrote: > On Fri, Jun 16, 2017 at 8:46 AM, Koval, Julia <julia.koval@intel.com> wrote: > > Hi, > > > > This test hangs on avx512er, maybe that's why: > >> According to POSIX, the behavior of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by kill(2) or raise(3). > > > > And volatile make it work even without a patch(r1 and r2 are not combined then). > > > > Added other changes. > > The testcase LGTM. I'll leave the final approval to Kirill. The change and the case are fine to me. I've committed it to main trunk. > > Uros. =- Thanks, K ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-06-20 18:26 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-06-12 13:21 [PATCH][X86] Fix rounding pattern similar to PR73350 Koval, Julia 2017-06-12 13:42 ` H.J. Lu 2017-06-12 16:06 ` Koval, Julia 2017-06-12 16:08 ` H.J. Lu 2017-06-12 16:18 ` Jakub Jelinek 2017-06-12 16:50 ` Koval, Julia 2017-06-13 8:08 ` Richard Biener 2017-06-13 11:37 ` Koval, Julia 2017-06-14 9:54 ` Uros Bizjak 2017-06-16 6:46 ` Koval, Julia 2017-06-16 7:05 ` Uros Bizjak 2017-06-20 18:26 ` Kirill Yukhin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).