public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+
@ 2005-03-04 17:50 jakub at gcc dot gnu dot org
2005-03-04 18:13 ` [Bug target/20322] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-03-04 17:50 UTC (permalink / raw)
To: gcc-bugs
libcpp/expr.c is miscompiled when compiled with gcc-4_0-branch GCC on x86-64
(and likely i386 as well).
expr.c miscompiled that way causes a testsuite regression on arith-3.c:
FAIL: gcc.dg/cpp/arith-3.c (test for bogus messages, line 257)
Self-contained testcase that reproduces the problem is:
extern void abort (void);
typedef unsigned long long T;
typedef struct
{
T a, b;
unsigned char c, d;
} S;
#define M (sizeof (T) * 4)
S __attribute__((noinline))
foo (T x, T y)
{
S e;
T f[2], g;
e.b = (x & (~(T) 0 >> M)) * (y & (~(T) 0 >> M));
e.a = (x >> M) * (y >> M);
f[0] = (x & (~(T) 0 >> M)) * (y >> M);
f[1] = (x >> M) * (y & (~(T) 0 >> M));
g = e.b;
e.b += (f[0] & (~(T) 0 >> M)) << M;
if (e.b < g)
e.a++;
g = e.b;
e.b += (f[1] & (~(T) 0 >> M)) << M;
if (e.b < g)
e.a++;
e.a += (f[0] >> M);
e.a += (f[1] >> M);
e.c = 1;
e.d = 0;
return e;
}
int
main (void)
{
T x = 1ULL << (M * 2 - 1);
S y = foo (1, x);
if (y.a || y.b != x || y.c != 1 || y.d)
abort ();
return 0;
}
--
Summary: Miscompilation of libcpp/expr.c at -O2+
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: x86_64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
@ 2005-03-04 18:13 ` pinskia at gcc dot gnu dot org
2005-03-04 18:16 ` [Bug target/20322] [4.0/4.1 " pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-04 18:13 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Keywords| |wrong-code
Summary|Miscompilation of |[4.0 Regression]
|libcpp/expr.c at -O2+ |Miscompilation of
| |libcpp/expr.c at -O2+
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
2005-03-04 18:13 ` [Bug target/20322] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-03-04 18:16 ` pinskia at gcc dot gnu dot org
2005-03-04 18:31 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-04 18:16 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.0 Regression] |[4.0/4.1 Regression]
|Miscompilation of |Miscompilation of
|libcpp/expr.c at -O2+ |libcpp/expr.c at -O2+
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
2005-03-04 18:13 ` [Bug target/20322] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-03-04 18:16 ` [Bug target/20322] [4.0/4.1 " pinskia at gcc dot gnu dot org
@ 2005-03-04 18:31 ` jakub at gcc dot gnu dot org
2005-03-07 16:06 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-03-04 18:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-03-04 18:30 -------
>From initial skimming, this sounds like combiner bug.
(insn 78 41 79 0 (set (reg:CC 17 flags)
(compare:CC (reg:DI 58 [ e$b.9 ])
(reg:DI 59 [ e$b.8 ]))) 2 {cmpdi_1_insn_rex64}
(insn_list:REG_DEP_TRUE 41 (nil))
(expr_list:REG_DEAD (reg:DI 59 [ e$b.8 ])
(nil)))
(insn 79 78 52 0 (parallel [
(set (reg:DI 64 [ e$a ])
(plus:DI (plus:DI (ltu:DI (reg:CC 17 flags)
(const_int 0 [0x0]))
(reg:DI 64 [ e$a ]))
(const_int 0 [0x0])))
(clobber (reg:CC 17 flags))
]) 174 {adddi3_carry_rex64} (insn_list:REG_DEP_TRUE 77
(insn_list:REG_DEP_TRUE 78 (nil)))
(expr_list:REG_DEAD (reg:CC 17 flags)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
(insn 52 79 53 0 (parallel [
(set (reg:DI 76)
(lshiftrt:DI (reg:DI 61 [ f$0 ])
(const_int 32 [0x20])))
(clobber (reg:CC 17 flags))
]) 435 {*lshrdi3_1_rex64} (nil)
(expr_list:REG_DEAD (reg:DI 61 [ f$0 ])
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
(insn 53 52 55 0 (parallel [
(set (reg:DI 60 [ e$a.6 ])
(plus:DI (reg:DI 64 [ e$a ])
(reg:DI 76)))
(clobber (reg:CC 17 flags))
]) 192 {*adddi_1_rex64} (insn_list:REG_DEP_TRUE 79
(insn_list:REG_DEP_TRUE 52 (nil)))
(expr_list:REG_DEAD (reg:DI 64 [ e$a ])
(expr_list:REG_DEAD (reg:DI 76)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil)))))
before combine is turned into:
(insn 78 41 79 0 (set (reg:CC 17 flags)
(compare:CC (reg:DI 58 [ e$b.9 ])
(reg:DI 59 [ e$b.8 ]))) 2 {cmpdi_1_insn_rex64}
(insn_list:REG_DEP_TRUE 41 (nil))
(expr_list:REG_DEAD (reg:DI 59 [ e$b.8 ])
(nil)))
(note 79 78 52 0 NOTE_INSN_DELETED)
(insn 52 79 53 0 (parallel [
(set (reg:DI 76)
(lshiftrt:DI (reg:DI 61 [ f$0 ])
(const_int 32 [0x20])))
(clobber (reg:CC 17 flags))
]) 435 {*lshrdi3_1_rex64} (nil)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(expr_list:REG_DEAD (reg:DI 61 [ f$0 ])
(nil))))
(insn 53 52 55 0 (parallel [
(set (reg:DI 60 [ e$a.6 ])
(plus:DI (plus:DI (ltu:DI (reg:CC 17 flags)
(const_int 0 [0x0]))
(reg:DI 64 [ e$a ]))
(reg:DI 76)))
(clobber (reg:CC 17 flags))
]) 174 {adddi3_carry_rex64} (insn_list:REG_DEP_TRUE 77
(insn_list:REG_DEP_TRUE 52 (nil)))
(expr_list:REG_UNUSED (reg:CC 17 flags)
(expr_list:REG_DEAD (reg:DI 76)
(expr_list:REG_DEAD (reg:DI 64 [ e$a ])
(nil)))))
which shouldn't be done, because the middle instruction is kept and clobbers
(reg:CC 17 flags), so combiner can't move use of %eflags from the first to the
last insn accross the clobber.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-03-04 18:31 ` jakub at gcc dot gnu dot org
@ 2005-03-07 16:06 ` jakub at gcc dot gnu dot org
2005-03-10 21:26 ` cvs-commit at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-03-07 16:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-03-07 16:06 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-03/msg00647.html>
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
Keywords| |patch
Last reconfirmed|0000-00-00 00:00:00 |2005-03-07 16:06:06
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-03-07 16:06 ` jakub at gcc dot gnu dot org
@ 2005-03-10 21:26 ` cvs-commit at gcc dot gnu dot org
2005-03-10 21:30 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-03-10 21:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-03-10 21:26 -------
Subject: Bug 20322
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: jakub@gcc.gnu.org 2005-03-10 21:26:12
Modified files:
gcc : ChangeLog combine.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.dg: 20050307-1.c
Log message:
PR target/20322
* combine.c (try_combine): If recog_for_combine added CLOBBERs
to NEWI2PAT, fail to combine if they are used by NEWPAT.
* gcc.dg/20050307-1.c: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7775&r2=2.7776
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&r1=1.478&r2=1.479
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5138&r2=1.5139
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20050307-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-03-10 21:26 ` cvs-commit at gcc dot gnu dot org
@ 2005-03-10 21:30 ` cvs-commit at gcc dot gnu dot org
2005-03-10 21:32 ` jakub at gcc dot gnu dot org
2005-03-11 14:01 ` uros at kss-loka dot si
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-03-10 21:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-03-10 21:30 -------
Subject: Bug 20322
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: jakub@gcc.gnu.org 2005-03-10 21:29:56
Modified files:
gcc : ChangeLog combine.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.dg: 20050307-1.c
Log message:
PR target/20322
* combine.c (try_combine): If recog_for_combine added CLOBBERs
to NEWI2PAT, fail to combine if they are used by NEWPAT.
* gcc.dg/20050307-1.c: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.39&r2=2.7592.2.40
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.475&r2=1.475.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.33&r2=1.5084.2.34
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20050307-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-03-10 21:30 ` cvs-commit at gcc dot gnu dot org
@ 2005-03-10 21:32 ` jakub at gcc dot gnu dot org
2005-03-11 14:01 ` uros at kss-loka dot si
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-03-10 21:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-03-10 21:31 -------
Fixed in CVS.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/20322] [4.0/4.1 Regression] Miscompilation of libcpp/expr.c at -O2+
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-03-10 21:32 ` jakub at gcc dot gnu dot org
@ 2005-03-11 14:01 ` uros at kss-loka dot si
7 siblings, 0 replies; 9+ messages in thread
From: uros at kss-loka dot si @ 2005-03-11 14:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2005-03-11 14:01 -------
Just FYI: arith-3.c still fails for me on pentium4. The sistem is fairly
unpatched Red Hat Linux release 8.0 (Psyche):
Linux moron 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux
Compiler version: 4.1.0 20050310 (experimental)
Platform: i686-pc-linux-gnu
libc-2.2.93.
Running target unix
FAIL: gcc.dg/cpp/arith-3.c (test for bogus messages, line 257)
XPASS: gcc.dg/vect/vect-22.c scan-tree-dump-times vectorized 3 loops 1
However, testcase from description compiles and runs OK with "gcc -O2 pr20322.c".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20322
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-03-11 14:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-04 17:50 [Bug target/20322] New: Miscompilation of libcpp/expr.c at -O2+ jakub at gcc dot gnu dot org
2005-03-04 18:13 ` [Bug target/20322] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-03-04 18:16 ` [Bug target/20322] [4.0/4.1 " pinskia at gcc dot gnu dot org
2005-03-04 18:31 ` jakub at gcc dot gnu dot org
2005-03-07 16:06 ` jakub at gcc dot gnu dot org
2005-03-10 21:26 ` cvs-commit at gcc dot gnu dot org
2005-03-10 21:30 ` cvs-commit at gcc dot gnu dot org
2005-03-10 21:32 ` jakub at gcc dot gnu dot org
2005-03-11 14:01 ` uros at kss-loka dot si
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).