aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-03-30 12:30:40 +0000
committerJakub Jelinek <jakub@redhat.com>2016-03-30 12:30:40 +0000
commit2f2e0bac95b43cca732647a746c2c5cfc1845341 (patch)
tree3f311a3844d556189e57ec5977838bf757403c97
parent5d1c0803b12f919bb71c653388e432302487cd09 (diff)
Backported from mainline
2016-02-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/69802 * tree-ssa-reassoc.c (update_range_test): If op is SSA_NAME_IS_DEFAULT_DEF, give up unless tem is a positive op == 1 test of precision 1 integral op, otherwise handle that case as op itself. Fix up formatting. (optimize_range_tests_to_bit_test, optimize_range_tests): Fix up formatting. * gcc.dg/pr69802.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@234550 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr69802.c23
-rw-r--r--gcc/tree-ssa-reassoc.c40
4 files changed, 72 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 87c46fe885f..49077d86010 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -3,6 +3,14 @@
Backported from mainline
2016-02-16 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/69802
+ * tree-ssa-reassoc.c (update_range_test): If op is
+ SSA_NAME_IS_DEFAULT_DEF, give up unless tem is a positive
+ op == 1 test of precision 1 integral op, otherwise handle
+ that case as op itself. Fix up formatting.
+ (optimize_range_tests_to_bit_test, optimize_range_tests): Fix
+ up formatting.
+
PR rtl-optimization/69764
PR rtl-optimization/69771
* optabs.c (expand_binop): Ensure for shift optabs invalid CONST_INT
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 144d040e4e9..b2f70b9d6d8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,11 @@
2016-03-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2016-02-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/69802
+ * gcc.dg/pr69802.c: New test.
+
2016-02-15 Jakub Jelinek <jakub@redhat.com>
PR c++/69797
diff --git a/gcc/testsuite/gcc.dg/pr69802.c b/gcc/testsuite/gcc.dg/pr69802.c
new file mode 100644
index 00000000000..27ee02f36b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr69802.c
@@ -0,0 +1,23 @@
+/* PR tree-optimization/69802 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+struct S { unsigned f : 1; };
+int a, d;
+
+int
+foo (void)
+{
+ unsigned b = 0;
+ struct S c;
+ d = ((1 && b) < c.f) & c.f; /* { dg-warning "is used uninitialized" } */
+ return a;
+}
+
+int
+bar (_Bool c)
+{
+ unsigned b = 0;
+ d = ((1 && b) < c) & c;
+ return a;
+}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 03faec5e4b3..0710bae7de0 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2134,11 +2134,33 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
in_p, low, high);
enum warn_strict_overflow_code wc = WARN_STRICT_OVERFLOW_COMPARISON;
gimple_stmt_iterator gsi;
- unsigned int i;
+ unsigned int i, uid;
if (tem == NULL_TREE)
return false;
+ /* If op is default def SSA_NAME, there is no place to insert the
+ new comparison. Give up, unless we can use OP itself as the
+ range test. */
+ if (op && SSA_NAME_IS_DEFAULT_DEF (op))
+ {
+ if (op == range->exp
+ && ((TYPE_PRECISION (optype) == 1 && TYPE_UNSIGNED (optype))
+ || TREE_CODE (optype) == BOOLEAN_TYPE)
+ && (op == tem
+ || (TREE_CODE (tem) == EQ_EXPR
+ && TREE_OPERAND (tem, 0) == op
+ && integer_onep (TREE_OPERAND (tem, 1))))
+ && opcode != BIT_IOR_EXPR
+ && (opcode != ERROR_MARK || oe->rank != BIT_IOR_EXPR))
+ {
+ stmt = NULL;
+ tem = op;
+ }
+ else
+ return false;
+ }
+
if (strict_overflow_p && issue_strict_overflow_warning (wc))
warning_at (loc, OPT_Wstrict_overflow,
"assuming signed overflow does not occur "
@@ -2176,12 +2198,22 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
tem = invert_truthvalue_loc (loc, tem);
tem = fold_convert_loc (loc, optype, tem);
- gsi = gsi_for_stmt (stmt);
- unsigned int uid = gimple_uid (stmt);
+ if (stmt)
+ {
+ gsi = gsi_for_stmt (stmt);
+ uid = gimple_uid (stmt);
+ }
+ else
+ {
+ gsi = gsi_none ();
+ uid = 0;
+ }
+ if (stmt == NULL)
+ gcc_checking_assert (tem == op);
/* In rare cases range->exp can be equal to lhs of stmt.
In that case we have to insert after the stmt rather then before
it. If stmt is a PHI, insert it at the start of the basic block. */
- if (op != range->exp)
+ else if (op != range->exp)
{
gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,