public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/43438] New: possible wrong code bug
@ 2010-03-19 6:16 regehr at cs dot utah dot edu
2010-03-19 6:51 ` [Bug c/43438] " sezeroz at gmail dot com
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: regehr at cs dot utah dot edu @ 2010-03-19 6:16 UTC (permalink / raw)
To: gcc-bugs
The -O0 result looks right. This behavior observed on x86 using r157445 and
x64 using r157542.
regehr@john-home:~$ current-gcc -O0 small.c -o small -Wall
regehr@john-home:~$ ./small
1
regehr@john-home:~$ current-gcc -O1 small.c -o small -Wall
regehr@john-home:~$ ./small
0
regehr@john-home:~$ cat small.c
extern int printf (__const char *__restrict __format, ...);
static unsigned char g_2 = 1;
static int g_9;
static int *l_8 = &g_9;
static void func_12(int p_13)
{
int * l_17 = &g_9;
*l_17 &= 0 < p_13;
}
int main(void)
{
unsigned char l_11 = 254;
*l_8 |= g_2;
l_11 |= *l_8;
func_12(l_11);
printf("%d\n", g_9);
return 0;
}
regehr@john-home:~$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/home/regehr/z/compiler-install/gcc-r157445-install/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r157445-install
--program-prefix=r157445- --enable-languages=c,c++
Thread model: posix
gcc version 4.5.0 20100314 (experimental) (GCC)
--
Summary: possible 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=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/43438] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
@ 2010-03-19 6:51 ` sezeroz at gmail dot com
2010-03-19 9:47 ` mikpe at it dot uu dot se
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: sezeroz at gmail dot com @ 2010-03-19 6:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sezeroz at gmail dot com 2010-03-19 06:51 -------
Happened on x86_64-pc-linux and my gcc-4.4 was affected too, gcc-3.4.6 seemed
fine.
--
sezeroz at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sezeroz at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/43438] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
2010-03-19 6:51 ` [Bug c/43438] " sezeroz at gmail dot com
@ 2010-03-19 9:47 ` mikpe at it dot uu dot se
2010-03-19 11:02 ` [Bug c/43438] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mikpe at it dot uu dot se @ 2010-03-19 9:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from mikpe at it dot uu dot se 2010-03-19 09:46 -------
4.2.4/4.3.4/4.4.3 are affected, 4.1.2 and older seem to be Ok.
--
mikpe at it dot uu dot se changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/43438] [4.3/4.4/4.5 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
2010-03-19 6:51 ` [Bug c/43438] " sezeroz at gmail dot com
2010-03-19 9:47 ` mikpe at it dot uu dot se
@ 2010-03-19 11:02 ` rguenth at gcc dot gnu dot org
2010-03-19 11:29 ` [Bug rtl-optimization/43438] " rguenth at gcc dot gnu dot org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-19 11:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-03-19 11:02 -------
Confirmed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|i686-pc-linux-gnu |
GCC host triplet|i686-pc-linux-gnu |
GCC target triplet|i686-pc-linux-gnu |i?86-*-* x86_64-*-*
Keywords| |wrong-code
Known to fail| |4.3.4 4.4.3 4.5.0
Known to work| |4.1.2
Last reconfirmed|0000-00-00 00:00:00 |2010-03-19 11:02:13
date| |
Summary|possible wrong code bug |[4.3/4.4/4.5 Regression]
| |possible wrong code bug
Target Milestone|--- |4.3.5
Version|unknown |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4/4.5 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (2 preceding siblings ...)
2010-03-19 11:02 ` [Bug c/43438] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
@ 2010-03-19 11:29 ` rguenth at gcc dot gnu dot org
2010-03-19 11:35 ` rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-19 11:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2010-03-19 11:29 -------
Combine breaks this.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |rtl-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4/4.5 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (3 preceding siblings ...)
2010-03-19 11:29 ` [Bug rtl-optimization/43438] " rguenth at gcc dot gnu dot org
@ 2010-03-19 11:35 ` rguenth at gcc dot gnu dot org
2010-03-19 12:06 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-19 11:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2010-03-19 11:35 -------
It combines
(insn 6 5 7 2 t.c:16 (parallel [
(set (reg:SI 59 [ D.2732 ])
(ior:SI (reg:SI 67 [ g_9 ])
(const_int 1 [0x1])))
(clobber (reg:CC 17 flags))
]) 394 {*iorsi_1} (expr_list:REG_DEAD (reg:SI 67 [ g_9 ])
(expr_list:REG_UNUSED (reg:CC 17 flags)
(expr_list:REG_EQUAL (ior:SI (mem/c/i:SI (symbol_ref:DI ("g_9")
[flags 0x2] <var_decl 0x7ffff5ae50a0 g_9>) [0 g_9+0 S4 A32])
(const_int 1 [0x1]))
(nil)))))
(insn 7 6 8 2 t.c:10 (parallel [
(set (reg:QI 68)
(ior:QI (subreg:QI (reg:SI 59 [ D.2732 ]) 0)
(const_int -2 [0xfffffffffffffffe])))
(clobber (reg:CC 17 flags))
]) 398 {*iorqi_1} (expr_list:REG_UNUSED (reg:CC 17 flags)
(nil)))
(insn 8 7 9 2 t.c:10 (parallel [
(set (reg:SI 69)
(zero_extend:SI (reg:QI 68)))
(clobber (reg:CC 17 flags))
]) 119 {*zero_extendqisi2_movzbl_and} (expr_list:REG_DEAD (reg:QI 68)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
and somewhere forgets to apply the zero-extension:
Successfully matched this instruction:
(set (reg:SI 59 [ D.2732 ])
(ior:SI (reg:SI 67 [ g_9 ])
(const_int 1 [0x1])))
Successfully matched this instruction:
(set (reg:SI 69)
(const_int -1 [0xffffffffffffffff]))
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4/4.5 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (4 preceding siblings ...)
2010-03-19 11:35 ` rguenth at gcc dot gnu dot org
@ 2010-03-19 12:06 ` rguenth at gcc dot gnu dot org
2010-03-19 12:41 ` rguenth at gcc dot gnu dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-19 12:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2010-03-19 12:06 -------
Breakpoint 7, combine_simplify_rtx (x=0x7ffff5ae6e58, op0_mode=VOIDmode,
in_dest=0) at /space/rguenther/src/svn/trunk/gcc/combine.c:4861
4861 enum rtx_code code = GET_CODE (x);
(set (reg:SI 69)
(and:SI (subreg:SI (ior:QI (subreg:QI (ior:SI (reg:SI 67 [ g_9 ])
(const_int 1 [0x1])) 0)
(const_int -2 [0xfffffffffffffffe])) 0)
(const_int 255 [0xff])))
(gdb) finish
Value returned is $19 = (struct rtx_def *) 0x7ffff5ae6e58
(gdb) call debug_rtx ($19)
(set (reg:SI 69)
(const_int -1 [0xffffffffffffffff]))
but combine_simplify_rtx didn't simplify the subexpressions without the
set. Hm.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2010-03-19 11:02:13 |2010-03-19 12:06:17
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4/4.5 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (5 preceding siblings ...)
2010-03-19 12:06 ` rguenth at gcc dot gnu dot org
@ 2010-03-19 12:41 ` rguenth at gcc dot gnu dot org
2010-03-20 13:44 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-19 12:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2010-03-19 12:40 -------
make_extraction (mode=SImode, inner=0x7ffff5b48ac8, pos=0, pos_rtx=0x0, len=8,
unsignedp=1, in_dest=0, in_compare=0)
at /space/rguenther/src/svn/trunk/gcc/combine.c:6648
6648 enum machine_mode is_mode = GET_MODE (inner);
(gdb) call debug_rtx (inner)
(subreg:SI (ior:QI (subreg:QI (ior:SI (reg:SI 67 [ g_9 ])
(const_int 1 [0x1])) 0)
(const_int -2 [0xfffffffffffffffe])) 0)
if (CONST_INT_P (new_rtx))
return gen_int_mode (INTVAL (new_rtx), mode);
misses the nececssary truncation. Dropping the special casing works
(but doesn't optimize). Fixing the appearantly many issues works as well.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4/4.5 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (6 preceding siblings ...)
2010-03-19 12:41 ` rguenth at gcc dot gnu dot org
@ 2010-03-20 13:44 ` rguenth at gcc dot gnu dot org
2010-03-20 13:44 ` [Bug rtl-optimization/43438] [4.3/4.4 " rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-20 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2010-03-20 13:44 -------
Subject: Bug 43438
Author: rguenth
Date: Sat Mar 20 13:44:18 2010
New Revision: 157592
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157592
Log:
2010-03-20 Richard Guenther <rguenther@suse.de>
PR rtl-optimization/43438
* combine.c (make_extraction): Properly zero-/sign-extend an
extraction of the low part of a CONST_INT. Also handle
CONST_DOUBLE.
* gcc.c-torture/execute/pr43438.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr43438.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/combine.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (7 preceding siblings ...)
2010-03-20 13:44 ` rguenth at gcc dot gnu dot org
@ 2010-03-20 13:44 ` rguenth at gcc dot gnu dot org
2010-03-22 15:06 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-20 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2010-03-20 13:44 -------
Fixed for 4.5 sofar.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.3.4 4.4.3 4.5.0 |4.3.4 4.4.3
Known to work|4.1.2 |4.1.2 4.5.0
Summary|[4.3/4.4/4.5 Regression] |[4.3/4.4 Regression]
|possible wrong code bug |possible wrong code bug
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3/4.4 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (8 preceding siblings ...)
2010-03-20 13:44 ` [Bug rtl-optimization/43438] [4.3/4.4 " rguenth at gcc dot gnu dot org
@ 2010-03-22 15:06 ` jakub at gcc dot gnu dot org
2010-03-22 15:28 ` [Bug rtl-optimization/43438] [4.3 " jakub at gcc dot gnu dot org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-03-22 15:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jakub at gcc dot gnu dot org 2010-03-22 15:06 -------
Subject: Bug 43438
Author: jakub
Date: Mon Mar 22 15:05:46 2010
New Revision: 157634
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157634
Log:
Backport from mainline:
2010-03-20 Richard Guenther <rguenther@suse.de>
PR rtl-optimization/43438
* combine.c (make_extraction): Properly zero-/sign-extend an
extraction of the low part of a CONST_INT. Also handle
CONST_DOUBLE.
* gcc.c-torture/execute/pr43438.c: New testcase.
Added:
branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr43438.c
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/combine.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (9 preceding siblings ...)
2010-03-22 15:06 ` jakub at gcc dot gnu dot org
@ 2010-03-22 15:28 ` jakub at gcc dot gnu dot org
2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-03-22 15:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jakub at gcc dot gnu dot org 2010-03-22 15:28 -------
Fixed also on 4.4 branch.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|4.1.2 4.5.0 |4.1.2 4.5.0 4.4.4
Summary|[4.3/4.4 Regression] |[4.3 Regression] possible
|possible wrong code bug |wrong code bug
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (11 preceding siblings ...)
2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
@ 2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-20 13:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from rguenth at gcc dot gnu dot org 2010-04-20 13:09 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/43438] [4.3 Regression] possible wrong code bug
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
` (10 preceding siblings ...)
2010-03-22 15:28 ` [Bug rtl-optimization/43438] [4.3 " jakub at gcc dot gnu dot org
@ 2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-20 13:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from rguenth at gcc dot gnu dot org 2010-04-20 13:10 -------
Subject: Bug 43438
Author: rguenth
Date: Tue Apr 20 13:09:42 2010
New Revision: 158555
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158555
Log:
2010-04-20 Richard Guenther <rguenther@suse.de>
PR rtl-optimization/43438
* combine.c (make_extraction): Properly zero-/sign-extend an
extraction of the low part of a CONST_INT.
* gcc.c-torture/execute/pr43438.c: New testcase.
Added:
branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr43438.c
Modified:
branches/gcc-4_3-branch/gcc/ChangeLog
branches/gcc-4_3-branch/gcc/combine.c
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43438
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-04-20 13:10 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-19 6:16 [Bug c/43438] New: possible wrong code bug regehr at cs dot utah dot edu
2010-03-19 6:51 ` [Bug c/43438] " sezeroz at gmail dot com
2010-03-19 9:47 ` mikpe at it dot uu dot se
2010-03-19 11:02 ` [Bug c/43438] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-03-19 11:29 ` [Bug rtl-optimization/43438] " rguenth at gcc dot gnu dot org
2010-03-19 11:35 ` rguenth at gcc dot gnu dot org
2010-03-19 12:06 ` rguenth at gcc dot gnu dot org
2010-03-19 12:41 ` rguenth at gcc dot gnu dot org
2010-03-20 13:44 ` rguenth at gcc dot gnu dot org
2010-03-20 13:44 ` [Bug rtl-optimization/43438] [4.3/4.4 " rguenth at gcc dot gnu dot org
2010-03-22 15:06 ` jakub at gcc dot gnu dot org
2010-03-22 15:28 ` [Bug rtl-optimization/43438] [4.3 " jakub at gcc dot gnu dot org
2010-04-20 13:10 ` rguenth at gcc dot gnu dot org
2010-04-20 13:10 ` rguenth 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).