[PATCH] hppa: Improve expansion of ashldi3 when !TARGET_64BIT

Roger Sayle roger@nextmovesoftware.com
Wed Aug 26 21:23:06 GMT 2020


The failure of slsr-13.c is not caused by the patchh3.txt, but the previous patchh2.txt
that's now on mainline and the gcc-10 branch.  That change provided more accurate
rtx_costs for hppa, and solved the performance problems with synth_mult.

These more accurate target rtx_costs are used by the gimple-ssa-strength-reduction.c
(via a call to mult_by_coeff_cost) to decide whether applying strength reduction would
be profitable.  This test case, slsr-13.c, assumes that two multiplications by four are
cheaper than two multiplications by five.   (I believe) This is not the case on hppa which
has a sh2add instruction, that performs a multiplication by five in one cycle, or exactly
the same cost as performing a left shift by two (i.e. a multiplication by four).  Oddly, I
also believe this isn't the case on x86_64, where the similar lea instruction is (sometimes)
as efficient as left shift by two bits.

I suspect that slsr-13.c should be expected to fail on some platforms depending upon 
a targets instruction set/timings.

Unfortunately, to complicate things in our case, it appears that after RTL optimizations,
performing this strength reduction actually does results in fewer instructions on the PA,
so it's the right thing to do.  I'll need to study the logic in gimple-ssa-strength to see
how mult_by_coeff cost is being used; cost(x*4) == cost(x*5), but cost(x*4+y) < cost(x*5+y).

My apologies for the inconvenience.

Roger
--

-----Original Message-----
From: John David Anglin <dave.anglin@bell.net> 
Sent: 26 August 2020 21:34
To: law@redhat.com; Roger Sayle <roger@nextmovesoftware.com>; 'GCC Patches' <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] hppa: Improve expansion of ashldi3 when !TARGET_64BIT

On 2020-08-26 4:08 p.m., Jeff Law wrote:
> It 3-stages, but trips:
> Tests that now fail, but worked before (5 tests):
>
> gcc.dg/tree-ssa/slsr-13.c scan-tree-dump-times optimized " \\* 4" 2 
> gcc.dg/tree-ssa/slsr-13.c scan-tree-dump-times optimized " \\* 4" 2 
> gcc.dg/tree-ssa/slsr-13.c scan-tree-dump-times optimized " \\* 5" 0 
> gcc.dg/tree-ssa/slsr-13.c scan-tree-dump-times optimized " \\* 5" 0
In my last Linux build, these failed:

FAIL: gcc.dg/tree-ssa/slsr-13.c scan-tree-dump-times optimized " \\\\* 4" 2
FAIL: gcc.dg/tree-ssa/slsr-13.c scan-tree-dump-times optimized " \\\\* 5" 0

The above didn't include patchh3.txt.  Seems to be a difference in quoting.  I'll check.
Linux build is close to running this test.

These tests didn't fail on 32-bit hpux without patchh2.txt or in previous Linux build.

Dave

--
John David Anglin  dave.anglin@bell.net




More information about the Gcc-patches mailing list