On Tue, Aug 20, 2019 at 10:37 AM Robin Dapp <[email protected]> wrote:
>
> > So - which case is it? IIRC we want to handle small signed
> > constants but the code can end up unsigned. For the
> > above we could write (unsigned long)((int)a + 1 - 1) and thus
> > sign-extend? Or even avoid this if we know the range.
> > That is, it becomes the first case again (operation performed
> > in a smaller type).
>
> Both :) But in order to move forward the second transform suffices to
> get rid of the redundant subtraction/addition of the ivopts candidate.
>
> Attached is a new version as single file that disregards the other
> possible cases (3/3 from before), only performs this transform and
> checks for gimple_simplified in vrp2 after ivopts now.
gimple_set_modified (stmt, true);
}
+ /* Also fold if we want to fold all statements. */
+ if (!did_replace && substitute_and_fold_engine->fold_all_stmts
+ && fold_stmt (&i, follow_single_use_edges))
+ {
+ did_replace = true;
+ stmt = gsi_stmt (i);
+ gimple_set_modified (stmt, true);
make it
} else if (substitute_and_fold_engine->fold_all_stmts
&& fold_stmt (&...
also please make initialization of fold_all_stmts via
a new constructor argument defaulted to false and
elide the set_fold_all_stmts method.
Are the various testcase adjustments still needed
(-fno-tree-ccp, etc.)? I guess not.
+ && int_fits_type_p (@1, TREE_TYPE (@0)))
while this properly guards against bogus truncation
of @1 I think it says false to -1ul fitting int. So
we wouldn't handle (unsigned long)intvar + -1ul.
But it's conservatively correct for now. Eventually
changing it to wi::min_precision (wi::to_wide (@1),
TYPE_SIGN (TREE_TYPE (@0))) <= TYPE_PRECISION (TREE_TYPE (@0))
might work for that special case.
> Bootstrapped, no regressions on s390 and x86.
OK with the first suggested change and the testcase changes
audited. We can do the rest as followup.
Thanks,
Richard.
> Regards
> Robin