On Thu, Jan 23, 2025 at 7:43 AM Alexandre Oliva <[email protected]> wrote:
>
> On Jan 22, 2025, Alexandre Oliva <[email protected]> wrote:
>
> > I have another patch coming up that doesn't raise concerns for me, so
> > I'll hold off from installing the above, in case you also prefer the
> > other one.
>
> And here's an unrelated bit that came to mind while working on this, but
> that I split out before posting.
>
>
> Don't reject an ifcombine field-merging opportunity just because the
> left-hand operands aren't both reversed, if the second compare needs
> to be swapped for operands to match.
>
> Also mention that reversep does NOT affect the turning of range tests
> into bit tests.
>
> Regstrapped on x86_64-linux-gnu. Ok to install?
OK.
>
> for gcc/ChangeLog
>
> * gimple-fold.cc (fold_truth_andor_for_ifcombine): Document
> reversep's absence of effects on range tests. Don't reject
> reversep mismatches before trying compare swapping.
> ---
> gcc/gimple-fold.cc | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
> index 3c971a29ef045..da3f505c3fcac 100644
> --- a/gcc/gimple-fold.cc
> +++ b/gcc/gimple-fold.cc
> @@ -8090,8 +8090,9 @@ fold_truth_andor_for_ifcombine (enum tree_code code,
> tree truth_type,
> return 0;
> }
>
> - /* Prepare to turn compares of signed quantities with zero into
> - sign-bit tests. */
> + /* Prepare to turn compares of signed quantities with zero into sign-bit
> + tests. We need not worry about *_reversep here for these compare
> + rewrites: loads will have already been reversed before compares. */
> bool lsignbit = false, rsignbit = false;
> if ((lcode == LT_EXPR || lcode == GE_EXPR)
> && integer_zerop (lr_arg)
> @@ -8198,10 +8199,11 @@ fold_truth_andor_for_ifcombine (enum tree_code code,
> tree truth_type,
> the rhs's. If one is a load and the other isn't, we have to be
> conservative and avoid the optimization, otherwise we could get
> SRAed fields wrong. */
> - if (volatilep || ll_reversep != rl_reversep)
> + if (volatilep)
> return 0;
>
> - if (! operand_equal_p (ll_inner, rl_inner, 0))
> + if (ll_reversep != rl_reversep
> + || ! operand_equal_p (ll_inner, rl_inner, 0))
> {
> /* Try swapping the operands. */
> if (ll_reversep != rr_reversep
>
>
> --
> Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/
> Free Software Activist GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive