diff options
author | Richard Biener <rguenther@suse.de> | 2017-04-21 12:47:02 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-04-21 12:47:02 +0000 |
commit | 2fd30fbe0d3a9525ec14e0102f3ebb0e80a2736e (patch) | |
tree | 42f28df22eb2f507943aa8dfc534240d738c9a69 /gcc/tree-ssa-structalias.c | |
parent | bb1bc604a852c38afd0df9d2f6a66a0e1a80db34 (diff) | |
download | gcc-2fd30fbe0d3a9525ec14e0102f3ebb0e80a2736e.zip gcc-2fd30fbe0d3a9525ec14e0102f3ebb0e80a2736e.tar.gz gcc-2fd30fbe0d3a9525ec14e0102f3ebb0e80a2736e.tar.bz2 |
re PR tree-optimization/79547 (duplicate strlen calls with same argument not folded)
2017-04-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/79547
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
Handle strlen, strcmp, strncmp, strcasecmp, strncasecmp, memcmp,
bcmp, strspn, strcspn, __builtin_object_size and __builtin_constant_p
without any constraints.
* gcc.dg/tree-ssa/strlen-2.c: New testcase.
From-SVN: r247062
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r-- | gcc/tree-ssa-structalias.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 77736f5..7b1bf10 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -4474,6 +4474,40 @@ find_func_aliases_for_builtin_call (struct function *fn, gcall *t) process_all_all_constraints (lhsc, rhsc); } return true; + /* Pure functions that return something not based on any object and + that use the memory pointed to by their arguments (but not + transitively). */ + case BUILT_IN_STRCMP: + case BUILT_IN_STRNCMP: + case BUILT_IN_STRCASECMP: + case BUILT_IN_STRNCASECMP: + case BUILT_IN_MEMCMP: + case BUILT_IN_BCMP: + case BUILT_IN_STRSPN: + case BUILT_IN_STRCSPN: + { + varinfo_t uses = get_call_use_vi (t); + make_any_offset_constraints (uses); + make_constraint_to (uses->id, gimple_call_arg (t, 0)); + make_constraint_to (uses->id, gimple_call_arg (t, 1)); + /* No constraints are necessary for the return value. */ + return true; + } + case BUILT_IN_STRLEN: + { + varinfo_t uses = get_call_use_vi (t); + make_any_offset_constraints (uses); + make_constraint_to (uses->id, gimple_call_arg (t, 0)); + /* No constraints are necessary for the return value. */ + return true; + } + case BUILT_IN_OBJECT_SIZE: + case BUILT_IN_CONSTANT_P: + { + /* No constraints are necessary for the return value or the + arguments. */ + return true; + } /* Trampolines are special - they set up passing the static frame. */ case BUILT_IN_INIT_TRAMPOLINE: |