public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Committed] IBM Z: Fix PR96456
@ 2020-08-12  6:24 Andreas Krebbel
  2020-08-12  6:24 ` [Committed] IBM Z: Fix PR96308 Andreas Krebbel
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Krebbel @ 2020-08-12  6:24 UTC (permalink / raw)
  To: gcc-patches

The testcase failed because our backend refuses to generate vector
compare instructions for signaling operators with -fno-trapping-math
-fno-finite-math-only.

Bootstrapped and regression tested on s390x.

Committed to mainline.

gcc/ChangeLog:

	PR target/96456
	* config/s390/s390.h (TARGET_NONSIGNALING_VECTOR_COMPARE_OK): New
	macro.
	* config/s390/vector.md (vcond_comparison_operator): Use new macro
	for the check.

gcc/testsuite/ChangeLog:

	PR target/96456
	* gcc.target/s390/pr96456.c: New test.
---
 gcc/config/s390/s390.h                  |  5 +++++
 gcc/config/s390/vector.md               |  6 +++---
 gcc/testsuite/gcc.target/s390/pr96456.c | 13 +++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/s390/pr96456.c

diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index e4ef63e4080..ec5128c0af2 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -175,6 +175,11 @@ enum processor_flags
 #define TARGET_VECTOR_LOADSTORE_ALIGNMENT_HINTS 0
 #endif
 
+/* Evaluate to true if it is ok to emit a non-signaling vector
+   comparison.  */
+#define TARGET_NONSIGNALING_VECTOR_COMPARE_OK \
+  (TARGET_VX && !TARGET_VXE && (flag_finite_math_only || !flag_trapping_math))
+
 #ifdef HAVE_AS_MACHINE_MACHINEMODE
 #define S390_USE_TARGET_ATTRIBUTE 1
 #else
diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md
index 08f2d4cbda6..131bbda09bc 100644
--- a/gcc/config/s390/vector.md
+++ b/gcc/config/s390/vector.md
@@ -622,7 +622,7 @@
     case GT:
     case LTGT:
       /* Signaling vector comparisons are supported only on z14+.  */
-      return TARGET_Z14;
+      return TARGET_VXE || TARGET_NONSIGNALING_VECTOR_COMPARE_OK;
     default:
       return true;
     }
@@ -1534,7 +1534,7 @@
   [(set (match_operand:<tointvec>         0 "register_operand" "=v")
 	(gt:<tointvec> (match_operand:VFT 1 "register_operand" "v")
 		       (match_operand:VFT 2 "register_operand" "v")))]
-  "TARGET_VX && !TARGET_VXE && flag_finite_math_only"
+  "TARGET_NONSIGNALING_VECTOR_COMPARE_OK"
   "<vw>fch<sdx>b\t%v0,%v1,%v2"
   [(set_attr "op_type" "VRR")])
 
@@ -1551,7 +1551,7 @@
   [(set (match_operand:<tointvec>         0 "register_operand" "=v")
 	(ge:<tointvec> (match_operand:VFT 1 "register_operand" "v")
 		       (match_operand:VFT 2 "register_operand" "v")))]
-  "TARGET_VX && !TARGET_VXE && flag_finite_math_only"
+  "TARGET_NONSIGNALING_VECTOR_COMPARE_OK"
   "<vw>fche<sdx>b\t%v0,%v1,%v2"
   [(set_attr "op_type" "VRR")])
 
diff --git a/gcc/testsuite/gcc.target/s390/pr96456.c b/gcc/testsuite/gcc.target/s390/pr96456.c
new file mode 100644
index 00000000000..ea9e9cd7a37
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr96456.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -std=gnu99 -ffast-math -fno-finite-math-only -march=z13" } */
+
+int b, c, d;
+double *e;
+int f() {
+  double *a = a;
+  int g = d, f = c, h = b;
+  if (__builtin_expect(f, 0))
+    for (; g < h; g++)
+      e[g] = (int)(a[g] >= 0.0 ? g + 0.99999999 : a[g]);
+  return 0;
+}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Committed] IBM Z: Fix PR96308
  2020-08-12  6:24 [Committed] IBM Z: Fix PR96456 Andreas Krebbel
@ 2020-08-12  6:24 ` Andreas Krebbel
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Krebbel @ 2020-08-12  6:24 UTC (permalink / raw)
  To: gcc-patches

