On Sun, Jun 10, 2012 at 4:16 PM, Marc Glisse <
marc.glisse@...> wrote:
> Hello,
>
> currently, tree-ssa-ifcombine handles pairs of imbricated "if"s that share
> the same then branch, or the same else branch. There is no particular reason
> why it couldn't also handle the case where the then branch of one is the
> else branch of the other, which is what I do here.
>
> Any comments?
The general idea looks good, but I think the patch is too invasive. As far
as I can see the only callers with a non-zero 'inv' argument come from
ifcombine_ifnotorif and ifcombine_ifnotandif (and both with inv == 2).
I would rather see a more localized patch that makes use of
invert_tree_comparison to perform the inversion on the call arguments
of maybe_fold_and/or_comparisons.
Is there any reason that would not work?
At least
+ if (inv & 1)
+ lcompcode2 = COMPCODE_TRUE - lcompcode2;
looks as if it were not semantically correct - you cannot simply invert
floating-point comparisons (see the restrictions invert_tree_comparison
has).
Thanks,
Richard.
>
> 2012-06-10 Marc Glisse <
marc.glisse@...>
>
> gcc/
> PR tree-optimization/51938
> * fold-const.c (combine_comparisons): Extra argument. Handle inverted
> conditions.
> (fold_truth_andor_1): Update call to combine_comparisons.
> * gimple-fold.c (swap12): New function.
> (and_comparisons_1): Extra argument. Handle inverted conditions.
> (and_var_with_comparison_1): Update call to and_comparisons_1.
> (maybe_fold_and_comparisons): Extra argument. Update call to
> and_comparisons_1.
> (or_comparisons_1): Extra argument. Handle inverted conditions.
> (or_var_with_comparison_1): Update call to or_comparisons_1.
> (maybe_fold_or_comparisons): Extra argument. Update call to
> or_comparisons_1.
> * tree-ssa-ifcombine.c (ifcombine_ifnotandif): New function.
> (ifcombine_ifnotorif): New function.
> (tree_ssa_ifcombine_bb): Call them.
> (ifcombine_iforif): Update call to maybe_fold_or_comparisons.
> (ifcombine_ifandif): Update call to maybe_fold_and_comparisons.
> * tree-ssa-reassoc.c (eliminate_redundant_comparison): Update calls
> to
> maybe_fold_or_comparisons and maybe_fold_and_comparisons.
> * tree-if-conv.c (fold_or_predicates): Update call to
> maybe_fold_or_comparisons.
> * gimple.h (maybe_fold_and_comparisons): Match gimple-fold.c
> prototype.
> (maybe_fold_or_comparisons): Likewise.
> * tree.h (combine_comparisons): Match fold-const.c prototype.
>
> gcc/testsuite/
> PR tree-optimization/51938
> * gcc.dg/tree-ssa/ssa-ifcombine-8.c: New testcase.
> * gcc.dg/tree-ssa/ssa-ifcombine-9.c: New testcase.
>
>
>
> --
> Marc Glisse