public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR tree-optimization/110266 - Check for integer only complex
@ 2023-06-15 16:22 Andrew MacLeod
  0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2023-06-15 16:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: hernandez, aldy

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

With the expanded capabilities of range-op dispatch, floating point 
complex objects can appear when folding, whic they couldn't before. In 
the processing for extracting integers from complex int's, make sure it 
actually is an integer.

Bootstraps on x86_64-pc-linux-gnu.  Regtesting currently under way.  
Assuming there are no issues, I will push this.

Andrew


[-- Attachment #2: 0001-Check-for-integer-only-complex.patch --]
[-- Type: text/x-patch, Size: 2678 bytes --]

From 2ba20a9e7b41fbcf1f03d5447e14b9b7b174fead Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Thu, 15 Jun 2023 11:59:55 -0400
Subject: [PATCH] Check for integer only complex.

With the expanded capabilities of range-op dispatch, floating point
complex objects can appear when folding, whic they couldn't before.
In the processig for extracting integers from complex ints, make sure it
is an integer complex.

	PR tree-optimization/110266
	gcc/
	* gimple-range-fold.cc (adjust_imagpart_expr): Check for integer
	complex type.
	(adjust_realpart_expr): Ditto.

	gcc/testsuite/
	* gcc.dg/pr110266.c: New.
---
 gcc/gimple-range-fold.cc        |  6 ++++--
 gcc/testsuite/gcc.dg/pr110266.c | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr110266.c

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 173d9f386c5..b4018d08d2b 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -506,7 +506,8 @@ adjust_imagpart_expr (vrange &res, const gimple *stmt)
       && gimple_assign_rhs_code (def_stmt) == COMPLEX_CST)
     {
       tree cst = gimple_assign_rhs1 (def_stmt);
-      if (TREE_CODE (cst) == COMPLEX_CST)
+      if (TREE_CODE (cst) == COMPLEX_CST
+	  && TREE_CODE (TREE_TYPE (TREE_TYPE (cst))) == INTEGER_TYPE)
 	{
 	  wide_int w = wi::to_wide (TREE_IMAGPART (cst));
 	  int_range<1> imag (TREE_TYPE (TREE_IMAGPART (cst)), w, w);
@@ -533,7 +534,8 @@ adjust_realpart_expr (vrange &res, const gimple *stmt)
       && gimple_assign_rhs_code (def_stmt) == COMPLEX_CST)
     {
       tree cst = gimple_assign_rhs1 (def_stmt);
-      if (TREE_CODE (cst) == COMPLEX_CST)
+      if (TREE_CODE (cst) == COMPLEX_CST
+	  && TREE_CODE (TREE_TYPE (TREE_TYPE (cst))) == INTEGER_TYPE)
 	{
 	  wide_int imag = wi::to_wide (TREE_REALPART (cst));
 	  int_range<2> tmp (TREE_TYPE (TREE_REALPART (cst)), imag, imag);
diff --git a/gcc/testsuite/gcc.dg/pr110266.c b/gcc/testsuite/gcc.dg/pr110266.c
new file mode 100644
index 00000000000..0b2acb5a791
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110266.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <math.h>
+
+int Hann_i, PsyBufferUpdate_psyInfo_0, PsyBufferUpdate_i;
+double *mdct_data;
+double PsyBufferUpdate_sfreq;
+void PsyBufferUpdate() {
+  if (PsyBufferUpdate_psyInfo_0 == 4)
+    for (; Hann_i;)
+      ;
+  {
+    double xr_0 = cos(PsyBufferUpdate_psyInfo_0);
+    PsyBufferUpdate_sfreq = sin(PsyBufferUpdate_psyInfo_0);
+    for (; PsyBufferUpdate_psyInfo_0; PsyBufferUpdate_i++)
+      mdct_data[PsyBufferUpdate_i] = xr_0 * PsyBufferUpdate_sfreq;
+  }
+}
+
-- 
2.40.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-15 16:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15 16:22 [PATCH] PR tree-optimization/110266 - Check for integer only complex Andrew MacLeod

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