2016-07-07 Jakub Jelinek <jakub@redhat.com>
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.
+
2014-12-12 Richard Biener <rguenther@suse.de>
PR middle-end/64280
tree tem = build_range_check (loc, optype, exp, in_p, low, high);
enum warn_strict_overflow_code wc = WARN_STRICT_OVERFLOW_COMPARISON;
gimple_stmt_iterator gsi;
+ unsigned int 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 "
tem = invert_truthvalue_loc (loc, tem);
tem = fold_convert_loc (loc, optype, tem);
- gsi = gsi_for_stmt (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 (op == range->exp)
+ else if (op == range->exp)
tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, false,
GSI_CONTINUE_LINKING);
else
if (gimple_uid (gsi_stmt (gsi)))
break;
else
- gimple_set_uid (gsi_stmt (gsi), gimple_uid (stmt));
+ gimple_set_uid (gsi_stmt (gsi), uid);
oe->op = tem;
range->exp = exp;