Revision 171903: http://gcc.gnu.org/ml/gcc-cvs/2011-04/msg00095.html breaks gcc.c-torture/compile/labels-3.c for targets where Pmode == DImode and ptr_mode == SImode like x32. Revert * cgraphbuild.c (record_reference): Canonicalize constructor values. fixes the regression.
The record_reference change remove the cast, which is needed for Pmode != ptr_mode: diff -upr bad/x.i.143r.expand good/x.i.143r.expand --- bad/x.i.143r.expand 2011-04-04 15:02:05.652458274 -0700 +++ good/x.i.143r.expand 2011-04-04 15:02:55.233678782 -0700 @@ -5,7 +5,7 @@ foo (int a) { void * gotovar.0; void * p; - static const short int ar[2] = {0, (short unsigned int) &l2 - (short unsigned int) &l1}; + static const short int ar[2] = {0, (short int) ((short unsigned int) (int) &l2 - (short unsigned int) (int) &l1)}; int D.2689; unsigned int D.2688; const short int D.2687; @@ -105,7 +105,7 @@ foo (int a) { void * gotovar.0; void * p; - static const short int ar[2] = {0, (short unsigned int) &l2 - (short unsigned int) &l1}; + static const short int ar[2] = {0, (short int) ((short unsigned int) (int) &l2 - (short unsigned int) (int) &l1)}; int D.2689; unsigned int D.2688; const short int D.2687;
This patch: diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index 3948cf6..c80d7ab 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -56,7 +56,10 @@ record_reference (tree *tp, int *walk_subtrees, void *data) t = canonicalize_constructor_val (t); if (!t) t = *tp; - else if (t != *tp) + else if (t != *tp + && !(Pmode != ptr_mode + && TREE_CODE (t) == ADDR_EXPR + && TREE_CODE (*tp) == CONVERT_EXPR)) *tp = t; switch (TREE_CODE (t)) seems to work.
A patch is posted at http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00281.html
- static const short int ar[2] = {0, (short unsigned int) &l2 - (short unsigned int) &l1}; + static const short int ar[2] = {0, (short int) ((short unsigned int) (int) &l2 - (short unsigned int) (int) &l1)}; this transformation is completely reasonable for any pointer size. The bug must be elsewhere and latent.
Author: hjl Date: Fri Apr 8 00:23:02 2011 New Revision: 172156 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172156 Log: Properly get inner mode for constant op0. 2011-04-06 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/48440 * expr.c (expand_expr_real_2): Get inner mode from op0 instead of treeop0 for constant op0. Modified: branches/x32/gcc/ChangeLog.x32 branches/x32/gcc/expr.c
Invalid thus.