This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ppc64 floating point usage [was Re: PPC64 Compiler bug !!]


On Fri, Jun 13, 2003 at 04:00:39PM -0400, David Edelsohn wrote:
> 	Have you tested the change in allocation order patch on floating
> point intensive code?

Janis has kindly run specfp tests.  And found a regression.  :-(

On looking at the code differences for the case with a slowdown, I
see 

 fctiwz 0,1
..
 stfd 0,128(1)
..
 ld 0,128(1)
..
 std 0,112(1)
 lwz 5,116(1)

Without the RS6000_ALT_REG_ALLOC_ORDER patch we generate:

 fctiwz 0,1
..
 stfd 0,112(1)
..
 lwz 5,116(1)

We have three of these sequences in the function.  On analyzing -da
dumps, for the slow case I see the fctiwz instruction being allocated a
gpr for its output, while the fast case gets an fpr.  Of course, with a
gpr we then require a reload, and optimization passes which run after
reload don't seem to be clever enough to see the useless moves to and
from memory.

Now it turns out that the register allocator isn't getting all the
information it needs to do a good job, because the fctiwz pattern tells
the allocator to ignore the fact that the output should be in a fpr.
David, you introduced this with

2002-07-03  David Edelsohn  <edelsohn@gnu.org>

	* config/rs6000/rs6000.md (fix_truncdfsi2_internal): Ignore DImode
	in FPR as preference.
	(fctiwz): Same.
	(floatdidf2, fix_truncdfdi2): Same.
	(floatdisf2, floatditf2, fix_trunctfdi2): Same.
	(floatditf2): Same.
	(floatsitf2, fix_trunctfsi2): SImode in GPR.
	(ctrdi): Remove FPR alternative and splitter.

Going back over gcc-patches archives, it appears that this was to fix
a reload problem.  (See [RFC PATCH] Fix middle-end/6963 from June and
July 2002.)  The good news is that the underlying reload problem is
fixed, I think.  I'm testing the following patch, which compiles the
testcase in http://gcc.gnu.org/ml/gcc-patches/2002-06/msg02214.html
without a problem, and things are looking good so far with regression
tests.

	* config/rs6000/rs6000.md (fctiwz): Don't ignore fpr preference.
	(floatdidf2, fix_truncdfdi2, floatdisf2_internal1): Likewise.
	(floatditf2, fix_trunctfdi2): Likewise.

Index: gcc/config/rs6000/rs6000.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.md,v
retrieving revision 1.264
diff -u -p -r1.264 rs6000.md
--- gcc/config/rs6000/rs6000.md	16 Jul 2003 11:52:51 -0000	1.264
+++ gcc/config/rs6000/rs6000.md	8 Aug 2003 06:52:44 -0000
@@ -5182,7 +5182,7 @@
 ; because the first makes it clear that operand 0 is not live
 ; before the instruction.
 (define_insn "fctiwz"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
 	(unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
 		   UNSPEC_FCTIWZ))]
   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
@@ -5197,7 +5197,7 @@
 
 (define_insn "floatdidf2"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
-	(float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
+	(float:DF (match_operand:DI 1 "gpc_reg_operand" "f")))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "fcfid %0,%1"
   [(set_attr "type" "fp")])
@@ -5233,7 +5233,7 @@
   "")
 
 (define_insn "fix_truncdfdi2"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
 	(fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "fctidz %0,%1"
@@ -5260,7 +5260,7 @@
 ;; from double rounding.
 (define_insn_and_split "floatdisf2_internal1"
   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
-        (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
+        (float:SF (match_operand:DI 1 "gpc_reg_operand" "f")))
    (clobber (match_scratch:DF 2 "=f"))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "#"
@@ -8342,7 +8342,7 @@
 
 (define_insn_and_split "floatditf2"
   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
-        (float:TF (match_operand:DI 1 "gpc_reg_operand" "*f")))
+        (float:TF (match_operand:DI 1 "gpc_reg_operand" "f")))
    (clobber (match_scratch:DF 2 "=f"))]
   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
@@ -8369,7 +8369,7 @@
   "")
 
 (define_insn_and_split "fix_trunctfdi2"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
         (fix:DI (match_operand:TF 1 "gpc_reg_operand" "f")))
    (clobber (match_scratch:DF 2 "=f"))]
   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Attachment: janis.c
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]