public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44858] New: likely integer wrong code bug
@ 2010-07-07 14:12 regehr at cs dot utah dot edu
2010-07-08 8:14 ` [Bug rtl-optimization/44858] " jakub at gcc dot gnu dot org
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: regehr at cs dot utah dot edu @ 2010-07-07 14:12 UTC (permalink / raw)
To: gcc-bugs
regehr@john-home:~$ current-gcc -O0 small.c -o small
regehr@john-home:~$ ./small
checksum g_610 = 1
regehr@john-home:~$ current-gcc -O1 small.c -o small
regehr@john-home:~$ ./small
checksum g_610 = 0
regehr@john-home:~$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/home/regehr/z/compiler-install/gcc-r161813-install/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r161813-install
--program-prefix=r161813- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20100704 (experimental) (GCC)
regehr@john-home:~$ cat small.c
extern int printf (__const char *__restrict __format, ...);
int g_33 = 3;
int g_610 = 1;
long long foo(int i1, int i2)
{
return (i1 / i2);
}
int main(void)
{
int l_2 = 2;
l_2 &= foo(1, g_610) > g_610;
g_610 = (g_33 != 0) | l_2;
printf("checksum g_610 = %d\n", g_610);
return l_2;
}
--
Summary: likely integer wrong code bug
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: regehr at cs dot utah dot edu
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
@ 2010-07-08 8:14 ` jakub at gcc dot gnu dot org
2010-07-08 8:37 ` jakub at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-08 8:14 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Component|c |rtl-optimization
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-07-08 08:14:08
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
2010-07-08 8:14 ` [Bug rtl-optimization/44858] " jakub at gcc dot gnu dot org
@ 2010-07-08 8:37 ` jakub at gcc dot gnu dot org
2010-07-08 9:59 ` [Bug rtl-optimization/44858] [4.5/4.6 Regression] " jakub at gcc dot gnu dot org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-08 8:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jakub at gcc dot gnu dot org 2010-07-08 08:37 -------
Things go wrong in the combiner:
(insn 21 42 22 6 pr44858.c:16 (parallel [
(set (reg/v:SI 62 [ c ])
(and:SI (reg:SI 68)
(const_int 2 [0x2])))
(clobber (reg:CC 17 flags))
]) 375 {*andsi_1} (expr_list:REG_DEAD (reg:SI 68)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
(insn 22 21 23 6 pr44858.c:17 (set (reg:CCZ 17 flags)
(compare:CCZ (mem/c/i:SI (symbol_ref:SI ("a") [flags 0x2] <var_decl
0x7f8d06f05000 a>) [0 a+0 S4 A32])
(const_int 0 [0]))) 2 {*cmpsi_ccno_1} (nil))
(insn 23 22 24 6 pr44858.c:17 (set (reg:QI 70)
(ne:QI (reg:CCZ 17 flags)
(const_int 0 [0]))) 570 {*setcc_qi} (expr_list:REG_DEAD (reg:CCZ 17
flags)
(nil)))
(insn 24 23 25 6 pr44858.c:17 (parallel [
(set (reg:SI 69)
(zero_extend:SI (reg:QI 70)))
(clobber (reg:CC 17 flags))
]) 119 {*zero_extendqisi2_movzbl_and} (expr_list:REG_DEAD (reg:QI 70)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
(insn 25 24 26 6 pr44858.c:17 (parallel [
(set (reg:SI 65 [ b.2 ])
(ior:SI (reg/v:SI 62 [ c ])
(reg:SI 69)))
(clobber (reg:CC 17 flags))
]) 394 {*iorsi_1} (expr_list:REG_DEAD (reg:SI 69)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
changes into:
(note 21 42 22 6 NOTE_INSN_DELETED)
(insn 22 21 23 6 pr44858.c:17 (set (reg:CCZ 17 flags)
(compare:CCZ (mem/c/i:SI (symbol_ref:SI ("a") [flags 0x2] <var_decl
0x7f8d06f05000 a>) [0 a+0 S4 A32])
(const_int 0 [0]))) 2 {*cmpsi_ccno_1} (nil))
(note 23 22 24 6 NOTE_INSN_DELETED)
(insn 24 23 25 6 pr44858.c:17 (parallel [
(set (reg/v:SI 62 [ c ])
(and:SI (reg:SI 68)
(const_int 2 [0x2])))
(clobber (reg:CC 17 flags))
]) 375 {*andsi_1} (expr_list:REG_UNUSED (reg:CC 17 flags)
(expr_list:REG_DEAD (reg:SI 68)
(nil))))
(insn 25 24 26 6 pr44858.c:17 (set (reg:SI 65 [ b.2 ])
(ne:SI (reg:CCZ 17 flags)
(const_int 0 [0]))) 569 {*setcc_si_1_movzbl} (expr_list:REG_DEAD
(reg:CC 17 flags)
(nil)))
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
2010-07-08 8:14 ` [Bug rtl-optimization/44858] " jakub at gcc dot gnu dot org
2010-07-08 8:37 ` jakub at gcc dot gnu dot org
@ 2010-07-08 9:59 ` jakub at gcc dot gnu dot org
2010-07-08 10:01 ` jakub at gcc dot gnu dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-08 9:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jakub at gcc dot gnu dot org 2010-07-08 09:58 -------
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152642
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |uros at gcc dot gnu dot org
AssignedTo|jakub at gcc dot gnu dot org|unassigned at gcc dot gnu
| |dot org
Status|ASSIGNED |NEW
Summary|likely integer wrong code |[4.5/4.6 Regression] likely
|bug |integer wrong code bug
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (2 preceding siblings ...)
2010-07-08 9:59 ` [Bug rtl-optimization/44858] [4.5/4.6 Regression] " jakub at gcc dot gnu dot org
@ 2010-07-08 10:01 ` jakub at gcc dot gnu dot org
2010-07-08 14:44 ` jakub at gcc dot gnu dot org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-08 10:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jakub at gcc dot gnu dot org 2010-07-08 10:01 -------
Updated testcase:
extern void abort (void);
int a = 3;
int b = 1;
__attribute__((noinline)) long long
foo (int x, int y)
{
return x / y;
}
__attribute__((noinline)) int
bar (void)
{
int c = 2;
c &= foo (1, b) > b;
b = (a != 0) | c;
return c;
}
int
main (void)
{
if (bar () != 0 || b != 1)
abort ();
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (3 preceding siblings ...)
2010-07-08 10:01 ` jakub at gcc dot gnu dot org
@ 2010-07-08 14:44 ` jakub at gcc dot gnu dot org
2010-07-22 8:58 ` rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-08 14:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jakub at gcc dot gnu dot org 2010-07-08 14:44 -------
Created an attachment (id=21147)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21147&action=view)
gcc46-vrp.patch
So, combiner seems to be the first to notice that c must be actually zero
(2 & (x > y)).
This patch just tries to notice it earlier, during VRP, which of course isn't a
fix for this bug (which is somewhere in the combiner where it doesn't notice
that when it moves the and insn it clobbers cc which is needed), just makes it
latent for -O2 (still present at -O1 or -O2 -fno-tree-vrp).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (4 preceding siblings ...)
2010-07-08 14:44 ` jakub at gcc dot gnu dot org
@ 2010-07-22 8:58 ` rguenth at gcc dot gnu dot org
2010-07-22 9:06 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-22 8:58 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.5.1
Version|unknown |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (5 preceding siblings ...)
2010-07-22 8:58 ` rguenth at gcc dot gnu dot org
@ 2010-07-22 9:06 ` rguenth at gcc dot gnu dot org
2010-07-22 9:36 ` jakub at gcc dot gnu dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-22 9:06 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (6 preceding siblings ...)
2010-07-22 9:06 ` rguenth at gcc dot gnu dot org
@ 2010-07-22 9:36 ` jakub at gcc dot gnu dot org
2010-07-31 9:35 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-22 9:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2010-07-22 09:36 -------
The VRP changes have been committed, so on the trunk this will be now
reproduceable only with -O1 or -O2 -fno-tree-vrp.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (7 preceding siblings ...)
2010-07-22 9:36 ` jakub at gcc dot gnu dot org
@ 2010-07-31 9:35 ` rguenth at gcc dot gnu dot org
2010-08-25 13:26 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-31 9:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2010-07-31 09:29 -------
GCC 4.5.1 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.5.1 |4.5.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (8 preceding siblings ...)
2010-07-31 9:35 ` rguenth at gcc dot gnu dot org
@ 2010-08-25 13:26 ` jakub at gcc dot gnu dot org
2010-08-25 14:01 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-08-25 13:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jakub at gcc dot gnu dot org 2010-08-25 13:25 -------
Created an attachment (id=21560)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21560&action=view)
gcc46-pr44858.patch
The combiner bug seems to be similar to PR20322, attached untested patch should
fix it.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (9 preceding siblings ...)
2010-08-25 13:26 ` jakub at gcc dot gnu dot org
@ 2010-08-25 14:01 ` jakub at gcc dot gnu dot org
2010-08-25 17:51 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-08-25 14:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jakub at gcc dot gnu dot org 2010-08-25 14:01 -------
Created an attachment (id=21561)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21561&action=view)
gcc46-pr44858-2.patch
Alternate patch, which doesn't give up so easily (usually both sets can go in
any order, so if added clobbers prevent one order, this patch tries the other
order too and only gives up if both orders aren't going to work).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (10 preceding siblings ...)
2010-08-25 14:01 ` jakub at gcc dot gnu dot org
@ 2010-08-25 17:51 ` jakub at gcc dot gnu dot org
2010-08-25 21:25 ` jakub at gcc dot gnu dot org
2010-08-25 21:27 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-08-25 17:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jakub at gcc dot gnu dot org 2010-08-25 17:51 -------
Subject: Bug 44858
Author: jakub
Date: Wed Aug 25 17:50:59 2010
New Revision: 163552
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163552
Log:
PR rtl-optimization/44858
* combine.c (try_combine): If recog_for_combine added CLOBBERs to
newi2pat, make sure they don't affect newpat.
* gcc.c-torture/execute/pr44858.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr44858.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/combine.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (11 preceding siblings ...)
2010-08-25 17:51 ` jakub at gcc dot gnu dot org
@ 2010-08-25 21:25 ` jakub at gcc dot gnu dot org
2010-08-25 21:27 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-08-25 21:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jakub at gcc dot gnu dot org 2010-08-25 21:25 -------
Subject: Bug 44858
Author: jakub
Date: Wed Aug 25 21:25:18 2010
New Revision: 163555
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163555
Log:
PR rtl-optimization/44858
* combine.c (try_combine): If recog_for_combine added CLOBBERs to
newi2pat, make sure they don't affect newpat.
* gcc.c-torture/execute/pr44858.c: New test.
Added:
branches/gcc-4_5-branch/gcc/testsuite/gcc.c-torture/execute/pr44858.c
Modified:
branches/gcc-4_5-branch/gcc/ChangeLog
branches/gcc-4_5-branch/gcc/combine.c
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/44858] [4.5/4.6 Regression] likely integer wrong code bug
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
` (12 preceding siblings ...)
2010-08-25 21:25 ` jakub at gcc dot gnu dot org
@ 2010-08-25 21:27 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-08-25 21:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jakub at gcc dot gnu dot org 2010-08-25 21:27 -------
Fixed.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44858
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2010-08-25 21:27 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07 14:12 [Bug c/44858] New: likely integer wrong code bug regehr at cs dot utah dot edu
2010-07-08 8:14 ` [Bug rtl-optimization/44858] " jakub at gcc dot gnu dot org
2010-07-08 8:37 ` jakub at gcc dot gnu dot org
2010-07-08 9:59 ` [Bug rtl-optimization/44858] [4.5/4.6 Regression] " jakub at gcc dot gnu dot org
2010-07-08 10:01 ` jakub at gcc dot gnu dot org
2010-07-08 14:44 ` jakub at gcc dot gnu dot org
2010-07-22 8:58 ` rguenth at gcc dot gnu dot org
2010-07-22 9:06 ` rguenth at gcc dot gnu dot org
2010-07-22 9:36 ` jakub at gcc dot gnu dot org
2010-07-31 9:35 ` rguenth at gcc dot gnu dot org
2010-08-25 13:26 ` jakub at gcc dot gnu dot org
2010-08-25 14:01 ` jakub at gcc dot gnu dot org
2010-08-25 17:51 ` jakub at gcc dot gnu dot org
2010-08-25 21:25 ` jakub at gcc dot gnu dot org
2010-08-25 21:27 ` jakub 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).