Bug 19708 - [4.0 Regression] does not fold "&int_cst->a" to just INT_CST
Summary: [4.0 Regression] does not fold "&int_cst->a" to just INT_CST
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2005-01-30 10:46 UTC by Alan Modra
Modified: 2005-02-09 22:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.4
Known to fail:
Last reconfirmed: 2005-01-30 14:08:31


Attachments
testcase (315 bytes, text/plain)
2005-01-30 10:47 UTC, Alan Modra
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2005-01-30 10:46:19 UTC
Found when attempting to compile powerpc64-linux glibc using current mainline gcc,
the attached cut-down testcase results in

tcboff.i: In function 'dummy':
tcboff.i:24: warning: asm operand 0 probably doesn't match constraints
tcboff.i:24: error: impossible constraint in 'asm'
Comment 1 Alan Modra 2005-01-30 10:47:36 UTC
Created attachment 8106 [details]
testcase
Comment 2 Andrew Pinski 2005-01-30 14:08:30 UTC
The problem is that we don't fold "&4294938544B->D.1116.header.multiple_threads" to the offset but 
I remember there was a reason why we don't.

The reason why this works in 3.4.4 is that we "fold' that in the front-end before getting anywhere.
Comment 3 Andrew Pinski 2005-01-30 14:14:49 UTC
The easiest fix would be to fold it in the front-end for all INT_CST's like the following with a slight 
comment fix above:
Index: c-typeck.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.415
diff -u -p -r1.415 c-typeck.c
--- c-typeck.c  29 Jan 2005 16:12:38 -0000      1.415
+++ c-typeck.c  30 Jan 2005 14:13:00 -0000
@@ -2683,7 +2683,7 @@ build_unary_op (enum tree_code code, tre
         when we have proper support for integer constant expressions.  */
       val = get_base_address (arg);
       if (val && TREE_CODE (val) == INDIRECT_REF
-         && integer_zerop (TREE_OPERAND (val, 0)))
+          && TREE_CODE (TREE_OPERAND (val, 0)) == INTEGER_CST)
        return fold_convert (argtype, fold_offsetof (arg));
 
       val = build1 (ADDR_EXPR, argtype, arg);
Comment 4 Andrew Pinski 2005-02-01 00:20:14 UTC
: Search converges between 2004-08-30-trunk (#529) and 2004-08-31-trunk (#530).
Comment 5 Richard Henderson 2005-02-09 22:18:32 UTC
Andrew, your patch is wrong; fold_offsetof assumes a zero base.

Alan, I have no particular interest in fixing this.  See how the 
alpha tcb-offsets.def file addresses this same problem.

If this turns out to be Absolutely Necessary, ie affects more than
just the nptl build, we can consider adding more hacks in this area
to accomodate, but at present I just don't think it's worth it.