diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-06-15 11:59:55 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-06-15 12:37:08 -0400 |
commit | 6c121a2c687c56b09ecc11ef6ae1893ec5006325 (patch) | |
tree | fdcd2bc82d31b109e3e3a9f337da2ac5a1501f16 | |
parent | 37f373e974ac0a272b0e2b24e27c08833ad43470 (diff) | |
download | gcc-6c121a2c687c56b09ecc11ef6ae1893ec5006325.zip gcc-6c121a2c687c56b09ecc11ef6ae1893ec5006325.tar.gz gcc-6c121a2c687c56b09ecc11ef6ae1893ec5006325.tar.bz2 |
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.
-rw-r--r-- | gcc/gimple-range-fold.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr110266.c | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index efcc3d8..d072460 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -508,7 +508,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); @@ -535,7 +536,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 0000000..0b2acb5 --- /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; + } +} + |