Bug 70131 - PowerPC ISA 2.07 is inefficient at doint (float)(int)x.
Summary: PowerPC ISA 2.07 is inefficient at doint (float)(int)x.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.0
: P3 enhancement
Target Milestone: ---
Assignee: Michael Meissner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-07 22:48 UTC by Michael Meissner
Modified: 2016-03-14 20:12 UTC (History)
2 users (show)

See Also:
Host:
Target: powerpc*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Proposed patch to fix the problem (1.29 KB, patch)
2016-03-11 22:43 UTC, Michael Meissner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meissner 2016-03-07 22:48:18 UTC
The current GCC compiler does not use the vupkhsw instruction that was introduced in ISA 2.07 (power8) to sign extend the 32-bit integer to 64-bit integer.  Instead it does a store and then a load to sign extend the value.

The code:

double foo (double x) { return (double)(int)x; }

generates the following code for power8:

        fctiwz 1,1
        addi 9,1,-16
        stfiwx 1,0,9
        ori 2,2,0
        lfiwax 1,0,9
        fcfid 1,1

It does this because 

It should generate something like:

        xscvdpsxws 33,1
        vupkhsw 1,1
        xxpermdi 33,33,33,2
        xscvsxddp 1,33
Comment 1 Michael Meissner 2016-03-11 22:43:38 UTC
Created attachment 37945 [details]
Proposed patch to fix the problem

Proposed patch to fix the problem.
Comment 2 Michael Meissner 2016-03-12 00:11:27 UTC
Author: meissner
Date: Sat Mar 12 00:10:54 2016
New Revision: 234155

URL: https://gcc.gnu.org/viewcvs?rev=234155&root=gcc&view=rev
Log:
[gcc]
2016-03-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/70131
	* config/rs6000/rs6000.md (round32<mode>2_fprs): Do not do the
	optimization if we have direct move.
	(roundu32<mode>2_fprs): Likewise.

[gcc/testsuite]
2016-03-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/70131
	* gcc.target/powerpc/ppc-round2.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/ppc-round2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.md
    trunk/gcc/testsuite/ChangeLog
Comment 3 Michael Meissner 2016-03-14 18:07:16 UTC
Author: meissner
Date: Mon Mar 14 18:06:45 2016
New Revision: 234186

URL: https://gcc.gnu.org/viewcvs?rev=234186&root=gcc&view=rev
Log:
[gcc]
2016-03-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/70131
	* config/rs6000/rs6000.md (round32<mode>2_fprs): Do not do the
	optimization if we have direct move.
	(roundu32<mode>2_fprs): Likewise.

[gcc/testsuite]
2016-03-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/70131
	* gcc.target/powerpc/ppc-round2.c: New test.


Added:
    branches/gcc-5-branch/gcc/testsuite/gcc.target/powerpc/ppc-round2.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/config/rs6000/rs6000.md
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 4 Michael Meissner 2016-03-14 18:19:17 UTC
Author: meissner
Date: Mon Mar 14 18:18:45 2016
New Revision: 234188

URL: https://gcc.gnu.org/viewcvs?rev=234188&root=gcc&view=rev
Log:
[gcc]
2016-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	Backport from mainline
	2016-03-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/70131
	* config/rs6000/rs6000.md (round32<mode>2_fprs): Do not do the
	optimization if we have direct move.
	(roundu32<mode>2_fprs): Likewise.

2016-03-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	Backport from mainline
	2016-03-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR target/62281
	* config/i386/sol2.h (STACK_REALIGN_DEFAULT): Define.

2016-03-10  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>

	PR target/70168
	* config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap):
	Handle overlapping retval and newval.

[gcc/testsuite]
2016-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	Backport from mainline
	2016-03-11  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/70131
	* gcc.target/powerpc/ppc-round2.c: New test.

2016-03-14  Dominique d'Humieres  <dominiq@lps.ens.fr>

	PR fortran/45076
	gfortran.dg/prof/prof.exp: New script.
	gfortran.dg/prof/dynamic_dispatch_6.f03: New test.


Added:
    branches/ibm/gcc-5-branch/gcc/testsuite/gcc.target/powerpc/ppc-round2.c
      - copied unchanged from r234186, branches/gcc-5-branch/gcc/testsuite/gcc.target/powerpc/ppc-round2.c
    branches/ibm/gcc-5-branch/gcc/testsuite/gfortran.dg/prof/
      - copied from r234186, branches/gcc-5-branch/gcc/testsuite/gfortran.dg/prof/
Modified:
    branches/ibm/gcc-5-branch/gcc/ChangeLog
    branches/ibm/gcc-5-branch/gcc/DATESTAMP
    branches/ibm/gcc-5-branch/gcc/config/i386/sol2.h
    branches/ibm/gcc-5-branch/gcc/config/rs6000/rs6000.c
    branches/ibm/gcc-5-branch/gcc/config/rs6000/rs6000.md
    branches/ibm/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 5 Michael Meissner 2016-03-14 20:12:46 UTC
Fixed in the trunk on svn id 234155, gcc-5-branch on svn id 234186.