]> git.ipfire.org Git - thirdparty/gcc.git/commit
Backported from trunk:
authorAaron Sawdey <acsawdey@linux.ibm.com>
Wed, 3 Mar 2021 00:06:37 +0000 (18:06 -0600)
committerAaron Sawdey <acsawdey@linux.ibm.com>
Thu, 17 Jun 2021 15:59:28 +0000 (10:59 -0500)
commitfb7327aa4ddb2fdb846c9b50b56f8c87dc37c8a2
tree0ae5fef11f7247a93ea1913be5c0491f98677c2d
parente86ad5ad011573121291bccb88d3a6fdb933469c
Backported from trunk:

Fusion patterns for add-logical/logical-add

This patch modifies the function in genfusion.pl for generating
the logical-logical patterns so that it can also generate the
add-logical and logical-add patterns which are very similar.

Also backported from trunk and combined with the add-logical patch
because that revealed problems on gcc-11.

Add needed earlyclobber to fusion patterns

The add-logical and add-add fusion patterns all have constraint
alternatives "=0,1,&r,r" for the output (3). The inputs 0 and 1
are used in the first fusion instruction and then either may be
reused as a temp for the output of the first insn which is
input to the second. However, if input 2 is the same as 0 or 1,
it gets clobbered unexpectedly. So the first 2 alts need to be
"=&0,&1,&r,r" instead to indicate that in alts 0 and 1, the
register used for 3 is earlyclobber, hence can't be the same as
input 2.

This was actually encountered in the backport of the add-logical
fusion patch to gcc-11. Some code in go hit this case:

   <runtime.fillAligned+520>:        andc r30,r30,r9
r30 now (~(x|((x&c)+c)))&(~c) --> this is new x
   <runtime.fillAligned+524>:        b <runtime.fillAligned+288>
   <runtime.fillAligned+288>:        addi r31,r31,-1
r31 now m-1
   <runtime.fillAligned+292>:        srd r31,r30,r31
r31 now x>>(m-1)
   <runtime.fillAligned+296>:        subf r30,r31,r30
r30 now x-(x>>(m-1))
   <runtime.fillAligned+300>:        or r30,r30,r30   # mdoom
nop
   <runtime.fillAligned+304>:        not     r3,r30
r3 now ~(x-(x>>(m-1))) -- WHOOPS

The or r30,r30,r30 was meant to be or-ing in the earlier value
of r30 which was overwritten by the output of the subf.

Combined ChangeLog (needed for the scripts to understand):

gcc/ChangeLog

* config/rs6000/genfusion.pl (gen_logical_addsubf): Refactor to
add generation of logical-add and add-logical fusion pairs.  Add
earlyclobber to alts 0/1.
(gen_addadd): Add earlyclobber to alts 0/1.
* config/rs6000/rs6000-cpus.def: Add new fusion to ISA 3.1 mask
and powerpc mask.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Turn on
logical-add and add-logical fusion by default.
* config/rs6000/rs6000.opt: Add -mpower10-fusion-logical-add and
-mpower10-fusion-add-logical options.
* config/rs6000/fusion.md: Regenerate file.

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/fusion-p10-logadd.c: New file.
gcc/config/rs6000/fusion.md
gcc/config/rs6000/genfusion.pl
gcc/config/rs6000/rs6000-cpus.def
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.opt
gcc/testsuite/gcc.target/powerpc/fusion-p10-logadd.c [new file with mode: 0644]