+2017-06-19 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80887
+ * tree-ssa-sccvn.c (mprts_hook_cnt): New global.
+ (vn_lookup_simplify_result): Allow only mprts_hook_cnt succesful
+ simplified lookups, then reset mprts_hook.
+ (vn_nary_build_or_lookup_1): Set mprts_hook_cnt to 9 before
+ simplifying.
+ (try_to_simplify): Likewise.
+
2017-06-19 Martin Liska <mliska@suse.cz>
PR sanitizer/80879
+2017-06-19 Richard Biener <rguenther@suse.de>
+
+ * gimple-parser.c (c_parser_gimple_postfix_expression): Handle
+ negated _Literals to parse _Literal (int) -1.
+
2017-06-13 Martin Liska <mliska@suse.cz>
PR sanitize/78204
}
else if (strcmp (IDENTIFIER_POINTER (id), "_Literal") == 0)
{
- /* _Literal '(' type-name ')' number */
+ /* _Literal '(' type-name ')' [ '-' ] constant */
c_parser_consume_token (parser);
tree type = NULL_TREE;
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
}
+ bool neg_p;
+ if ((neg_p = c_parser_next_token_is (parser, CPP_MINUS)))
+ c_parser_consume_token (parser);
tree val = c_parser_gimple_postfix_expression (parser).value;
if (! type
|| ! val
|| val == error_mark_node
- || TREE_CODE (val) != INTEGER_CST)
+ || ! CONSTANT_CLASS_P (val))
{
c_parser_error (parser, "invalid _Literal");
return expr;
}
+ if (neg_p)
+ {
+ val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val);
+ if (! val)
+ {
+ c_parser_error (parser, "invalid _Literal");
+ return expr;
+ }
+ }
expr.value = fold_convert (type, val);
return expr;
}
+2017-06-19 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80887
+ * gcc.dg/tree-ssa/pr80887.c: New testcase.
+
2017-06-19 Jakub Jelinek <jakub@redhat.com>
PR ipa/81112
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fgimple -O" } */
+
+int pos;
+void __GIMPLE (startwith("fre"))
+f()
+{
+ unsigned int t2;
+ unsigned int t1;
+ int a;
+ unsigned int u;
+ int _1;
+ int _2;
+ int _3;
+ unsigned int _4;
+ int _5;
+ unsigned int _6;
+
+bb_2:
+ _1 = pos;
+ _2 = _1 + 1;
+ pos = _2;
+ _3 = pos;
+ _4 = (unsigned int) _3;
+ u_9 = _4 + 4294967295u;
+ a_10 = pos;
+ _5 = a_10 + _Literal (int) -1;
+ t1_11 = (unsigned int) _5;
+ _6 = (unsigned int) a_10;
+ t2_12 = _6 + 4294967294u;
+ return;
+}
}
static vn_nary_op_t vn_nary_op_insert_stmt (gimple *stmt, tree result);
+static unsigned mprts_hook_cnt;
/* Hook for maybe_push_res_to_seq, lookup the expression in the VN tables. */
if (!rcode.is_tree_code ())
return NULL_TREE;
vn_nary_op_t vnresult = NULL;
- return vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
- (tree_code) rcode, type, ops, &vnresult);
+ tree res = vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
+ (tree_code) rcode, type, ops, &vnresult);
+ /* We can end up endlessly recursing simplifications if the lookup above
+ presents us with a def-use chain that mirrors the original simplification.
+ See PR80887 for an example. Limit successful lookup artificially
+ to 10 times if we are called as mprts_hook. */
+ if (res
+ && mprts_hook
+ && --mprts_hook_cnt == 0)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Resetting mprts_hook after too many "
+ "invocations.\n");
+ mprts_hook = NULL;
+ }
+ return res;
}
/* Return a value-number for RCODE OPS... either by looking up an existing
So first simplify and lookup this expression to see if it
is already available. */
mprts_hook = vn_lookup_simplify_result;
+ mprts_hook_cnt = 9;
bool res = false;
switch (TREE_CODE_LENGTH ((tree_code) rcode))
{
/* First try constant folding based on our current lattice. */
mprts_hook = vn_lookup_simplify_result;
+ mprts_hook_cnt = 9;
tem = gimple_fold_stmt_to_constant_1 (stmt, vn_valueize, vn_valueize);
mprts_hook = NULL;
if (tem