Fix multi-word add case in expand_binop

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Tue Apr 15 13:09:00 GMT 2003


This causes miscompilation of the following test case on Alpha Unix.

Tested on i686-pc-linux-gnu.

package Ranges is
 
   pragma Elaborate_Body;
 
   type Base_Range_T is  range 0 .. 32;
   function Range_Limit return Base_Range_T;
   procedure Dump (I : Integer);
end Ranges;
 
with Ada.Text_IO; use Ada.Text_IO;
package body Ranges is
 
   procedure Dump (I : Integer) is
   begin
      Put_Line (Integer'Image (I));
   end;

   function Range_Limit return Base_Range_T is begin return 20; end;
end Ranges;
 
with Ranges; use Ranges;
procedure P is
 
   type Array_T is array (0 .. Range_limit) of Integer;
 
   type Descriptor_T (Is_Complete : Boolean := True) is record
      case Is_Complete is
	 when True =>
	    A : Array_T;
	 when False =>
	    null;
      end case;
   end record;
 
   X : Integer;
begin
   X := Descriptor_T'Size;
   Dump (X);
end;

Thu Jan 16 19:01:51 2003  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* optabs.c (expand_binop): In multi-word add cases, ensure
	XTARGET is copied to TARGET if they are different.

*** gcc/optabs.c	9 Apr 2003 17:50:08 -0000	1.169
--- gcc/optabs.c	11 Apr 2003 21:58:27 -0000
*************** expand_binop (mode, binoptab, op0, op1, 
*** 1300,1304 ****
        if (i == GET_MODE_BITSIZE (mode) / (unsigned) BITS_PER_WORD)
  	{
! 	  if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  	    {
  	      rtx temp = emit_move_insn (target, xtarget);
--- 1300,1305 ----
        if (i == GET_MODE_BITSIZE (mode) / (unsigned) BITS_PER_WORD)
  	{
! 	  if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing
! 	      || ! rtx_equal_p (target, xtarget))
  	    {
  	      rtx temp = emit_move_insn (target, xtarget);



More information about the Gcc-patches mailing list