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] Fix invalid emit_move_insn calls in builtin expanders


Hello,

builtins.c occasionally calls emit_move_insn with a PLUS expression
that is not a general operand.  As far as I can see, this is not
supposed to work; and it does break on s390 when using a patch I'm
currently working on.

This patch changes the three locations in builtins.c to ensure
they only call emit_move_insn with general operands.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
OK for mainline?

Bye,
Ulrich

ChangeLog:

	* builtins.c (expand_builtin_strlen): Do not call emit_move_insn
	with a PLUS as source operand.
	(expand_movstr): Likewise.
	(expand_builtin_stpcpy): Likewise.



Index: gcc/builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.390
diff -c -p -r1.390 builtins.c
*** gcc/builtins.c	26 Sep 2004 19:15:00 -0000	1.390
--- gcc/builtins.c	29 Sep 2004 16:37:40 -0000
*************** expand_builtin_strlen (tree arglist, rtx
*** 2433,2440 ****
  
        /* Now that we are assured of success, expand the source.  */
        start_sequence ();
!       pat = memory_address (BLKmode,
! 			    expand_expr (src, src_reg, ptr_mode, EXPAND_SUM));
        if (pat != src_reg)
  	emit_move_insn (src_reg, pat);
        pat = get_insns ();
--- 2433,2439 ----
  
        /* Now that we are assured of success, expand the source.  */
        start_sequence ();
!       pat = expand_expr (src, src_reg, ptr_mode, EXPAND_NORMAL);
        if (pat != src_reg)
  	emit_move_insn (src_reg, pat);
        pat = get_insns ();
*************** expand_movstr (tree dest, tree src, rtx 
*** 3045,3052 ****
       terminator.  If the caller requested a mempcpy-like return value,
       adjust it.  */
    if (endp == 1 && target != const0_rtx)
!     emit_move_insn (target, plus_constant (gen_lowpart (GET_MODE (target),
! 							end), 1));
  
    return target;
  }
--- 3044,3053 ----
       terminator.  If the caller requested a mempcpy-like return value,
       adjust it.  */
    if (endp == 1 && target != const0_rtx)
!     {
!       rtx tem = plus_constant (gen_lowpart (GET_MODE (target), end), 1);
!       emit_move_insn (target, force_operand (tem, NULL_RTX));
!     }
  
    return target;
  }
*************** expand_builtin_stpcpy (tree arglist, rtx
*** 3156,3164 ****
  		  if (GET_MODE (target) != GET_MODE (ret))
  		    ret = gen_lowpart (GET_MODE (target), ret);
  
! 		  ret = emit_move_insn (target,
! 					plus_constant (ret,
! 						       INTVAL (len_rtx)));
  		  gcc_assert (ret);
  
  		  return target;
--- 3157,3164 ----
  		  if (GET_MODE (target) != GET_MODE (ret))
  		    ret = gen_lowpart (GET_MODE (target), ret);
  
! 		  ret = plus_constant (ret, INTVAL (len_rtx));
! 		  ret = emit_move_insn (target, force_operand (ret, NULL_RTX));
  		  gcc_assert (ret);
  
  		  return target;
-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


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