diff options
author | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-01-17 11:43:56 +0000 |
---|---|---|
committer | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-01-17 11:43:56 +0000 |
commit | efcf544eb21432692f77c83025f6bca5d496f17f (patch) | |
tree | 1602bbe42736dfa8a3086665d1106216fa262d59 | |
parent | d1abe720238b8d3316565e56d8dbbf163319b3bb (diff) |
Subject: Backport r256009
2018-01-17 Martin Liska <mliska@suse.cz>
Backport from mainline
2017-12-27 Martin Liska <mliska@suse.cz>
PR tree-optimization/83552
* tree-ssa-strlen.c (fold_strstr_to_strncmp): Assign result
of get_string_lenth to a SSA_NAME if not a GIMPLE value.
2018-01-17 Martin Liska <mliska@suse.cz>
Backport from mainline
2017-12-27 Martin Liska <mliska@suse.cz>
PR tree-optimization/83552
* gcc.dg/pr83552.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256786 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr83552.c | 13 | ||||
-rw-r--r-- | gcc/tree-ssa-strlen.c | 10 |
4 files changed, 40 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d170efe04c1d..42fe9b15dbf8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-01-17 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-12-27 Martin Liska <mliska@suse.cz> + + PR tree-optimization/83552 + * tree-ssa-strlen.c (fold_strstr_to_strncmp): Assign result + of get_string_lenth to a SSA_NAME if not a GIMPLE value. + 2018-01-16 Segher Boessenkool <segher@kernel.crashing.org> Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dadc47741c70..4c22beb07aaa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-01-17 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-12-27 Martin Liska <mliska@suse.cz> + + PR tree-optimization/83552 + * gcc.dg/pr83552.c: New test. + 2018-01-16 Eric Botcazou <ebotcazou@adacore.com> PR testsuite/77734 diff --git a/gcc/testsuite/gcc.dg/pr83552.c b/gcc/testsuite/gcc.dg/pr83552.c new file mode 100644 index 000000000000..993cdd265819 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83552.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/83364 */ +/* { dg-options "-O2" } */ + +char *b; +char d[100]; +void a (); +void +c (void) +{ + __builtin_strcat (d, "12345"); + if (__builtin_strstr (b, d) == b) + a (); +} diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 9c72d122bbe2..f9f2fdd68f00 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -2306,6 +2306,16 @@ fold_strstr_to_strncmp (tree rhs1, tree rhs2, gimple *stmt) { gimple_stmt_iterator gsi = gsi_for_stmt (call_stmt); tree strncmp_decl = builtin_decl_explicit (BUILT_IN_STRNCMP); + + if (!is_gimple_val (arg1_len)) + { + tree arg1_len_tmp = make_ssa_name (TREE_TYPE (arg1_len)); + gassign *arg1_stmt = gimple_build_assign (arg1_len_tmp, + arg1_len); + gsi_insert_before (&gsi, arg1_stmt, GSI_SAME_STMT); + arg1_len = arg1_len_tmp; + } + gcall *strncmp_call = gimple_build_call (strncmp_decl, 3, arg0, arg1, arg1_len); tree strncmp_lhs = make_ssa_name (integer_type_node); |