This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix simplify_subreg
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com
- Date: Sat, 8 Feb 2003 01:59:56 +0100
- Subject: Fix simplify_subreg
Hi,
this patch fixes small bug in conversion from vector into integer mode and adds
check for possible overflow and misscompilation when converting into TImode on
32bit target.
OK for 3.3/mainline?
Honza
Sat Feb 8 01:47:58 CET 2003 Jan Hubicka <jh@suse.cz>
* simplify-rtx.c (simplify_subreg): Fix conversion from vector into
integer mode.
Index: simplify-rtx.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.126.2.1
diff -c -3 -p -r1.126.2.1 simplify-rtx.c
*** simplify-rtx.c 1 Feb 2003 12:22:21 -0000 1.126.2.1
--- simplify-rtx.c 8 Feb 2003 00:47:46 -0000
*************** simplify_subreg (outermode, op, innermod
*** 2351,2363 ****
}
if (GET_CODE (elt) != CONST_INT)
return NULL_RTX;
high = high << shift | sum >> (HOST_BITS_PER_WIDE_INT - shift);
sum = (sum << shift) + INTVAL (elt);
}
if (GET_MODE_BITSIZE (outermode) <= HOST_BITS_PER_WIDE_INT)
return GEN_INT (trunc_int_for_mode (sum, outermode));
else if (GET_MODE_BITSIZE (outermode) == 2* HOST_BITS_PER_WIDE_INT)
! return immed_double_const (high, sum, outermode);
else
return NULL_RTX;
}
--- 2417,2432 ----
}
if (GET_CODE (elt) != CONST_INT)
return NULL_RTX;
+ /* Avoid overflow. */
+ if (high >> (HOST_BITS_PER_WIDE_INT - shift))
+ return NULL_RTX;
high = high << shift | sum >> (HOST_BITS_PER_WIDE_INT - shift);
sum = (sum << shift) + INTVAL (elt);
}
if (GET_MODE_BITSIZE (outermode) <= HOST_BITS_PER_WIDE_INT)
return GEN_INT (trunc_int_for_mode (sum, outermode));
else if (GET_MODE_BITSIZE (outermode) == 2* HOST_BITS_PER_WIDE_INT)
! return immed_double_const (sum, high, outermode);
else
return NULL_RTX;
}