diff options
author | Andrew Pinski <andrew_pinski@playstation.sony.com> | 2007-02-16 01:27:42 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2007-02-15 17:27:42 -0800 |
commit | 3c32c87f609a47e126044ce2d3f29701fa2c4dcc (patch) | |
tree | 7b02a8f486f877aa1281bc0e4df1b4251217bc42 /gcc/fold-const.c | |
parent | 76b9a2a1cd4c0777039da22ae087268ab282c123 (diff) | |
download | gcc-3c32c87f609a47e126044ce2d3f29701fa2c4dcc.zip gcc-3c32c87f609a47e126044ce2d3f29701fa2c4dcc.tar.gz gcc-3c32c87f609a47e126044ce2d3f29701fa2c4dcc.tar.bz2 |
re PR middle-end/30433 (no longer folding __complex__(0.0, 1.0) == __complex__(1.0, 0.0))
2007-02-15 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR middle-end/30433
* fold-const.c (fold_comparison): Add back the
folding of constant complex comparisions.
2007-02-15 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR middle-end/30433
* gcc.c-torture/compile/pr30433.c: New testcase to check
that complex constants comparisions are foldded.
From-SVN: r122029
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0aca93c..3c8636e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8852,6 +8852,29 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) } } + /* If this is a comparison of complex values and both sides + are COMPLEX_CST, do the comparision by parts to fold the + comparision. */ + if ((code == EQ_EXPR || code == NE_EXPR) + && TREE_CODE (TREE_TYPE (arg0)) == COMPLEX_TYPE + && TREE_CODE (arg0) == COMPLEX_CST + && TREE_CODE (arg1) == COMPLEX_CST) + { + tree real0, imag0, real1, imag1; + enum tree_code outercode; + + real0 = TREE_REALPART (arg0); + imag0 = TREE_IMAGPART (arg0); + real1 = TREE_REALPART (arg1); + imag1 = TREE_IMAGPART (arg1); + outercode = code == EQ_EXPR ? TRUTH_ANDIF_EXPR : TRUTH_ORIF_EXPR; + + return fold_build2 (outercode, type, + fold_build2 (code, type, real0, real1), + fold_build2 (code, type, imag0, imag1)); + } + + /* Fold a comparison of the address of COMPONENT_REFs with the same type and component to a comparison of the address of the base object. In short, &x->a OP &y->a to x OP y and |