[gnu.gcc.bug] fold_rtx returns garbage for zero_extend:DI

cudcv@warwick.ac.uk (Rob McMahon) (09/28/88)

GCC 1.28, Gould PN6000

Given an expression like (*_extend:DI (reg:SI ...)) which reduces to something
like (*_extend:DI (const_int ...)) once constants have been substituted,
fold_rtx tries to do the extend itself with logical operations, putting the
resulting value in `val', and later passing this to `gen_rtx (CONST_INT,
VOIDmode, val)'.  It knows not to do the logical operations if the size of the
original mode (SImode here) is == the word size, but in this case it leaves
`val' uninitialised, and carries on through the rest of the logic.  If `val'
happens to contain a legitimate constant, a garbage value is returned.

Fix:

RCS file: cse.c,v
retrieving revision 1.9.1.1
diff -c -r1.9.1.1 cse.c
*** /tmp/,RCSt1a01125	Wed Sep 28 00:24:43 1988
--- cse.c	Wed Sep 28 00:10:31 1988
***************
*** 1852,1857 ****
--- 1852,1859 ----
  	      return x;
  	    if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_INT)
  	      val = arg0 & ~((-1) << GET_MODE_BITSIZE (mode));
+ 	    else
+ 	      val = arg0;
  	    break;
  	  }
  
***************
*** 1866,1871 ****
--- 1868,1875 ----
  		if (val & (1 << (GET_MODE_BITSIZE (mode) - 1)))
  		  val -= 1 << GET_MODE_BITSIZE (mode);
  	      }
+ 	    else
+ 	      val = arg0;
  	    break;
  	  }
  

Rob
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England