[PATCH] PR target/65240, Fix Power{7,8} insn constraint issue with -O3 -ffast-math

David Edelsohn dje.gcc@gmail.com
Wed Mar 11 17:02:00 GMT 2015


On Thu, Mar 5, 2015 at 3:06 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> This patch fixes PR 65240, which was a latent bug that was introduced when I
> added the -mupper-regs support to the PowerPC compiler.  In the PowerPC
> compiler, if you use -ffast-math, the compiler allows floating point constants
> in move RTLs until register allocation time, in order to allow the
> optimizations that replace division by a constant with multiplication by the
> reciprocal.  If the register being loaded up is a traditional Altivec register,
> the load will fail, since there is no D-FORM (register+offset) addressing mode
> for the traditional altivec registers.
>
> I had had a define_split to try and handle this situation, but it didn't work
> all of the time.  I rewrote the insns, so there is an UNSPEC in it to prevent
> over optimization.
>
> I have done bootstrap builds and make check's on both a big endian power7
> system, and a little endian power8 system with no regressions in the tests.  I
> have also built both power7 and power8 spec 2006 (v5) versions, and Spec
> built.  I have run the Spec floating point tests on a power7 box, and all of
> the tests performed about at the same speed as before the bug fix was done,
> with the exception of gromacs, which is 4% faster with the fix.
>
> Looking at the static instruction counts, the big change is to fold the addi
> instruction into the load of the constant if it is loading the value to a
> traditional floating point register (previously, it would load up the constant
> with addis/addi and then do an indirect load).  I do see other instructions
> change, including a few more floating point loads, but with the exception of
> gromacs, most of the changes are in the noise level.
>
> Is this ok to install into the trunk?  At present, it is not needed for GCC
> 4.9, since that branch does not have the -mupper-regs support.
>
> [gcc]
> 2015-03-05  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         PR target/65240
>         * config/rs6000/rs6000.md (UNSPEC_FUSION_FP_CONSTANT): New unspec.
>         (Vsx_load): New mode attribute to give appropriate VSX load
>         instruction.
>         (move floating point constant define_split): Use an UNSPEC to make
>         sure that the load of the constant is kept as a memory address,
>         instead of being converted back into a move of the constant.
>         (load_<mode>_constant): Likewise.
>
> [gcc/testsuite]
> 2015-03-05  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         PR target/65240
>         * gcc.target/powerpc/pr65240.c: New test.

I am concerned with the create_TOC_reference use for TARGET_TOC.  Has
this been tested with big endian -mcmodel=small?

Thanks, David



More information about the Gcc-patches mailing list