public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 17:46 Richard Henderson
0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2002-04-09 17:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/6233: simple loop miscompilation
Date: Tue, 9 Apr 2002 17:41:07 -0700
On Wed, Apr 10, 2002 at 09:30:14AM +0930, Alan Modra wrote:
> Sledgehammer to crack a nut? Should I instead specifically search
> for the use_mem_scratch?
Please.
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 19:06 Richard Henderson
0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2002-04-09 19:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/6233: simple loop miscompilation
Date: Tue, 9 Apr 2002 19:03:42 -0700
On Wed, Apr 10, 2002 at 10:32:37AM +0930, Alan Modra wrote:
> * rtlanal.c (pure_call_p): New function.
> * rtl.h (pure_call_p): Declare.
> * loop.c (prescan_loop): Use it to set has_nonconst_call.
Much better, thanks.
For mainline, would you change store_killed_in_insn
to use this too, please?
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 18:06 Alan Modra
0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2002-04-09 18:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: Richard Henderson <rth@redhat.com>, gcc-gnats@gcc.gnu.org,
gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/6233: simple loop miscompilation
Date: Wed, 10 Apr 2002 10:32:37 +0930
On Tue, Apr 09, 2002 at 05:41:07PM -0700, Richard Henderson wrote:
> On Wed, Apr 10, 2002 at 09:30:14AM +0930, Alan Modra wrote:
> > Sledgehammer to crack a nut? Should I instead specifically search
> > for the use_mem_scratch?
>
> Please.
OK. i686-linux native bootstrap and reg test in progress.
* rtlanal.c (pure_call_p): New function.
* rtl.h (pure_call_p): Declare.
* loop.c (prescan_loop): Use it to set has_nonconst_call.
Index: gcc/loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.394
diff -u -p -r1.394 loop.c
--- gcc/loop.c 3 Apr 2002 07:56:44 -0000 1.394
+++ gcc/loop.c 10 Apr 2002 00:56:54 -0000
@@ -2493,6 +2493,8 @@ prescan_loop (loop)
loop_info->unknown_address_altered = 1;
loop_info->has_nonconst_call = 1;
}
+ else if (pure_call_p (insn))
+ loop_info->has_nonconst_call = 1;
loop_info->has_call = 1;
if (can_throw_internal (insn))
loop_info->has_multiple_exit_targets = 1;
Index: gcc/rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.337
diff -u -p -r1.337 rtl.h
--- gcc/rtl.h 1 Apr 2002 03:18:49 -0000 1.337
+++ gcc/rtl.h 10 Apr 2002 00:56:56 -0000
@@ -1502,6 +1502,7 @@ extern rtx find_reg_equal_equiv_note PAR
extern int find_reg_fusage PARAMS ((rtx, enum rtx_code, rtx));
extern int find_regno_fusage PARAMS ((rtx, enum rtx_code,
unsigned int));
+extern int pure_call_p PARAMS ((rtx));
extern void remove_note PARAMS ((rtx, rtx));
extern int side_effects_p PARAMS ((rtx));
extern int volatile_refs_p PARAMS ((rtx));
Index: gcc/rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.130
diff -u -p -r1.130 rtlanal.c
--- gcc/rtlanal.c 28 Mar 2002 12:25:18 -0000 1.130
+++ gcc/rtlanal.c 10 Apr 2002 00:56:58 -0000
@@ -2011,6 +2011,31 @@ find_regno_fusage (insn, code, regno)
return 0;
}
+
+/* Return true if INSN is a call to a pure function. */
+
+int
+pure_call_p (insn)
+ rtx insn;
+{
+ rtx link;
+
+ if (GET_CODE (insn) != CALL_INSN || ! CONST_OR_PURE_CALL_P (insn))
+ return 0;
+
+ /* Look for the note that differentiates const and pure functions. */
+ for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
+ {
+ rtx u, m;
+
+ if (GET_CODE (u = XEXP (link, 0)) == USE
+ && GET_CODE (m = XEXP (u, 0)) == MEM && GET_MODE (m) == BLKmode
+ && GET_CODE (XEXP (m, 0)) == SCRATCH)
+ return 1;
+ }
+
+ return 0;
+}
\f
/* Remove register note NOTE from the REG_NOTES of INSN. */
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 17:06 Alan Modra
0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2002-04-09 17:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: Richard Henderson <rth@redhat.com>, gcc-gnats@gcc.gnu.org,
gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/6233: simple loop miscompilation
Date: Wed, 10 Apr 2002 09:30:14 +0930
On Tue, Apr 09, 2002 at 09:41:57AM -0700, Richard Henderson wrote:
> On Tue, Apr 09, 2002 at 08:57:35PM +0930, Alan Modra wrote:
> > * alias.c (nonlocal_referenced_p): Make global.
> > * tree.h (nonlocal_referenced_p): Declare.
> > * loop.c (prescan_loop): Set has_nonconst_call for pure functions.
>
> This is almost certainly wrong. It sounds more like either
> we've mis-categorized the function to begin with
No, initial rtl looks OK (to my untrained eye)
(call_insn 21 9 22 (call_placeholder 16 10 0 0 (call_insn/u 16 0 18 (set (reg:SI 0 eax)
(call (mem:QI (symbol_ref:SI ("is_end_of_statement")) [0 S1 A8])
(const_int 0 [0x0]))) -1 (nil)
(insn_list:REG_LIBCALL 18 (expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
(nil)))
(expr_list (use (mem:BLK (scratch) [0 A8]))
(nil)))) -1 (nil)
(nil)
(nil))
>, or loop is
> failing to note the USE of memory in CALL_INSN_FUNCTION_USAGE.
Yes, that's what I was using nonlocal_referenced_p to find.
Sledgehammer to crack a nut? Should I instead specifically search
for the use_mem_scratch?
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 9:46 Richard Henderson
0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2002-04-09 9:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/6233: simple loop miscompilation
Date: Tue, 9 Apr 2002 09:41:57 -0700
On Tue, Apr 09, 2002 at 08:57:35PM +0930, Alan Modra wrote:
> * alias.c (nonlocal_referenced_p): Make global.
> * tree.h (nonlocal_referenced_p): Declare.
> * loop.c (prescan_loop): Set has_nonconst_call for pure functions.
This is almost certainly wrong. It sounds more like either
we've mis-categorized the function to begin with, or loop is
failing to note the USE of memory in CALL_INSN_FUNCTION_USAGE.
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 6:46 Alan Modra
0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2002-04-09 6:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/6233: simple loop miscompilation
Date: Tue, 9 Apr 2002 23:09:12 +0930
On Tue, Apr 09, 2002 at 08:57:35PM +0930, Alan Modra wrote:
> This patch cures PR6233.
Oh, and as Andreas Jaeger reminded me (thanks!), bootstrapped,
regression tested i686-linux native.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: optimization/6233: simple loop miscompilation
@ 2002-04-09 4:36 Alan Modra
0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2002-04-09 4:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6233; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: gcc-gnats@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: Re: optimization/6233: simple loop miscompilation
Date: Tue, 9 Apr 2002 20:57:35 +0930
This patch cures PR6233.
gcc/ChangeLog
* alias.c (nonlocal_referenced_p): Make global.
* tree.h (nonlocal_referenced_p): Declare.
* loop.c (prescan_loop): Set has_nonconst_call for pure functions.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
Index: gcc/alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.169
diff -u -p -r1.169 alias.c
--- gcc/alias.c 4 Apr 2002 22:48:16 -0000 1.169
+++ gcc/alias.c 9 Apr 2002 10:55:06 -0000
@@ -112,7 +112,6 @@ static int write_dependence_p
static int nonlocal_mentioned_p_1 PARAMS ((rtx *, void *));
static int nonlocal_mentioned_p PARAMS ((rtx));
static int nonlocal_referenced_p_1 PARAMS ((rtx *, void *));
-static int nonlocal_referenced_p PARAMS ((rtx));
static int nonlocal_set_p_1 PARAMS ((rtx *, void *));
static int nonlocal_set_p PARAMS ((rtx));
@@ -2455,7 +2454,7 @@ nonlocal_referenced_p_1 (loc, data)
/* Returns non-zero if X might reference something which is not
local to the function and is not constant. */
-static int
+int
nonlocal_referenced_p (x)
rtx x;
{
Index: gcc/loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.394
diff -u -p -r1.394 loop.c
--- gcc/loop.c 3 Apr 2002 07:56:44 -0000 1.394
+++ gcc/loop.c 9 Apr 2002 10:55:27 -0000
@@ -2493,6 +2493,8 @@ prescan_loop (loop)
loop_info->unknown_address_altered = 1;
loop_info->has_nonconst_call = 1;
}
+ else if (nonlocal_referenced_p (insn))
+ loop_info->has_nonconst_call = 1;
loop_info->has_call = 1;
if (can_throw_internal (insn))
loop_info->has_multiple_exit_targets = 1;
Index: gcc/tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.327
diff -u -p -r1.327 tree.h
--- gcc/tree.h 4 Apr 2002 22:19:38 -0000 1.327
+++ gcc/tree.h 9 Apr 2002 10:55:30 -0000
@@ -2815,6 +2815,7 @@ extern int alias_sets_conflict_p PARAMS
HOST_WIDE_INT));
extern int readonly_fields_p PARAMS ((tree));
extern int objects_must_conflict_p PARAMS ((tree, tree));
+extern int nonlocal_referenced_p PARAMS ((rtx));
struct obstack;
^ permalink raw reply [flat|nested] 8+ messages in thread
* optimization/6233: simple loop miscompilation
@ 2002-04-08 21:36 amodra
0 siblings, 0 replies; 8+ messages in thread
From: amodra @ 2002-04-08 21:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 6233
>Category: optimization
>Synopsis: simple loop miscompilation
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Apr 08 21:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Alan Modra
>Release: 3.2 20020408 (experimental)
>Organization:
IBM
>Environment:
configured with: /src/gcc-current/configure --prefix=/usr/local --build=i686-linux --host=i686-linux --target=i686-linux --disable-nls --enable-shared --enable-languages=c,c++
>Description:
function call incorrectly moved out of loop at -O2.
>How-To-Repeat:
testcase distilled from binutils sources
extern char *p;
static int
is_end_of_statement ()
{
return *p == '\n' || *p == ';' || *p == '!';
}
void foo (void)
{
while (!is_end_of_statement ())
p++;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-04-10 2:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-09 17:46 optimization/6233: simple loop miscompilation Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2002-04-09 19:06 Richard Henderson
2002-04-09 18:06 Alan Modra
2002-04-09 17:06 Alan Modra
2002-04-09 9:46 Richard Henderson
2002-04-09 6:46 Alan Modra
2002-04-09 4:36 Alan Modra
2002-04-08 21:36 amodra
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).