On Thu, 13 Mar 2025, Richard Sandiford wrote:

> Updates in v2:
> 
> - Make one of the pointer-arith-11.c scans require LP64, since
>   the constant is printed differently for ILP32, and would be
>   printed differently still for 16-bit targets.
> 
> - Avoid use of element_precision in scalar-only folds
> 
> - Use tree_int_cst_sgn instead of wi::to_widest.
> 
> Original message:
> 
> gcc.target/aarch64/sve/pr98119.c has been failing since r15-268.
> The test expects pointer alignment to be done with a plain AND,
> but that no longer happens.
> 
> It was combine that previously generated the ANDs, but I think it's
> fair to argue that it isn't combine's job to handle this case.
> The test's gimple output is pretty suboptimal.
> 
> The current gimple is:
> 
>   _21 = (unsigned long) vectp_x.4_22;
>   _20 = _21 >> 1;
>   _17 = (unsigned int) _20;
>   _16 = _17 & 15;
>   _9 = (sizetype) _16;
>   _18 = (unsigned int) _9;
>   _32 = _18 w* 2;
>   _33 = -_32;                        // -(_21 & 30)
>   vectp_x.6_10 = x_13(D) + _33;      // x_31(D) & ~30
>   _41 = 18446744073709551584 - _32;  // -32 - (_21 & 30)
>   vectp_x.9_38 = x_13(D) + _41;      // (x_31(D) - 32) & ~30
>   _55 = _16 + 1000;
> 
> This series adds two groups of folds that together give:
> 
>   _21 = (unsigned long) vectp_x.4_22;
>   _20 = _21 >> 1;
>   _17 = (unsigned int) _20;
>   _16 = _17 & 15;
>   vectp_x.6_10 = x_13(D) & -31B;
>   _18 = x_13(D) & -31B;
>   vectp_x.9_38 = _18 + 18446744073709551584;
>   _55 = _16 + 1000;
> 
> The duplicate "x_13(D) & -31B"s are unfortunate, but RTL CSE does get
> rid of them.
> 
> I asked on IRC whether new folds to fix this kind of regression were
> acceptable, but I admit that the patches ended up being bigger than
> I'd imagined.  I'll fully understand if they seem like too much for
> stage 4 after all.
> 
> Bootstrapped & regression-tested on aarch64-linux-gnu.  Also tested
> in its original form on x86_64-linux-gnu.  OK to install?

OK.

Thanks,
Richard.

> Richard
> 
> 
> Richard Sandiford (2):
>   match.pd: Fold ((X >> C1) & C2) * (1 << C1)
>   match.pd: Extend pointer alignment folds
> 
>  gcc/match.pd                                 | 55 +++++++++++++
>  gcc/testsuite/gcc.dg/fold-mul-and-lshift-1.c | 59 ++++++++++++++
>  gcc/testsuite/gcc.dg/fold-mul-and-lshift-2.c | 15 ++++
>  gcc/testsuite/gcc.dg/pointer-arith-11.c      | 39 ++++++++++
>  gcc/testsuite/gcc.dg/pointer-arith-12.c      | 82 ++++++++++++++++++++
>  5 files changed, 250 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.dg/fold-mul-and-lshift-1.c
>  create mode 100644 gcc/testsuite/gcc.dg/fold-mul-and-lshift-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/pointer-arith-11.c
>  create mode 100644 gcc/testsuite/gcc.dg/pointer-arith-12.c
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to