public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [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

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).