public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
@ 2008-01-13 14:01 rguenth at gcc dot gnu dot org
2008-01-13 14:04 ` [Bug middle-end/34768] " rguenth at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-13 14:01 UTC (permalink / raw)
To: gcc-bugs
int x;
void __attribute__((noinline)) foo (void)
{
x = -x;
}
void __attribute__((const,noinline)) bar (void)
{
}
int __attribute__((noinline))
test (int c)
{
int tmp = x;
(c ? foo : bar) ();
return tmp + x;
}
extern void abort (void);
int main()
{
x = 1;
if (test (1) != 0)
abort ();
return 0;
}
creates wrong code because the side-effect of the call to foo() is not
accounted for.
Since the merge of tree-ssa already gimplification removes the function call.
Thus, the above fails with -O0.
If you modify the testcase to use the return-value, you see that wrong
alias information is created because we appearantly use the const attribute
for the indirect call.
int x;
int __attribute__((noinline)) foo (void)
{
x = -x;
return 0;
}
int __attribute__((const,noinline)) bar (void)
{
return 0;
}
int __attribute__((noinline))
test (int c)
{
int tmp = x;
int res = (c ? foo : bar) ();
return tmp + x + res;
}
extern void abort (void);
int main()
{
x = 1;
if (test (1) != 0)
abort ();
return 0;
}
alias produced is:
test (c)
{
int res;
int tmp;
int D.1207;
int x.3;
int D.1205;
int (*<T240>) (void) iftmp.2;
<bb 2>:
# VUSE <x_11(D)>
tmp_2 = x;
if (c_3(D) != 0)
goto <bb 4>;
else
goto <bb 3>;
<bb 3>:
<bb 4>:
# iftmp.2_1 = PHI <foo(2), bar(3)>
res_6 = iftmp.2_1 ();
# VUSE <x_11(D)>
x.3_7 = x;
D.1207_8 = tmp_2 + x.3_7;
D.1205_9 = D.1207_8 + res_6;
return D.1205_9;
}
and we happily CSE the load from x. This testcase requires -O to fail.
--
Summary: [4.1/4.2/4.3 Regression] Wrong code with conditional
function invocation
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/34768] [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
@ 2008-01-13 14:04 ` rguenth at gcc dot gnu dot org
2008-01-13 14:36 ` [Bug c/34768] " rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-13 14:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-01-13 13:23 -------
Mine. Probably also causes PR32139.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |32139
nThis| |
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Known to fail| |4.0.4 4.1.3 4.2.3 4.3.0
Known to work| |3.4.6
Priority|P3 |P1
Last reconfirmed|0000-00-00 00:00:00 |2008-01-13 13:23:55
date| |
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
2008-01-13 14:04 ` [Bug middle-end/34768] " rguenth at gcc dot gnu dot org
@ 2008-01-13 14:36 ` rguenth at gcc dot gnu dot org
2008-01-13 14:36 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-13 14:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2008-01-13 13:25 -------
Um, this is a FE bug.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |c
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
2008-01-13 14:04 ` [Bug middle-end/34768] " rguenth at gcc dot gnu dot org
2008-01-13 14:36 ` [Bug c/34768] " rguenth at gcc dot gnu dot org
@ 2008-01-13 14:36 ` rguenth at gcc dot gnu dot org
2008-01-13 18:02 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-13 14:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-01-13 13:50 -------
The bug is in common_pointer_type (), where we merge the function type
qualifiers (TYPE_READONLY is used for 'const' functions):
else if (TYPE_P (exp) && TYPE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
flags |= ECF_CONST;
volatile is used as 'noreturn'.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (2 preceding siblings ...)
2008-01-13 14:36 ` rguenth at gcc dot gnu dot org
@ 2008-01-13 18:02 ` pinskia at gcc dot gnu dot org
2008-01-13 18:34 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-13 18:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2008-01-13 17:49 -------
THis is related to PR 29382 and PR 13519. And I think this is exactly the same
issue as PR 28289.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-01-13 18:02 ` pinskia at gcc dot gnu dot org
@ 2008-01-13 18:34 ` rguenth at gcc dot gnu dot org
2008-01-16 10:17 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-13 18:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2008-01-13 18:17 -------
*** Bug 28289 has been marked as a duplicate of this bug. ***
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amylaar at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-01-13 18:34 ` rguenth at gcc dot gnu dot org
@ 2008-01-16 10:17 ` rguenth at gcc dot gnu dot org
2008-01-16 10:29 ` [Bug c/34768] [4.1/4.2 " rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-16 10:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2008-01-16 09:45 -------
Subject: Bug 34768
Author: rguenth
Date: Wed Jan 16 09:44:23 2008
New Revision: 131568
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131568
Log:
2008-01-16 Richard Guenther <rguenther@suse.de>
PR c/34768
* c-typeck.c (common_pointer_type): Do not merge inconsistent
type qualifiers for function types.
* gcc.c-torture/execute/pr34768-1.c: New testcase.
* gcc.c-torture/execute/pr34768-2.c: Likewise.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr34768-1.c
trunk/gcc/testsuite/gcc.c-torture/execute/pr34768-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-typeck.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (5 preceding siblings ...)
2008-01-16 10:17 ` rguenth at gcc dot gnu dot org
@ 2008-01-16 10:29 ` rguenth at gcc dot gnu dot org
2008-01-22 14:48 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-16 10:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2008-01-16 09:47 -------
Fixed on the trunk.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|3.4.6 |3.4.6 4.3.0
Summary|[4.1/4.2/4.3 Regression] |[4.1/4.2 Regression] Wrong
|Wrong code with conditional |code with conditional
|function invocation |function invocation
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1/4.2 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (6 preceding siblings ...)
2008-01-16 10:29 ` [Bug c/34768] [4.1/4.2 " rguenth at gcc dot gnu dot org
@ 2008-01-22 14:48 ` rguenth at gcc dot gnu dot org
2008-01-22 14:57 ` [Bug c/34768] [4.1 " rguenth at gcc dot gnu dot org
2008-07-04 16:18 ` jsm28 at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-22 14:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2008-01-22 14:46 -------
Subject: Bug 34768
Author: rguenth
Date: Tue Jan 22 14:45:56 2008
New Revision: 131723
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131723
Log:
2008-01-22 Richard Guenther <rguenther@suse.de>
PR middle-end/34739
Backport from mainline
2008-01-16 Richard Guenther <rguenther@suse.de>
PR c/34768
* c-typeck.c (common_pointer_type): Do not merge inconsistent
type qualifiers for function types.
2007-11-12 Richard Guenther <rguenther@suse.de>
PR middle-end/34070
* fold-const.c (fold_binary): If testing for non-negative
operands with tree_expr_nonnegative_warnv_p make sure to
use op0 which has all (sign) conversions retained.
2006-10-24 Richard Guenther <rguenther@suse.de>
PR middle-end/28796
* builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS
for deciding optimizations in consistency with fold-const.c
(fold_builtin_unordered_cmp): Likewise.
Added:
branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr34070-1.c
- copied unchanged from r130098,
trunk/gcc/testsuite/gcc.c-torture/execute/pr34070-1.c
branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr34070-2.c
- copied unchanged from r130098,
trunk/gcc/testsuite/gcc.c-torture/execute/pr34070-2.c
branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr34768-1.c
- copied unchanged from r131568,
trunk/gcc/testsuite/gcc.c-torture/execute/pr34768-1.c
branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr34768-2.c
- copied unchanged from r131568,
trunk/gcc/testsuite/gcc.c-torture/execute/pr34768-2.c
branches/gcc-4_2-branch/gcc/testsuite/gcc.dg/pr28796-1.c
- copied unchanged from r118001, trunk/gcc/testsuite/gcc.dg/pr28796-1.c
branches/gcc-4_2-branch/gcc/testsuite/gcc.dg/pr28796-2.c
- copied unchanged from r118001, trunk/gcc/testsuite/gcc.dg/pr28796-2.c
Modified:
branches/gcc-4_2-branch/gcc/ChangeLog
branches/gcc-4_2-branch/gcc/builtins.c
branches/gcc-4_2-branch/gcc/c-typeck.c
branches/gcc-4_2-branch/gcc/fold-const.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (7 preceding siblings ...)
2008-01-22 14:48 ` rguenth at gcc dot gnu dot org
@ 2008-01-22 14:57 ` rguenth at gcc dot gnu dot org
2008-07-04 16:18 ` jsm28 at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-22 14:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2008-01-22 14:51 -------
Fixed on the 4.2 branch.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|rguenth at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
Known to fail|4.0.4 4.1.3 4.2.3 4.3.0 |4.0.4 4.1.3
Known to work|3.4.6 4.3.0 |3.4.6 4.2.3 4.3.0
Summary|[4.1/4.2 Regression] Wrong |[4.1 Regression] Wrong code
|code with conditional |with conditional function
|function invocation |invocation
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/34768] [4.1 Regression] Wrong code with conditional function invocation
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
` (8 preceding siblings ...)
2008-01-22 14:57 ` [Bug c/34768] [4.1 " rguenth at gcc dot gnu dot org
@ 2008-07-04 16:18 ` jsm28 at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 16:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jsm28 at gcc dot gnu dot org 2008-07-04 16:17 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|4.1.3 |4.2.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34768
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-07-04 16:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-13 14:01 [Bug middle-end/34768] New: [4.1/4.2/4.3 Regression] Wrong code with conditional function invocation rguenth at gcc dot gnu dot org
2008-01-13 14:04 ` [Bug middle-end/34768] " rguenth at gcc dot gnu dot org
2008-01-13 14:36 ` [Bug c/34768] " rguenth at gcc dot gnu dot org
2008-01-13 14:36 ` rguenth at gcc dot gnu dot org
2008-01-13 18:02 ` pinskia at gcc dot gnu dot org
2008-01-13 18:34 ` rguenth at gcc dot gnu dot org
2008-01-16 10:17 ` rguenth at gcc dot gnu dot org
2008-01-16 10:29 ` [Bug c/34768] [4.1/4.2 " rguenth at gcc dot gnu dot org
2008-01-22 14:48 ` rguenth at gcc dot gnu dot org
2008-01-22 14:57 ` [Bug c/34768] [4.1 " rguenth at gcc dot gnu dot org
2008-07-04 16:18 ` jsm28 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).