public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing
@ 2008-10-18 18:17 edwintorok at gmail dot com
2008-10-18 18:30 ` [Bug tree-optimization/37868] code that " sabre at nondot dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: edwintorok at gmail dot com @ 2008-10-18 18:17 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]
+++ This bug was initially created as a clone of Bug #37867 +++
Cloning bug on Chris's request.
Running gcc-4.3 -O2 on PR1386.c I get different results than with -O1.
$ gcc-4.3 -O1 PR1386.c && ./a.out
PR1386.c: In function main:
PR1386.c:15: warning: large integer implicitly truncated to unsigned type
PR1386.c:17: warning: large integer implicitly truncated to unsigned type
bad bits: 0
$ gcc-4.3 -O2 PR1386.c && ./a.out
PR1386.c: In function main:
PR1386.c:15: warning: large integer implicitly truncated to unsigned type
PR1386.c:17: warning: large integer implicitly truncated to unsigned type
bad bits: fffffffffffffff0
$ g++-4.3 -O2 -fno-strict-aliasing x.c
x.c: In function int main():
x.c:15: warning: large integer implicitly truncated to unsigned type
x.c:17: warning: large integer implicitly truncated to unsigned type
edwin@debian:~$ ./a.out
bad bits: fffffffffffffff0
--
Summary: code that doesn't breaks TBAA is misoptimized even with
-fno-strict-aliasing
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: edwintorok at gmail dot com
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
@ 2008-10-18 18:30 ` sabre at nondot dot org
2008-10-18 18:58 ` rguenth at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2008-10-18 18:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sabre at nondot dot org 2008-10-18 18:29 -------
Here is the testcase. I should work with -fno-strict-aliasing:
#include <stdio.h>
#include <stdint.h>
struct X {
unsigned char pad : 4;
uint64_t a : 64;
uint64_t b : 60;
} __attribute__((packed));
int main (void)
{
struct X x;
uint64_t bad_bits;
x.pad = 255;
x.a = -1ULL;
x.b = -1ULL;
bad_bits = ((uint64_t)-1ULL) ^ *(1+(uint64_t *) &x);
printf("bad bits: %llx\n", bad_bits);
return bad_bits != 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
2008-10-18 18:30 ` [Bug tree-optimization/37868] code that " sabre at nondot dot org
@ 2008-10-18 18:58 ` rguenth at gcc dot gnu dot org
2008-10-18 22:36 ` rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-18 18:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2008-10-18 18:57 -------
I don't see why it _should_ work with -fno-strict-aliasing. It may. Note that
this testcase also violates pointer arithmetic rules - you have a pointer that
doesn't point to a valid object.
On the 4.3 branch we still optimize it because we use SFTs for the individual
elements and offset disambiguation selects only one. On the trunk PTA seems
to prune the symbol.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
2008-10-18 18:30 ` [Bug tree-optimization/37868] code that " sabre at nondot dot org
2008-10-18 18:58 ` rguenth at gcc dot gnu dot org
@ 2008-10-18 22:36 ` rguenth at gcc dot gnu dot org
2008-10-18 22:44 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-18 22:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-10-18 22:34 -------
It works on the trunk for me with -fno-strict-aliasing, with -fstrict-aliasing
TBAA pruning prunes the points-to set.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |4.3.2
Known to work| |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (2 preceding siblings ...)
2008-10-18 22:36 ` rguenth at gcc dot gnu dot org
@ 2008-10-18 22:44 ` rguenth at gcc dot gnu dot org
2008-10-22 11:48 ` [Bug tree-optimization/37868] [4.3 Regression] " rguenth at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-18 22:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2008-10-18 22:42 -------
4.3 is broken because PTA figures
D.1187_2 = { x.a }
from the constraints
x.0_1 = &x
D.1187_2 = x.0_1 + 64
because the 4.3 branch doesn't have the PTA fixes, in particular
/* If the found variable is not exactly at the pointed to
result, we have to include the next variable in the
solution as well. Otherwise two increments by offset / 2
do not result in the same or a conservative superset
solution. */
if (temp->offset != curr->offset + rhsoffset
&& temp->next != NULL)
{
struct constraint_expr c2;
c2.var = temp->next->id;
c2.type = ADDRESSOF;
c2.offset = 0;
VEC_safe_push (ce_s, heap, *results, &c2);
}
see rev. 137573:
2008-07-07 Richard Guenther <rguenther@suse.de>
+ * tree-ssa-structalias.c (struct variable_info): Add is_full_var flag.
+ (new_var_info): Set it to false.
+ (solution_set_add): Correctly handle pointers outside a var and
+ inside a field.
+ (type_safe): Treat variables with is_full_var properly.
+ (do_sd_constraint): Likewise.
+ (do_ds_constraint): Likewise.
+ (process_constraint): Remove zeroing offset for !use_field_sensitive.
+ (get_constraint_for_ptr_offset): New function.
+ (get_constraint_for_component_ref): For addresses at least include
+ the last field of the variable. Handle is_full_vars properly.
+ (get_constraint_for_1): Factor common code, handle POINTER_PLUS_EXPR.
+ (handle_ptr_arith): Remove.
+ (find_func_aliases): Simplify assignment handling.
+ (create_function_info_for): For parameter and result varinfos set
+ is_full_var flag.
+ (create_variable_info_for): Set is_full_var flag whenever we
+ just created a single varinfo for a decl.
+ (init_alias_vars): Initialize use_field_sensitive from
+ max-fields-for-field-sensitive parameter.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2008-10-18 22:42:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (3 preceding siblings ...)
2008-10-18 22:44 ` rguenth at gcc dot gnu dot org
@ 2008-10-22 11:48 ` rguenth at gcc dot gnu dot org
2008-10-22 13:50 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-22 11:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2008-10-22 11:46 -------
4.2 works, so this is a regression. Mine.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Known to work|4.4.0 |4.2.4 4.4.0
Last reconfirmed|2008-10-18 22:42:54 |2008-10-22 11:46:45
date| |
Summary|code that breaks TBAA is |[4.3 Regression] code that
|misoptimized even with -fno-|breaks TBAA is misoptimized
|strict-aliasing |even with -fno-strict-
| |aliasing
Target Milestone|--- |4.3.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (4 preceding siblings ...)
2008-10-22 11:48 ` [Bug tree-optimization/37868] [4.3 Regression] " rguenth at gcc dot gnu dot org
@ 2008-10-22 13:50 ` rguenth at gcc dot gnu dot org
2008-11-03 11:29 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-22 13:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2008-10-22 13:49 -------
Backporting the fix turns out to be tricky...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (5 preceding siblings ...)
2008-10-22 13:50 ` rguenth at gcc dot gnu dot org
@ 2008-11-03 11:29 ` jakub at gcc dot gnu dot org
2008-11-07 12:51 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-11-03 11:29 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (6 preceding siblings ...)
2008-11-03 11:29 ` jakub at gcc dot gnu dot org
@ 2008-11-07 12:51 ` rguenth at gcc dot gnu dot org
2008-11-20 12:14 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-07 12:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2008-11-07 12:50 -------
*** Bug 38048 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (7 preceding siblings ...)
2008-11-07 12:51 ` rguenth at gcc dot gnu dot org
@ 2008-11-20 12:14 ` rguenth at gcc dot gnu dot org
2008-11-20 12:15 ` rguenth at gcc dot gnu dot org
2008-11-20 12:28 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-20 12:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2008-11-20 12:13 -------
Subject: Bug 37868
Author: rguenth
Date: Thu Nov 20 12:12:01 2008
New Revision: 142040
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142040
Log:
2008-11-20 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37868
* tree-ssa-structalias.c (set_uids_in_ptset): Add SFTs based on
pointed to variable and access size.
* gcc.dg/torture/pr37868.c: New testcase.
* gcc.c-torture/execute/pr38048-1.c: Likewise.
* gcc.c-torture/execute/pr38048-2.c: Likewise.
Backport from mainline:
2008-07-07 Richard Guenther <rguenther@suse.de>
* tree-ssa-structalias.c (struct variable_info): Add is_full_var flag.
(new_var_info): Set it to false.
(solution_set_add): Correctly handle pointers outside a var and
inside a field.
(type_safe): Treat variables with is_full_var properly.
(do_sd_constraint): Likewise.
(do_ds_constraint): Likewise.
(process_constraint): Remove zeroing offset for !use_field_sensitive.
(get_constraint_for_ptr_offset): New function.
(get_constraint_for_component_ref): Handle is_full_vars properly.
(get_constraint_for): Handle POINTER_PLUS_EXPR.
(handle_ptr_arith): Remove.
(find_func_aliases): Handle POINTER_PLUS_EXPR through generic
get_constraint_for code.
(create_function_info_for): For parameter and result varinfos set
is_full_var flag.
(create_variable_info_for): Set is_full_var flag whenever we
just created a single varinfo for a decl.
(init_alias_vars): Initialize use_field_sensitive from
max-fields-for-field-sensitive parameter.
* gcc.dg/torture/pta-ptrarith-1.c: New testcase.
* gcc.dg/torture/pta-ptrarith-2.c: Likewise.
Added:
branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/torture/pr37868.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c
Modified:
branches/gcc-4_3-branch/gcc/ChangeLog
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
branches/gcc-4_3-branch/gcc/tree-ssa-structalias.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (8 preceding siblings ...)
2008-11-20 12:14 ` rguenth at gcc dot gnu dot org
@ 2008-11-20 12:15 ` rguenth at gcc dot gnu dot org
2008-11-20 12:28 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-20 12:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2008-11-20 12:14 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/37868] [4.3 Regression] code that breaks TBAA is misoptimized even with -fno-strict-aliasing
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
` (9 preceding siblings ...)
2008-11-20 12:15 ` rguenth at gcc dot gnu dot org
@ 2008-11-20 12:28 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-20 12:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2008-11-20 12:26 -------
Subject: Bug 37868
Author: rguenth
Date: Thu Nov 20 12:25:26 2008
New Revision: 142041
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142041
Log:
2008-11-20 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37868
* gcc.dg/torture/pr37868.c: New testcase.
* gcc.c-torture/execute/pr38048-1.c: Likewise.
* gcc.c-torture/execute/pr38048-2.c: Likewise.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c
trunk/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c
trunk/gcc/testsuite/gcc.dg/torture/pr37868.c
Modified:
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37868
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-11-20 12:28 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-18 18:17 [Bug tree-optimization/37868] New: code that doesn't breaks TBAA is misoptimized even with -fno-strict-aliasing edwintorok at gmail dot com
2008-10-18 18:30 ` [Bug tree-optimization/37868] code that " sabre at nondot dot org
2008-10-18 18:58 ` rguenth at gcc dot gnu dot org
2008-10-18 22:36 ` rguenth at gcc dot gnu dot org
2008-10-18 22:44 ` rguenth at gcc dot gnu dot org
2008-10-22 11:48 ` [Bug tree-optimization/37868] [4.3 Regression] " rguenth at gcc dot gnu dot org
2008-10-22 13:50 ` rguenth at gcc dot gnu dot org
2008-11-03 11:29 ` jakub at gcc dot gnu dot org
2008-11-07 12:51 ` rguenth at gcc dot gnu dot org
2008-11-20 12:14 ` rguenth at gcc dot gnu dot org
2008-11-20 12:15 ` rguenth at gcc dot gnu dot org
2008-11-20 12:28 ` rguenth at gcc dot gnu 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).