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: fix rtl-opt/15289, part 4


> Final part, and the bit that actually fixes the bug.
>
> As promised, gen_realpart and gen_imagpart are gone.  I was pleasently
> surprised to find that these routines were only used in three places,
> which made replacing them fairly easy.
>
> The hardest part here, actually, was making sense of emit_move_insn_1.
> I wound up splitting out seven subroutines in order to help.

I'd like to raise the question of the appropriateness of applying these 
patches to the 3.4 branch at this stage: as far as I can see, they totally 
revamp the handling of complex numbers.

Are they really worth the risk before a .4 release?  Are you not concerned 
about potential ABI fallouts?  My experience with the SPARC back-end taught 
me that handling complexes can be really tricky and the code very fragile; 
moreover, there is the SPLIT_COMPLEX_ARG vs !SPLIT_COMPLEX_ARG split.


In either case, we found a problem in your change to expand_inline_function in 
integrate.c, which is not mentioned in the ChangeLog:

@@ -958,12 +958,12 @@
 	}
       else if (GET_CODE (loc) == REG)
 	process_reg_param (map, loc, copy);
-      else if (GET_CODE (loc) == CONCAT)
+      else if (GET_CODE (loc) == CONCAT && GET_CODE (copy) == CONCAT)
 	{
-	  rtx locreal = gen_realpart (GET_MODE (XEXP (loc, 0)), loc);
-	  rtx locimag = gen_imagpart (GET_MODE (XEXP (loc, 0)), loc);
-	  rtx copyreal = gen_realpart (GET_MODE (locreal), copy);
-	  rtx copyimag = gen_imagpart (GET_MODE (locimag), copy);
+	  rtx locreal = XEXP (loc, 0);
+	  rtx locimag = XEXP (loc, 1);
+	  rtx copyreal = XEXP (copy, 0);
+	  rtx copyimag = XEXP (copy, 1);
 
 	  process_reg_param (map, locreal, copyreal);
 	  process_reg_param (map, locimag, copyimag);

You can reproduce on x86 with:

../../xgcc -B../../ -c -O -gnatpgn  a-ncelfu.ads -o a-ncelfu.o

from the gcc/ada/rts directory.


We have:

(gdb) p debug_rtx(copy)
(mem/f:SC (symbol_ref/f:SI ("*.LC369") [flags 0x2] <complex_cst 0x56089348>) 
[0 S8 A32])
$1 = void
(gdb) p debug_rtx(loc)
(concat/u:SC (reg/v:SF 60 [ left ])
    (reg/v:SF 61 [ left+4 ]))

so we now abort line 972.  The attached patch is enough to fix the problem.
Bootstrapped/regtested (C, Ada) on i586-mandrake-linux-gnu.


2004-12-03  Eric Botcazou  <ebotcazou@adacore.com>

	* integrate.c (expand_inline_function): Accept again non-CONCAT arguments
	for CONCAT parameters and invoke read_complex_part on them.


-- 
Eric Botcazou
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/integrate.c,v
retrieving revision 1.244.2.2
diff -u -p -r1.244.2.2 integrate.c
--- integrate.c	2 Dec 2004 19:16:34 -0000	1.244.2.2
+++ integrate.c	3 Dec 2004 09:34:26 -0000
@@ -958,12 +958,12 @@ expand_inline_function (tree fndecl, tre
 	}
       else if (GET_CODE (loc) == REG)
 	process_reg_param (map, loc, copy);
-      else if (GET_CODE (loc) == CONCAT && GET_CODE (copy) == CONCAT)
+      else if (GET_CODE (loc) == CONCAT)
 	{
 	  rtx locreal = XEXP (loc, 0);
 	  rtx locimag = XEXP (loc, 1);
-	  rtx copyreal = XEXP (copy, 0);
-	  rtx copyimag = XEXP (copy, 1);
+	  rtx copyreal = read_complex_part (copy, false);
+	  rtx copyimag = read_complex_part (copy, true);
 
 	  process_reg_param (map, locreal, copyreal);
 	  process_reg_param (map, locimag, copyimag);

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