This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
bug in cse.c
- From: Leehod Baruch <LEEHOD at il dot ibm dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Mircea Namolaru <NAMOLARU at il dot ibm dot com>, Ayal Zaks <ZAKS at il dot ibm dot com>, MustafA at il dot ibm dot com
- Date: Tue, 28 Sep 2004 19:36:53 +0200
- Subject: bug in cse.c
Hello,
There is a bug in the cse.c
In the pattern:
(insn 1288 532 1289 14 (set (reg:DI 558)
(zero_extend:DI (reg:QI 556))) -1 (nil)
(nil))
(insn 1289 1288 1264 14 (set (reg:SI 839)
(subreg:SI (reg:DI 558) 0)) -1 (nil)
(nil))
the register 839 was mistakably analyzed as equal to const_int 0.
The high subreg of register 558 is really a const_int 0 but the
low subreg is not.
The reason for this mistake is that the analysis didn't take into
account that the computer may use the big Endean method.
Here is a proposal of how to fix this:
(Bootstrapped on POWER4)
*** cse.c 2004-09-28 20:01:00.000000000 -0500
--- cse.c 2004-09-27 13:53:05.000000000 -0500
*************** fold_rtx (rtx x, rtx insn)
*** 3404,3424 ****
this transformation may be moved to simplify_subreg. */
for (; elt; elt = elt->next_same_value)
{
! if (GET_CODE (elt->exp) == ZERO_EXTEND)
! {
! if (BYTES_BIG_ENDIAN)
! {
! int ze_offset = (BITS_PER_WORD - GET_MODE_BITSIZE
(GET_MODE (XEXP (elt->exp, 0))));
! if (ze_offset < 0)
! ze_offset = 0;
! if ((subreg_lsb (x) + GET_MODE_BITSIZE (GET_MODE
(x)))
! <= (unsigned int) ze_offset)
! return CONST0_RTX (mode);
! }
! else if (subreg_lsb (x)
! >= GET_MODE_BITSIZE (GET_MODE (XEXP
(elt->exp, 0))))
! return CONST0_RTX (mode);
! }
}
}
--- 3404,3413 ----
this transformation may be moved to simplify_subreg. */
for (; elt; elt = elt->next_same_value)
{
! if (GET_CODE (elt->exp) == ZERO_EXTEND
! && subreg_lsb (x)
! >= GET_MODE_BITSIZE (GET_MODE (XEXP (elt->exp,
0))))
! return CONST0_RTX (mode);
}
}