public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/27529] New: Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var
@ 2006-05-10 10:01 rguenth at gcc dot gnu dot org
2006-05-10 15:48 ` [Bug middle-end/27529] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-10 10:01 UTC (permalink / raw)
To: gcc-bugs
Fold does not fold two comparisons in a row if the intermediate type differs
in being a pointer vs. an integer variable. This also is the reason for not
folding (Foo *)(char *)foo with foo being of Foo& type (we can fold that to
(Foo *)foo).
There's code to do that I think, but it's just missing adjustment for pointers:
/* In addition to the cases of two conversions in a row
handled below, if we are converting something to its own
type via an object of identical or wider precision, neither
conversion is needed. */
if (TYPE_MAIN_VARIANT (inside_type) == TYPE_MAIN_VARIANT (type)
&& ((inter_int && final_int)
|| (inter_float && final_float))
&& inter_prec >= final_prec)
return fold_build1 (code, type, TREE_OPERAND (op0, 0));
I have a patch. Of course RTL doesn't care.
--
Summary: Does not fold (char *)(size_t)char_ptr or (size_t)(char
*)size_t_var
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P3
Component: middle-end
AssignedTo: rguenth at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27529
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/27529] Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var
2006-05-10 10:01 [Bug middle-end/27529] New: Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var rguenth at gcc dot gnu dot org
@ 2006-05-10 15:48 ` pinskia at gcc dot gnu dot org
2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-10 15:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-05-10 15:47 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-05-10 15:47:38
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27529
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/27529] Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var
2006-05-10 10:01 [Bug middle-end/27529] New: Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var rguenth at gcc dot gnu dot org
2006-05-10 15:48 ` [Bug middle-end/27529] " pinskia at gcc dot gnu dot org
@ 2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
2006-05-15 19:40 ` patchapp at dberlin dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-11 8:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2006-05-11 08:30 -------
Subject: Bug 27529
Author: rguenth
Date: Thu May 11 08:29:40 2006
New Revision: 113692
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113692
Log:
2006-05-11 Richard Guenther <rguenther@suse.de>
PR middle-end/27529
* fold-const.c (fold_unary): Handle intermediate conversion
to a pointer type like intermediate conversion to an integer
type in folding of (T1)(T2)var to var.
Match the code to the comment in the final conversion for
(T1)(T2)var to (T1)var regarding to type precision. Rather
than disallow T1 being of pointer type, assert that both T1
and var are of pointer type or not. Make sure not to fall
over the frontends lazyness wrt array to pointer decay though.
* gcc.dg/tree-ssa/foldcast-1.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27529
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/27529] Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var
2006-05-10 10:01 [Bug middle-end/27529] New: Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var rguenth at gcc dot gnu dot org
2006-05-10 15:48 ` [Bug middle-end/27529] " pinskia at gcc dot gnu dot org
2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
@ 2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
2006-05-15 19:40 ` patchapp at dberlin dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-11 8:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2006-05-11 08:30 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27529
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/27529] Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var
2006-05-10 10:01 [Bug middle-end/27529] New: Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var rguenth at gcc dot gnu dot org
` (2 preceding siblings ...)
2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
@ 2006-05-15 19:40 ` patchapp at dberlin dot org
3 siblings, 0 replies; 5+ messages in thread
From: patchapp at dberlin dot org @ 2006-05-15 19:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from patchapp at dberlin dot org 2006-05-15 19:39 -------
Subject: Bug number PR27529
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00415.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27529
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-05-15 19:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-10 10:01 [Bug middle-end/27529] New: Does not fold (char *)(size_t)char_ptr or (size_t)(char *)size_t_var rguenth at gcc dot gnu dot org
2006-05-10 15:48 ` [Bug middle-end/27529] " pinskia at gcc dot gnu dot org
2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
2006-05-11 8:30 ` rguenth at gcc dot gnu dot org
2006-05-15 19:40 ` patchapp at dberlin dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).