public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-08 15:26 Richard Henderson
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2002-10-08 15:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: Glen Nakamura <glen@imodulo.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Tue, 8 Oct 2002 15:20:53 -0700
On Mon, Oct 07, 2002 at 03:24:09PM -1000, Glen Nakamura wrote:
> * simplify-rtx.c (simplify_replace_rtx): Added case to simplify
> and replace LO_SUM expressions.
I get the feeling this is simply papering over the problem.
I'll continue to investigate...
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-14 11:16 Richard Henderson
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2002-10-14 11:16 UTC (permalink / raw)
To: rth; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: Glen Nakamura <glen@imodulo.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Mon, 14 Oct 2002 11:09:56 -0700
On Sat, Oct 12, 2002 at 08:39:25AM -1000, Glen Nakamura wrote:
> Looking at try_replace_reg() again, I noticed that the REG_EQUAL note
> isn't always replaced. Is the "else" really okay?
Yes. Look again. We only bypass the else if we didn't make
a substitution.
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-12 11:46 Glen Nakamura
0 siblings, 0 replies; 10+ messages in thread
From: Glen Nakamura @ 2002-10-12 11:46 UTC (permalink / raw)
To: rth; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Glen Nakamura <glen@imodulo.com>
To: Richard Henderson <rth@redhat.com>, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Sat, 12 Oct 2002 08:39:25 -1000
On Fri, Oct 11, 2002 at 05:51:43PM -0700, Richard Henderson wrote:
> I guess your original patch is probably correct. I was
> focused so much on the LO_SUM/HIGH simplification that
> I missed the fact that we were failing to process the
> internal regs of the LO_SUM at all.
Looking at try_replace_reg() again, I noticed that the REG_EQUAL note
isn't always replaced. Is the "else" really okay?
static int
try_replace_reg (from, to, insn)
rtx from, to, insn;
{
rtx note = find_reg_equal_equiv_note (insn);
...
if (!success && set && reg_mentioned_p (from, SET_SRC (set)))
{
...
/* If we've failed to do replacement, have a single SET, and don't already
have a note, add a REG_EQUAL note to not lose information. */
if (!success && note == 0 && set != 0)
note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
}
/* If there is already a NOTE, update the expression in it with our
replacement. */
else if (note != 0)
^^^^
XEXP (note, 0) = simplify_replace_rtx (XEXP (note, 0), from, to);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-11 17:56 Richard Henderson
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2002-10-11 17:56 UTC (permalink / raw)
To: rth; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: Glen Nakamura <glen@imodulo.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Fri, 11 Oct 2002 17:51:43 -0700
On Fri, Oct 11, 2002 at 01:17:21PM -1000, Glen Nakamura wrote:
> Does try_replace_reg still need the above code?
I completely missed that. Sigh.
I guess your original patch is probably correct. I was
focused so much on the LO_SUM/HIGH simplification that
I missed the fact that we were failing to process the
internal regs of the LO_SUM at all.
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-11 16:26 Glen Nakamura
0 siblings, 0 replies; 10+ messages in thread
From: Glen Nakamura @ 2002-10-11 16:26 UTC (permalink / raw)
To: rth; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Glen Nakamura <glen@imodulo.com>
To: Richard Henderson <rth@redhat.com>, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc:
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Fri, 11 Oct 2002 13:17:21 -1000
On Fri, Oct 11, 2002 at 03:44:48PM -0700, Richard Henderson wrote:
> * gcse.c (adjust_libcall_notes): Also adjust notes for INSN.
Okay, but isn't this redundant to the following code in try_replace_reg ():
static int
try_replace_reg (from, to, insn)
rtx from, to, insn;
{
rtx note = find_reg_equal_equiv_note (insn);
...
/* If there is already a NOTE, update the expression in it with our
replacement. */
else if (note != 0)
XEXP (note, 0) = simplify_replace_rtx (XEXP (note, 0), from, to);
Does try_replace_reg still need the above code?
- glen
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-11 16:13 rth
0 siblings, 0 replies; 10+ messages in thread
From: rth @ 2002-10-11 16:13 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, glen, nobody, rth
Synopsis: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Responsible-Changed-From-To: unassigned->rth
Responsible-Changed-By: rth
Responsible-Changed-When: Fri Oct 11 16:13:06 2002
Responsible-Changed-Why:
.
State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Fri Oct 11 16:13:06 2002
State-Changed-Why:
http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00743.html
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8165
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-11 15:46 Richard Henderson
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2002-10-11 15:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Richard Henderson <rth@redhat.com>
To: Glen Nakamura <glen@imodulo.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Fri, 11 Oct 2002 15:44:48 -0700
You're right about the REG_EQUAL note being bogus, but as I feared,
the fix was in the wrong place. The problem has nothing to do with
lo_sum in specific, but is a generic issue with local cprop failing
to update notes.
Addressed thus.
r~
* gcse.c (adjust_libcall_notes): Also adjust notes for INSN.
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.220
diff -u -p -r1.220 gcse.c
--- gcse.c 30 Sep 2002 13:00:29 -0000 1.220
+++ gcse.c 11 Oct 2002 07:51:06 -0000
@@ -4251,6 +4251,7 @@ cprop_insn (insn, alter_jumps)
/* LIBCALL_SP is a zero-terminated array of insns at the end of a libcall;
their REG_EQUAL notes need updating. */
+
static bool
do_local_cprop (x, insn, alter_jumps, libcall_sp)
rtx x;
@@ -4260,10 +4261,12 @@ do_local_cprop (x, insn, alter_jumps, li
{
rtx newreg = NULL, newcnst = NULL;
- /* Rule out USE instructions and ASM statements as we don't want to change the hard registers mentioned. */
+ /* Rule out USE instructions and ASM statements as we don't want to
+ change the hard registers mentioned. */
if (GET_CODE (x) == REG
&& (REGNO (x) >= FIRST_PSEUDO_REGISTER
- || (GET_CODE (PATTERN (insn)) != USE && asm_noperands (PATTERN (insn)) < 0)))
+ || (GET_CODE (PATTERN (insn)) != USE
+ && asm_noperands (PATTERN (insn)) < 0)))
{
cselib_val *val = cselib_lookup (x, GET_MODE (x), 0);
struct elt_loc_list *l;
@@ -4327,17 +4330,23 @@ do_local_cprop (x, insn, alter_jumps, li
/* LIBCALL_SP is a zero-terminated array of insns at the end of a libcall;
their REG_EQUAL notes need updating to reflect that OLDREG has been
- replaced with NEWVAL in INSN. Return true if all substitutions could
- be made. */
+ replaced with NEWVAL in INSN. Also update the REG_EQUAL notes in INSN.
+
+ Return true if all substitutions could be made. */
+
static bool
adjust_libcall_notes (oldreg, newval, insn, libcall_sp)
rtx oldreg, newval, insn, *libcall_sp;
{
- rtx end;
+ rtx end, note;
+
+ note = find_reg_equal_equiv_note (insn);
+ if (note)
+ XEXP (note, 0) = replace_rtx (XEXP (note, 0), oldreg, newval);
while ((end = *libcall_sp++))
{
- rtx note = find_reg_equal_equiv_note (end);
+ note = find_reg_equal_equiv_note (end);
if (! note)
continue;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-08 16:16 Glen Nakamura
0 siblings, 0 replies; 10+ messages in thread
From: Glen Nakamura @ 2002-10-08 16:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Glen Nakamura <glen@imodulo.com>
To: Richard Henderson <rth@redhat.com>, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org
Cc:
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Tue, 8 Oct 2002 13:13:26 -1000
On Tue, Oct 08, 2002 at 03:20:53PM -0700, Richard Henderson wrote:
> I get the feeling this is simply papering over the problem.
> I'll continue to investigate...
Thanks, you are quite possibly right.
There was a bunch of things happening, and I don't fully understand
the semantics of REG_EQUAL notes. I don't have the original rtx dumps,
but from memory things looked like this before gcse:
SET A
...
BEGIN_LOOP
...
SET B
USE B REG_EQUAL B
After gcse USE B is replaced with USE A, but REG_EQUAL still refers to B:
SET A
...
BEGIN_LOOP
...
SET B
USE A REG_EQUAL B
Then I think the loop pass moved USE A out of the loop (above SET B):
SET A
...
USE A REG_EQUAL B
BEGIN_LOOP
...
SET B
Eventually, SET B is determined dead and removed but the REG_EQUAL
referring to it still exists... Then for some reason, the REG_EQUAL note
gets used and bad things happen. One bad side-effect is that life-analysis
determines B is live at the entry of basic block 0. I hope this helps.
- glen
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-07 18:26 Glen Nakamura
0 siblings, 0 replies; 10+ messages in thread
From: Glen Nakamura @ 2002-10-07 18:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/8165; it has been noted by GNATS.
From: Glen Nakamura <glen@imodulo.com>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Cc:
Subject: Re: optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
Date: Mon, 7 Oct 2002 15:24:09 -1000
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8165
Okay, I think the problem is in the gcse pass.
When we replace a register, we don't completely replace its references
in the instruction's REG_EQUAL note. Specifically, we miss the case
where the register is referred to in a (lo_sum (reg) (symbol_ref)).
My proposed fix is to add this case to simplify_replace_rtx() which is
called by try_replace_reg() during the gcse pass.
2002-10-07 Glen Nakamura <glen@imodulo.com>
* simplify-rtx.c (simplify_replace_rtx): Added case to simplify
and replace LO_SUM expressions.
Index: gcc/simplify-rtx.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.122
diff -c -5 -p -r1.122 simplify-rtx.c
*** gcc/simplify-rtx.c 27 Sep 2002 12:48:02 -0000 1.122
--- gcc/simplify-rtx.c 8 Oct 2002 00:41:55 -0000
*************** simplify_replace_rtx (x, old, new)
*** 339,348 ****
--- 339,364 ----
if (code == MEM)
return replace_equiv_address_nv (x,
simplify_replace_rtx (XEXP (x, 0),
old, new));
+ if (code == LO_SUM)
+ {
+ if (REG_P (old) && REG_P (XEXP (x, 0))
+ && REGNO (old) == REGNO (XEXP (x, 0)))
+ {
+ if (REG_P (new))
+ return gen_rtx_fmt_ee (code, mode, new, XEXP (x, 1));
+
+ /* (lo_sum (high X) X) is simply X. */
+ if (GET_CODE (new) == HIGH
+ && rtx_equal_p (XEXP (new, 0), XEXP (x, 1)))
+ return XEXP (x, 1);
+ }
+ return x;
+ }
+
if (REG_P (x) && REG_P (old) && REGNO (x) == REGNO (old))
return new;
return x;
^ permalink raw reply [flat|nested] 10+ messages in thread
* optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
@ 2002-10-07 17:56 glen
0 siblings, 0 replies; 10+ messages in thread
From: glen @ 2002-10-07 17:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 8165
>Category: optimization
>Synopsis: builtin string functions SEGV on alpha-pc-linux-gnu at -O2
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 07 17:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Glen Nakamura
>Release: gcc version 3.3 20021006 (experimental)
>Organization:
>Environment:
alpha-pc-linux-gnu
>Description:
The testcase results in SEGV when compiled at -O2.
>How-To-Repeat:
gcc -O2 testcase.c
./a.out
>Fix:
I'll send a proposed patch in a bit...
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="testcase.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="testcase.c"
ZXh0ZXJuIHZvaWQgYWJvcnQgKHZvaWQpOwoKY2hhciBidWZbNjRdOwoKaW50Cm1haW4gKHZvaWQp
CnsKICBpbnQgaTsKCiAgX19idWlsdGluX3N0cmNweSAoYnVmLCAibXlzdHJpbmciKTsKICBpZiAo
X19idWlsdGluX3N0cmNtcCAoYnVmLCAibXlzdHJpbmciKSAhPSAwKQogICAgYWJvcnQgKCk7Cgog
IGZvciAoaSA9IDA7IGkgPCAxNjsgKytpKQogICAgewogICAgICBfX2J1aWx0aW5fc3RyY3B5IChi
dWYgKyBpLCAibXlzdHJpbmciKTsKICAgICAgaWYgKF9fYnVpbHRpbl9zdHJjbXAgKGJ1ZiArIGks
ICJteXN0cmluZyIpICE9IDApCglhYm9ydCAoKTsKICAgIH0KCiAgcmV0dXJuIDA7Cn0K
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2002-10-14 18:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-08 15:26 optimization/8165: builtin string functions SEGV on alpha-pc-linux-gnu at -O2 Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2002-10-14 11:16 Richard Henderson
2002-10-12 11:46 Glen Nakamura
2002-10-11 17:56 Richard Henderson
2002-10-11 16:26 Glen Nakamura
2002-10-11 16:13 rth
2002-10-11 15:46 Richard Henderson
2002-10-08 16:16 Glen Nakamura
2002-10-07 18:26 Glen Nakamura
2002-10-07 17:56 glen
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).