Just a trivial cleanup from Martin's work. if (x == CONST) do something; else return value;
Turns into if (x != CONST) return value; do something; Again no behavior changes, but makes it easier to find the nuggets in the rest of Martin's work. Bootstrapped, regression tested on x86_64 and installed on the trunk. jeff ps. We're just about done with this stuff :-) The holidays are both a blessing and a curse when it comes to wrapping up something like this...
commit 0d90d6a22287cecf0c509336005cfd6c27560c67 Author: Jeff Law <l...@torsion.usersys.redhat.com> Date: Fri Dec 21 14:23:49 2018 -0500 * gimple-fold.c (get_range_strlen): Minor logic cleanup. Add comments on code's intent. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1ee865e1de8..54585381cbe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,9 @@ 2018-12-30 Martin Sebor <mse...@redhat.com> Jeff Law <l...@redhat.com> + * gimple-fold.c (get_range_strlen): Minor logic cleanup. Add comments + on code's intent. + * gimple-fold.c (strlen_range_kind): New enum. (get_range_strlen): Update signature to use strlen_range_kind instead of type+fuzzy. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 76fa328703c..fb43552bc35 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1548,10 +1548,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, if (!get_range_strlen (ops[i], length, visited, rkind, flexp, eltsize, nonstr)) { - if (rkind == SRK_LENRANGE_2) - *maxlen = build_all_ones_cst (size_type_node); - else + if (rkind != SRK_LENRANGE_2) return false; + /* Set the upper bound to the maximum to prevent + it from being adjusted in the next iteration but + leave MINLEN and the more conservative MAXBOUND + determined so far alone (or leave them null if + they haven't been set yet). That the MINLEN is + in fact zero can be determined from MAXLEN being + unbounded but the discovered minimum is used for + diagnostics. */ + *maxlen = build_all_ones_cst (size_type_node); } return true; } @@ -1576,10 +1583,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, if (!get_range_strlen (arg, length, visited, rkind, flexp, eltsize, nonstr)) { - if (rkind == SRK_LENRANGE_2) - *maxlen = build_all_ones_cst (size_type_node); - else + if (rkind != SRK_LENRANGE_2) return false; + /* Set the upper bound to the maximum to prevent + it from being adjusted in the next iteration but + leave MINLEN and the more conservative MAXBOUND + determined so far alone (or leave them null if + they haven't been set yet). That the MINLEN is + in fact zero can be determined from MAXLEN being + unbounded but the discovered minimum is used for + diagnostics. */ + *maxlen = build_all_ones_cst (size_type_node); } } return true;