summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2009-10-13 11:31:08 +0000
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2009-10-13 11:31:08 +0000
commitdf017114b7c46d7cb9f6a51888a7939a5767047c (patch)
treec366eb26ee9527581ae826e651347c89c8a66cbd
parent37531c6560b357b092ff7a94f70b2cba985a8d0b (diff)
downloadgcc-df017114b7c46d7cb9f6a51888a7939a5767047c.tar.gz
2009-10-13 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/41661 * ipa-prop.c (compute_complex_pass_through): Allow only operations that are tcc_comparisons or do not change the type in any un-usleless way. * ipa-cp.c (ipcp_lattice_from_jfunc): Request boolean type when folding tcc_comparison operations. * testsuite/gcc.c-torture/compile/pr41661.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152702 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/ipa-cp.c13
-rw-r--r--gcc/ipa-prop.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr41661.c20
5 files changed, 46 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 495e1920259..c60bd482e71 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2009-10-13 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/41661
+ * ipa-prop.c (compute_complex_pass_through): Allow only operations
+ that are tcc_comparisons or do not change the type in any
+ un-usleless way.
+ * ipa-cp.c (ipcp_lattice_from_jfunc): Request boolean type when
+ folding tcc_comparison operations.
+
2009-10-13 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/s390/s390.c (s390_encode_section_info): Handle BLKmode
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 59a051915f6..7e499ca27fa 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -299,9 +299,16 @@ ipcp_lattice_from_jfunc (struct ipa_node_params *info, struct ipcp_lattice *lat,
cst = caller_lat->constant;
if (jfunc->value.pass_through.operation != NOP_EXPR)
- cst = fold_binary (jfunc->value.pass_through.operation,
- TREE_TYPE (cst), cst,
- jfunc->value.pass_through.operand);
+ {
+ tree restype;
+ if (TREE_CODE_CLASS (jfunc->value.pass_through.operation)
+ == tcc_comparison)
+ restype = boolean_type_node;
+ else
+ restype = TREE_TYPE (cst);
+ cst = fold_binary (jfunc->value.pass_through.operation,
+ restype, cst, jfunc->value.pass_through.operand);
+ }
if (!cst || !is_gimple_ip_invariant (cst))
lat->type = IPA_BOTTOM;
lat->constant = cst;
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 0e6aaf51168..93c407b0826 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -357,6 +357,9 @@ compute_complex_pass_through (struct ipa_node_params *info,
{
if (TREE_CODE (op1) != SSA_NAME
|| !SSA_NAME_IS_DEFAULT_DEF (op1)
+ || (TREE_CODE_CLASS (gimple_expr_code (stmt)) != tcc_comparison
+ && !useless_type_conversion_p (TREE_TYPE (name),
+ TREE_TYPE (op1)))
|| !is_gimple_ip_invariant (op2))
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 23035892ca8..8e53af978ff 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-10-13 Martin Jambor <mjambor@suse.cz>
+
+ * gcc.c-torture/compile/pr41661.c: New test.
+
2009-10-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/41683
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr41661.c b/gcc/testsuite/gcc.c-torture/compile/pr41661.c
new file mode 100644
index 00000000000..658e4288b8d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr41661.c
@@ -0,0 +1,20 @@
+/* PR tree-optimization/41661 */
+/* { dg-do compile } */
+/* { dg-options "-fno-early-inlining" } */
+
+int g;
+
+void foo (int x)
+{
+ g = x;
+}
+
+void bar (double d)
+{
+ foo (d == 1);
+}
+
+void baz (int a)
+{
+ bar (1);
+}