On 12/18/2017 02:45 PM, Jakub Jelinek wrote:
> Hi!
>
> As the testcase shows, we fold strlen (str) == 0 into *str == 0 before
> the strlen pass has a chance to optimize. The following patch optimizes
> loads from the known termination '\0' into lhs = '\0' and loads from the
> part of the string known to be non-zero results in ~[0, 0] range being
> recorded if we don't have anything better.
>
> Note that unfortunately vrp2 doesn't consider any memory loads as
> interesting, even when they have non-varying ranges from other passes,
> but guess that is something to improve later.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-12-18 Jakub Jelinek <ja...@redhat.com>
>
> PR tree-optimization/83444
> * tree-ssa-strlen.c (strlen_check_and_optimize_stmt): Optimize
> character loads.
>
> * gcc.dg/strlenopt-36.c: New test.
OK.
jeff