Bug 48440 - [4.7 Regression] FAIL: gcc.c-torture/compile/labels-3.c
Summary: [4.7 Regression] FAIL: gcc.c-torture/compile/labels-3.c
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-04 21:58 UTC by H.J. Lu
Modified: 2011-10-10 11:44 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-04-04 21:58:17 UTC
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.
Comment 1 H.J. Lu 2011-04-04 22:05:30 UTC
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;
Comment 2 H.J. Lu 2011-04-04 22:15:54 UTC
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.
Comment 3 H.J. Lu 2011-04-05 00:51:43 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00281.html
Comment 4 Richard Biener 2011-04-05 11:02:50 UTC
-  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.
Comment 5 hjl@gcc.gnu.org 2011-04-08 00:23:05 UTC
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
Comment 6 Richard Biener 2011-10-10 11:44:14 UTC
Invalid thus.