This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
combine.c (simplify_logical, case AND): Only call ...
- To: egcs-patches at egcs dot cygnus dot com
- Subject: combine.c (simplify_logical, case AND): Only call ...
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Mon, 14 Jun 1999 13:14:35 -0700
This fixes a bug that showed up in a 32 bit hosted cross compiler to a 64 bit
target.
Combine converted
x = (and:DI (ashiftrt:DI (ashift:DI (subreg:DI (reg:SI 336) 0)
(const_int 32))
(const_int 32))
(const_int -0x80000000))
to
(and:DI (subreg:DI (reg:SI 336) 0) (const_int -0x80000000))
which is wrong, because the sign-extension of (reg:SI 336) has been lost.
Mon Jun 14 12:57:38 1999 David Mosberger <davidm@hpl.hp.com>
* combine.c (simplify_logical, case AND): Only call
simplify_and_const_int if the mode is no wider than HOST_WIDE_INT
or the constant is positive.
Index: combine.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/combine.c,v
retrieving revision 1.62
diff -p -r1.62 combine.c
*** combine.c 1999/03/25 16:54:31 1.62
--- combine.c 1999/06/14 20:05:35
*************** simplify_logical (x, last)
*** 4902,4908 ****
&& ! side_effects_p (op1))
x = gen_binary (AND, mode, XEXP (XEXP (op0, 0), 0), op1);
! if (GET_CODE (op1) == CONST_INT)
{
x = simplify_and_const_int (x, mode, op0, INTVAL (op1));
--- 4902,4913 ----
&& ! side_effects_p (op1))
x = gen_binary (AND, mode, XEXP (XEXP (op0, 0), 0), op1);
! /* We can call simplify_and_const_int only if we don't lose
! any (sign) bits when converting INTVAL (op1) to
! "unsigned HOST_WIDE_INT". */
! if (GET_CODE (op1) == CONST_INT
! && (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
! || INTVAL (op1) > 0))
{
x = simplify_and_const_int (x, mode, op0, INTVAL (op1));