aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c23
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr30433.c2
4 files changed, 37 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 152407b..aac9a3e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
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/30729
* stmt.c (warn_if_unused_value): VA_ARG_EXPR has side
effects unknown to this function, return early.
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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c0fc66a..e05d167 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
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.
+
+2007-02-15 Andrew Pinski <andrew_pinski@playstation.sony.com>
+
PR C++/30158
* g++.dg/ext/stmtexpr10.C: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr30433.c b/gcc/testsuite/gcc.c-torture/compile/pr30433.c
new file mode 100644
index 0000000..1f0edd0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr30433.c
@@ -0,0 +1,2 @@
+int f = (_Complex float)(0.5) == 0.5;
+