For the testcase a symbol with a TLS reloc and an unary minus is being
generated.  The backend didn't handle this correctly.

In s390_cannot_force_const_mem an unary minus on a symbolic constant
is rejected now since gas would not allow this.

legitimize_tls_address now makes the NEG rtx the outermost operation
by pulling it out of the CONST rtx.

Bootstrapped and regression tested on s390x.

Committed to mainline.

gcc/ChangeLog:

	PR target/96308
	* config/s390/s390.c (s390_cannot_force_const_mem): Reject an
	unary minus for everything not being a numeric constant.
	(legitimize_tls_address): Move a NEG out of the CONST rtx.

gcc/testsuite/ChangeLog:

	PR target/96308
	* g++.dg/pr96308.C: New test.
---
 gcc/config/s390/s390.c         | 25 +++++++++++++++++++++++++
 gcc/testsuite/g++.dg/pr96308.C |  7 +++++++
 2 files changed, 32 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/pr96308.C

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 22ac5e43121..5488a5dc5e8 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -4106,6 +4106,18 @@ s390_cannot_force_const_mem (machine_mode mode, rtx x)
       /* Accept all non-symbolic constants.  */
       return false;
 
+    case NEG:
+      /* Accept an unary '-' only on scalar numeric constants.  */
+      switch (GET_CODE (XEXP (x, 0)))
+	{
+	case CONST_INT:
+	case CONST_DOUBLE:
+	case CONST_WIDE_INT:
+	  return false;
+	default:
+	  return true;
+	}
+
     case LABEL_REF:
       /* Labels are OK iff we are non-PIC.  */
       return flag_pic != 0;
@@ -5268,6 +5280,7 @@ legitimize_tls_address (rtx addr, rtx reg)
     {
       switch (XINT (XEXP (addr, 0), 1))
 	{
+	case UNSPEC_NTPOFF:
 	case UNSPEC_INDNTPOFF:
 	  new_rtx = addr;
 	  break;
@@ -5290,6 +5303,18 @@ legitimize_tls_address (rtx addr, rtx reg)
       new_rtx = force_operand (new_rtx, 0);
     }
 
+  /* (const (neg (unspec (symbol_ref)))) -> (neg (const (unspec (symbol_ref)))) */
+  else if (GET_CODE (addr) == CONST && GET_CODE (XEXP (addr, 0)) == NEG)
+    {
+      new_rtx = XEXP (XEXP (addr, 0), 0);
+      if (GET_CODE (new_rtx) != SYMBOL_REF)
+	new_rtx = gen_rtx_CONST (Pmode, new_rtx);
+
+      new_rtx = legitimize_tls_address (new_rtx, reg);
+      new_rtx = gen_rtx_NEG (Pmode, new_rtx);
+      new_rtx = force_operand (new_rtx, 0);
+    }
+
   else
     gcc_unreachable ();  /* for now ... */
 
diff --git a/gcc/testsuite/g++.dg/pr96308.C b/gcc/testsuite/g++.dg/pr96308.C
new file mode 100644
index 00000000000..9009bba5e82
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr96308.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-Os -fno-move-loop-invariants -std=c++11" }
+
+struct NonTrivial3 {
+  ~NonTrivial3();
+};
+void i() { thread_local NonTrivial3 tlarr[10]; }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-12  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12  6:24 [Committed] IBM Z: Fix PR96456 Andreas Krebbel
2020-08-12  6:24 ` [Committed] IBM Z: Fix PR96308 Andreas Krebbel

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