aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2014-12-01 13:05:41 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2014-12-01 13:05:41 +0100
commit64e5228e15ec4f5ccd9ba9ea309ddbeea678f447 (patch)
tree01bfdf1c99d8e9258be4ae9df6c71221c857c54d /gcc
parentf37477e5098105e140d88f8cb767f5780ee71f1f (diff)
downloadgcc-64e5228e15ec4f5ccd9ba9ea309ddbeea678f447.zip
gcc-64e5228e15ec4f5ccd9ba9ea309ddbeea678f447.tar.gz
gcc-64e5228e15ec4f5ccd9ba9ea309ddbeea678f447.tar.bz2
re PR tree-optimization/63551 (wrong code (segfaults) at -Os on x86_64-linux-gnu)
2014-12-01 Martin Jambor <mjambor@suse.cz> PR ipa/63551 * ipa-inline-analysis.c (evaluate_conditions_for_known_args): Convert value of the argument to the type of the value in the condition. testsuite/ * gcc.dg/ipa/pr63551.c: New test. * gcc.dg/ipa/pr64041.c: Likewise. From-SVN: r218205
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-inline-analysis.c5
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr63551.c33
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr64041.c64
5 files changed, 113 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a428bf0..2530e02 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-01 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/63551
+ * ipa-inline-analysis.c (evaluate_conditions_for_known_args): Convert
+ value of the argument to the type of the value in the condition.
+
2014-12-01 Oleg Endo <olegendo@gcc.gnu.org>
PR target/63986
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 9d62722..71b56fd 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -880,7 +880,10 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
}
if (c->code == IS_NOT_CONSTANT || c->code == CHANGED)
continue;
- res = fold_binary_to_constant (c->code, boolean_type_node, val, c->val);
+ val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c->val), val);
+ res = val
+ ? fold_binary_to_constant (c->code, boolean_type_node, val, c->val)
+ : NULL;
if (res && integer_zerop (res))
continue;
clause |= 1 << (i + predicate_first_dynamic_condition);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 52ac186..6fd7162 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-01 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/63551
+ * gcc.dg/ipa/pr63551.c: New test.
+ * gcc.dg/ipa/pr64041.c: Likewise.
+
2014-12-01 Ilya Tocar <ilya.tocar@intel.com>
* gcc.target/i386/avx512bw-vdbpsadbw-2.c: Move defines from options.
diff --git a/gcc/testsuite/gcc.dg/ipa/pr63551.c b/gcc/testsuite/gcc.dg/ipa/pr63551.c
new file mode 100644
index 0000000..676c2c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr63551.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-Os" } */
+
+union U
+{
+ unsigned int f0;
+ int f1;
+};
+
+int a, d;
+
+void
+fn1 (union U p)
+{
+ if (p.f1 <= 0)
+ if (a)
+ d = 0;
+}
+
+void
+fn2 ()
+{
+ d = 0;
+ union U b = { 4294967286 };
+ fn1 (b);
+}
+
+int
+main ()
+{
+ fn2 ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/pr64041.c b/gcc/testsuite/gcc.dg/ipa/pr64041.c
new file mode 100644
index 0000000..4877b4b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr64041.c
@@ -0,0 +1,64 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+int printf (const char *, ...);
+
+int a, b = 1, d;
+
+union U1
+{
+ unsigned int f0;
+ int f1;
+};
+
+union U2
+{
+ int f2;
+ int f3;
+} c;
+
+int
+fn1 (int p)
+{
+ int t = p && a || p && a && p;
+ return t ? t : a;
+}
+
+unsigned
+fn2 (union U1 p1, union U2 p2)
+{
+ if (p1.f1 <= 0)
+ {
+ for (; p2.f2;)
+ c.f2 = 0;
+ p2.f2 = fn1 (d);
+ }
+ return p2.f3;
+}
+
+int g = 0;
+
+int
+foo ()
+{
+ if (b)
+ {
+ union U1 f = { 0xFFFFFFFFU };
+
+ fn2 (f, c);
+ }
+ g = 1;
+ return 0;
+}
+
+
+int
+main ()
+{
+ foo ();
+
+ if (g == 0)
+ __builtin_abort ();
+
+ return 0;
+}