public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
@ 2003-03-24 19:08 mmitchel
0 siblings, 0 replies; 6+ messages in thread
From: mmitchel @ 2003-03-24 19:08 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, rassahah
Synopsis: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Mon Mar 24 18:58:26 2003
State-Changed-Why:
Fixed in GCC 3.3, GCC 3.4.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10185
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
@ 2003-03-24 18:39 Jan Hubicka
0 siblings, 0 replies; 6+ messages in thread
From: Jan Hubicka @ 2003-03-24 18:39 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10185; it has been noted by GNATS.
From: Jan Hubicka <jh@suse.cz>
To: Janis Johnson <janis187@us.ibm.com>
Cc: Steven Bosscher <s.bosscher@student.tudelft.nl>,
rassahah@neofonie.de, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org, jh@suse.cz
Subject: Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
Date: Mon, 24 Mar 2003 19:26:18 +0100
> The regression appeared with this patch:
>
> Sun Jul 21 00:54:54 CEST 2002 Jan Hubicka <jh@suse.cz>
>
> * gcse.c: Include cselib.h
> (constptop_register): Break out from ...
> (cprop_insn): ... here; kill basic_block argument.
> (do_local_cprop, local_cprop_pass): New functions.
> (one_cprop_pass): Call local_cprop_pass.
>
> My testing used the submitter's test case with -O2 on
> i686-pc-linux-gnu.
As described in the audit, the bug is really latent problem in BIV
discovery code. This patch fixes the reason why gcse now manifest it.
I am now using cselib to discover noop moves and remove them more
aggresivly than delete_trivially_dead_insns can. 15 such noops are
found in combine.c compilation and resulting insn chain is reduced by 7
instructions, so this arrise in real programs too.
Bootstrapped/regtested x86-64. OK?
Mon Mar 24 19:00:35 CET 2003 Jan Hubicka <jh@suse.cz>
* gcse.c (local_cprop_pass): Do not copy propagate noop sets;
attempt to turn set into noop.
* cselib.c (cselib_set_noop_p): New function.
* cselib.h (cselib_set_noop_p): Declare.
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.239
diff -c -3 -p -r1.239 gcse.c
*** gcse.c 8 Mar 2003 09:47:28 -0000 1.239
--- gcse.c 24 Mar 2003 18:12:32 -0000
*************** local_cprop_pass (alter_jumps)
*** 4437,4442 ****
--- 4437,4443 ----
if (INSN_P (insn))
{
rtx note = find_reg_note (insn, REG_LIBCALL, NULL_RTX);
+ rtx set;
if (note)
{
*************** local_cprop_pass (alter_jumps)
*** 4448,4453 ****
--- 4449,4499 ----
if (note)
libcall_sp++;
note = find_reg_equal_equiv_note (insn);
+
+ if (noop_move_p (insn)
+ && !find_reg_note (insn, REG_LIBCALL, NULL_RTX))
+ {
+ delete_insn (insn);
+ continue;
+ }
+
+ set = single_set (insn);
+
+ /* Don't do copy propagation on noop moves as it only
+ results in these being in the insn chain longer */
+ if (set && set_noop_p (set))
+ continue;
+ /* Attempt to turn (set A B) where A B are known to be equivalent
+ into (set A A) or (set B B) so the instruction is removed later.
+ */
+ if (set && cselib_set_noop_p (set)
+ && (!SMALL_REGISTER_CLASSES
+ || ((!REG_P (SET_DEST (set))
+ || REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER)
+ && (GET_CODE (SET_DEST (set)) != SUBREG
+ || (REGNO (SUBREG_REG (SET_DEST (set)))
+ >= FIRST_PSEUDO_REGISTER)))))
+ {
+ bool converted = false;
+
+ if (validate_change (insn, &SET_DEST (set),
+ copy_rtx (SET_SRC (set)), 0))
+ converted = true;
+ else if (validate_change (insn, &SET_SRC (set),
+ copy_rtx (SET_DEST (set)), 0))
+ converted = true;
+ if (converted)
+ {
+ if (gcse_file)
+ fprintf (gcse_file,
+ "LOCAL COPY-PROP: Set in insn %d turned into noop",
+ INSN_UID (insn));
+ if (noop_move_p (insn)
+ && !find_reg_note (insn, REG_LIBCALL, NULL_RTX))
+ delete_insn (insn);
+ continue;
+ }
+ }
do
{
reg_use_count = 0;
Index: cselib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cselib.c,v
retrieving revision 1.26
diff -c -3 -p -r1.26 cselib.c
*** cselib.c 14 Mar 2003 20:15:11 -0000 1.26
--- cselib.c 24 Mar 2003 18:12:33 -0000
*************** rtx_equal_for_cselib_p (x, y)
*** 541,546 ****
--- 541,570 ----
return 1;
}
+ /* Return nonzero if the destination of SET equals the source
+ and there are no side effects. Use cselib infromation to recognize
+ nontrivial cases. */
+
+ bool
+ cselib_set_noop_p (set)
+ rtx set;
+ {
+ rtx src = SET_SRC (set);
+ rtx dst = SET_DEST (set);
+
+ if (GET_CODE (dst) == STRICT_LOW_PART)
+ dst = XEXP (dst, 0);
+ if ((GET_CODE (dst) == SIGN_EXTRACT
+ || GET_CODE (dst) == ZERO_EXTRACT)
+ && ! BYTES_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx)
+ dst = XEXP (dst, 0);
+
+ if (rtx_equal_for_cselib_p (src, dst))
+ return !side_effects_p (src) && !side_effects_p (dst);
+
+ return false;
+ }
+
/* We need to pass down the mode of constants through the hash table
functions. For that purpose, wrap them in a CONST of the appropriate
mode. */
Index: cselib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cselib.h,v
retrieving revision 1.7
diff -c -3 -p -r1.7 cselib.h
*** cselib.h 11 Mar 2003 21:52:41 -0000 1.7
--- cselib.h 24 Mar 2003 18:12:33 -0000
*************** extern void cselib_update_varray_sizes P
*** 67,72 ****
--- 67,73 ----
extern void cselib_init PARAMS ((void));
extern void cselib_finish PARAMS ((void));
extern void cselib_process_insn PARAMS ((rtx));
+ extern bool cselib_set_noop_p PARAMS ((rtx));
extern int rtx_equal_for_cselib_p PARAMS ((rtx, rtx));
extern int references_value_p PARAMS ((rtx, int));
extern rtx cselib_subst_to_values PARAMS ((rtx));
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
@ 2003-03-22 8:16 Glen Nakamura
0 siblings, 0 replies; 6+ messages in thread
From: Glen Nakamura @ 2003-03-22 8:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10185; it has been noted by GNATS.
From: Glen Nakamura <glen@imodulo.com>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, rassahah@neofonie.de
Cc:
Subject: Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
Date: Fri, 21 Mar 2003 22:13:39 -1000
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10185
Aloha,
This bug has similar symptoms to PR opt/10087. The gcse pass generates
the following code (notice insn 106 is redundant to insn 103):
(insn 22 88 103 3 0x4014b764 (parallel [
(set (reg/s:SI 65)
(plus:SI (reg:SI 79)
(const_int -1 [0xffffffff])))
(clobber (reg:CC 17 flags))
]) 146 {*addsi_1} (nil)
(nil))
(insn 103 22 23 3 (nil) (set (reg:SI 79)
(reg/s:SI 65)) 38 {*movsi_1} (nil)
(nil))
(insn 23 103 106 3 0x4014b764 (set (mem/f:SI (plus:SI (reg/f:SI 20 frame)
(const_int -4 [0xfffffffc])) [5 S4 A32])
(reg/s:SI 65)) 38 {*movsi_1} (nil)
(expr_list:REG_EQUAL (plus:SI (reg:SI 67)
(const_int -1 [0xffffffff]))
(nil)))
(insn 106 23 25 3 (nil) (set (reg:SI 79)
(reg/s:SI 65)) 38 {*movsi_1} (nil)
(nil))
The loop pass then considers insn 103 and insn 106 as places where biv 79
is incremented. This is incorrect since insn 106 sets reg 76 to the same
value as insn 103. Now during strength reduction, the giv is incremented
after insn 103 and insn 106 resulting in a delta that is twice the correct
value. This test case passes with the patch from:
http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01932.html
- glen
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
@ 2003-03-22 1:16 Janis Johnson
0 siblings, 0 replies; 6+ messages in thread
From: Janis Johnson @ 2003-03-22 1:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10185; it has been noted by GNATS.
From: Janis Johnson <janis187@us.ibm.com>
To: Steven Bosscher <s.bosscher@student.tudelft.nl>
Cc: rassahah@neofonie.de, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org, janis187@us.ibm.com, jh@suse.cz
Subject: Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
Date: Fri, 21 Mar 2003 17:16:51 -0800
The regression appeared with this patch:
Sun Jul 21 00:54:54 CEST 2002 Jan Hubicka <jh@suse.cz>
* gcse.c: Include cselib.h
(constptop_register): Break out from ...
(cprop_insn): ... here; kill basic_block argument.
(do_local_cprop, local_cprop_pass): New functions.
(one_cprop_pass): Call local_cprop_pass.
My testing used the submitter's test case with -O2 on
i686-pc-linux-gnu.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
@ 2003-03-21 22:56 Steven Bosscher
0 siblings, 0 replies; 6+ messages in thread
From: Steven Bosscher @ 2003-03-21 22:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10185; it has been noted by GNATS.
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: rassahah@neofonie.de, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org,
janis187@us.ibm.com
Cc:
Subject: Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs
& optimization
Date: Fri, 21 Mar 2003 23:54:04 +0100
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10185
Janis,
You offered to track down PRs some time ago with your (very
nice) regression hunter scripts. Can you please hunt this one
down? It must have been introduced between January 2002
(3.[12] branched) and January 2003 (3.3 branched).
Greetz
Steevn
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
@ 2003-03-21 15:40 bangerth
0 siblings, 0 replies; 6+ messages in thread
From: bangerth @ 2003-03-21 15:40 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, rassahah
Old Synopsis: Wrong code with 3-int-structs & optimization
New Synopsis: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 21 15:40:24 2003
State-Changed-Why:
Confirmed, a regression on 3.3 and mainline w.r.t. 3.2.2.
Here's a slightly simpler code:
--------------------
typedef struct {
int x1, dummy1, dummy2;
} X;
void barrier (int *dummy) {}
main ()
{
static X x[] = {{1}, {2}, {5}};
int i=3, flag=0;
barrier(&i);
while (i--)
if (x[i].x1 == 2) // should trigger for i==1
flag = 1;
if (flag != 1)
abort ();
}
-------------------------------
The abort() shouldn't be triggered, but is if compiled
with -O2 in 3.3 and mainline:
g/x> /home/bangerth/bin/gcc-3.2.2-pre/bin/gcc -O2 x.c ; ./a.out
g/x> /home/bangerth/bin/gcc-3.3-pre/bin/gcc -O2 x.c ; ./a.out
Aborted
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -O2 x.c ; ./a.out
Aborted
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10185
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-03-24 18:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-24 19:08 optimization/10185: [3.3/3.4 regression] Wrong code with 3-int-structs & optimization mmitchel
-- strict thread matches above, loose matches on Subject: below --
2003-03-24 18:39 Jan Hubicka
2003-03-22 8:16 Glen Nakamura
2003-03-22 1:16 Janis Johnson
2003-03-21 22:56 Steven Bosscher
2003-03-21 15:40 bangerth
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).