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]

[PATCH] Use emit_move_insn to move complex parts


The following patch fixes some testsuite regressions recently observed
by Kazu Hirata on h8300 and by Eric Christopher on mips64, that were
recently introduced by "Extracting components of complex constants"
patch: http://gcc.gnu.org/ml/gcc-patches/2003-05/msg02224.html

It turns out that now we do a better job of getting the rtx of a
complex component out of the constant pool, we trip over a latent
bug in emit_move_insn that doesn't place the floating point constant
back in the constant pool.  The current usage of mov_optab doesn't
validate that its operand is valid/recognized by the machine
description.  Swithing to using emit_move_insn both fixes this
problem, and also provides REG_EQUAL notes that help the RTL
optimizers do their thing.

The use of GEN_FCN (mov_optabs... ) predates the current CVS
repository.  There should be no problems with unbounded recursion
as emit_move_insn is decomposing the task into smaller sub-moves.


The following has been tested on i686-pc-linux-gnu with a complete
bootstrap, all languages except treelang, and regression tested
with a top-level "make -k check" with no new failures.  I've confirmed
that this fixes the reported ICE in a cc1 cross-compiler to h8300-hms,
and many thanks to Kazu for confirming that this patch fixes all of
the H8300 test suite regressions without introducing any new failures.

Ok for mainline?



2003-06-03  Roger Sayle  <roger@eyesopen.com>

	* expr.c (emit_move_insn_1): Use emit_move_insn to move the parts
	of a complex number rather than invoke mov_optab directly.


Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.544
diff -c -3 -p -r1.544 expr.c
*** expr.c	30 May 2003 17:49:44 -0000	1.544
--- expr.c	3 Jun 2003 01:54:55 -0000
*************** emit_move_insn_1 (x, y)
*** 3314,3332 ****
  	  /* Note that the real part always precedes the imag part in memory
  	     regardless of machine's endianness.  */
  #ifdef STACK_GROWS_DOWNWARD
! 	  emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
! 		     (gen_rtx_MEM (submode, XEXP (x, 0)),
! 		      gen_imagpart (submode, y)));
! 	  emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
! 		     (gen_rtx_MEM (submode, XEXP (x, 0)),
! 		      gen_realpart (submode, y)));
  #else
! 	  emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
! 		     (gen_rtx_MEM (submode, XEXP (x, 0)),
! 		      gen_realpart (submode, y)));
! 	  emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
! 		     (gen_rtx_MEM (submode, XEXP (x, 0)),
! 		      gen_imagpart (submode, y)));
  #endif
  	}
        else
--- 3314,3328 ----
  	  /* Note that the real part always precedes the imag part in memory
  	     regardless of machine's endianness.  */
  #ifdef STACK_GROWS_DOWNWARD
! 	  emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
! 			  gen_imagpart (submode, y));
! 	  emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
! 			  gen_realpart (submode, y));
  #else
! 	  emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
! 			  gen_realpart (submode, y));
! 	  emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
! 			  gen_imagpart (submode, y));
  #endif
  	}
        else
*************** emit_move_insn_1 (x, y)
*** 3401,3410 ****
  		  || GET_CODE (imagpart_x) == SUBREG))
  	    emit_insn (gen_rtx_CLOBBER (VOIDmode, x));

! 	  emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
! 		     (realpart_x, realpart_y));
! 	  emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
! 		     (imagpart_x, imagpart_y));
  	}

        return get_last_insn ();
--- 3397,3404 ----
  		  || GET_CODE (imagpart_x) == SUBREG))
  	    emit_insn (gen_rtx_CLOBBER (VOIDmode, x));

! 	  emit_move_insn (realpart_x, realpart_y);
! 	  emit_move_insn (imagpart_x, imagpart_y);
  	}

        return get_last_insn ();

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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