This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix gcc.dg/uninit-A.c on alpha
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 25 Oct 2003 21:00:49 -0600 (MDT)
- Subject: [PATCH] Fix gcc.dg/uninit-A.c on alpha
The following patch is a repost of my earlier patch "Promoted variable
SUBREG optimizations" which I posted back in August updated to current
mainline: http://gcc.gnu.org/ml/gcc-patches/2003-08/msg00568.html
As shown by Zack's misfortune earlier today, warnings that trigger on
some platforms and not others due to failings in GCC's middle-end can
lead to unpredictable instability. A patch which works perfectly on
one platform, can innocently cause a bootstrap failure on another.
The previous version of this patch has been tested with full bootstraps,
with default languages except Ada and regression testsuite runs on:
i686-pc-linux-gnu
alphaev67-dec-osf5.1
powerpc-ibm-axi5.2.0.0
ia64-unknown-linux-gnu
hppa2.0w-hp-hpux11.00
sparc-sun-solaris2.8
mips-sgi-irix6.5
To double check that nothing had changed in the meantime, I've just
finished retesting on i686-pc-linux-gnu with a full "make bootstrap",
all languages except treelang, and regression tested with a top-level
"make -k check" with no new failures.
Ok for mainline? Or can we at least reopen the discussion on why
SUBREG_PROMOTED_VAR_P may legitimately be used after initial RTL
expansion.
Many thanks in advance,
2003-10-25 Roger Sayle <roger@eyesopen.com>
* dojump.c (do_jump): If the expression being compared against
zero, is the subreg of a promoted variable, perform the comparison
in the promoted mode.
* simplify-rtx.c (simplify_unary_operation): Optimize sign and
zero-extensions of subregs of promoted variables where the
extension is identical to that used to promote the variable.
Index: dojump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dojump.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 dojump.c
*** dojump.c 20 Aug 2003 19:27:49 -0000 1.6
--- dojump.c 25 Oct 2003 21:10:19 -0000
*************** do_jump (tree exp, rtx if_false_label, r
*** 584,590 ****
{
/* The RTL optimizers prefer comparisons against pseudos. */
if (GET_CODE (temp) == SUBREG)
! temp = copy_to_reg (temp);
do_compare_rtx_and_jump (temp, CONST0_RTX (GET_MODE (temp)),
NE, TREE_UNSIGNED (TREE_TYPE (exp)),
GET_MODE (temp), NULL_RTX,
--- 584,597 ----
{
/* The RTL optimizers prefer comparisons against pseudos. */
if (GET_CODE (temp) == SUBREG)
! {
! /* Compare promoted variables in their promoted mode. */
! if (SUBREG_PROMOTED_VAR_P (temp)
! && GET_CODE (XEXP (temp, 0)) == REG)
! temp = XEXP (temp, 0);
! else
! temp = copy_to_reg (temp);
! }
do_compare_rtx_and_jump (temp, CONST0_RTX (GET_MODE (temp)),
NE, TREE_UNSIGNED (TREE_TYPE (exp)),
GET_MODE (temp), NULL_RTX,
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.163
diff -c -3 -p -r1.163 simplify-rtx.c
*** simplify-rtx.c 11 Oct 2003 21:06:15 -0000 1.163
--- simplify-rtx.c 25 Oct 2003 21:10:20 -0000
*************** simplify_unary_operation (enum rtx_code
*** 1028,1033 ****
--- 1028,1042 ----
&& GET_CODE (XEXP (XEXP (op, 0), 1)) == LABEL_REF)
return XEXP (op, 0);
+ /* Check for a sign extension of a subreg of a promoted
+ variable, where the promotion is sign-extended, and the
+ target mode is the same as the variable's promotion. */
+ if (GET_CODE (op) == SUBREG
+ && SUBREG_PROMOTED_VAR_P (op)
+ && ! SUBREG_PROMOTED_UNSIGNED_P (op)
+ && GET_MODE (XEXP (op, 0)) == mode)
+ return XEXP (op, 0);
+
#if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend)
if (! POINTERS_EXTEND_UNSIGNED
&& mode == Pmode && GET_MODE (op) == ptr_mode
*************** simplify_unary_operation (enum rtx_code
*** 1040,1047 ****
#endif
break;
- #if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend)
case ZERO_EXTEND:
if (POINTERS_EXTEND_UNSIGNED > 0
&& mode == Pmode && GET_MODE (op) == ptr_mode
&& (CONSTANT_P (op)
--- 1049,1065 ----
#endif
break;
case ZERO_EXTEND:
+ /* Check for a zero extension of a subreg of a promoted
+ variable, where the promotion is zero-extended, and the
+ target mode is the same as the variable's promotion. */
+ if (GET_CODE (op) == SUBREG
+ && SUBREG_PROMOTED_VAR_P (op)
+ && SUBREG_PROMOTED_UNSIGNED_P (op)
+ && GET_MODE (XEXP (op, 0)) == mode)
+ return XEXP (op, 0);
+
+ #if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend)
if (POINTERS_EXTEND_UNSIGNED > 0
&& mode == Pmode && GET_MODE (op) == ptr_mode
&& (CONSTANT_P (op)
*************** simplify_unary_operation (enum rtx_code
*** 1050,1057 ****
&& REG_POINTER (SUBREG_REG (op))
&& GET_MODE (SUBREG_REG (op)) == Pmode)))
return convert_memory_address (Pmode, op);
- break;
#endif
default:
break;
--- 1068,1075 ----
&& REG_POINTER (SUBREG_REG (op))
&& GET_MODE (SUBREG_REG (op)) == Pmode)))
return convert_memory_address (Pmode, op);
#endif
+ break;
default:
break;
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833