Bug 27266 - [4.2 Regression] syncronization primitives cause ICE with -march=pentium or better
Summary: [4.2 Regression] syncronization primitives cause ICE with -march=pentium or b...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Kazu Hirata
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-04-23 09:54 UTC by Rask Ingemann Lambertsen
Modified: 2006-05-22 17:56 UTC (History)
3 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work: 4.1.0
Known to fail: 4.2.0
Last reconfirmed: 2006-04-23 16:09:17


Attachments
Preprocessed source code (1.13 KB, text/plain)
2006-04-23 14:46 UTC, Rask Ingemann Lambertsen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rask Ingemann Lambertsen 2006-04-23 09:54:58 UTC
Mainline is ICE'ing on testsuite/gcc.c-torture/compile/sync-1.c for some arguments to -march. For example:

./xgcc -B. -O2 /mnt/sysfs/rask/cvssrc/gcc/gcc/testsuite/gcc.c-torture/compile/sync-1.c -S -o /tmp/sync-1.s -march=pentium
/mnt/sysfs/rask/cvssrc/gcc/gcc/testsuite/gcc.c-torture/compile/sync-1.c: In function 'test_lock':
/mnt/sysfs/rask/cvssrc/gcc/gcc/testsuite/gcc.c-torture/compile/sync-1.c:261: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

It works with: i386, i486, winchip-c6, winchip2 and c3.
It fails with: pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4, nocona, prescott, k6, k6-2, k6-3, k8, athlon, opteron and c3-2.

The gcc-4.1.0-3 compiler shipped by Red Hat fails in the same way for the same arguments to -march.
Comment 1 Rask Ingemann Lambertsen 2006-04-23 14:46:49 UTC
Created attachment 11317 [details]
Preprocessed source code
Comment 2 Andrew Pinski 2006-04-23 16:09:16 UTC
Note Redhat's 4.1.0 is closer to 4.2.0 than 4.1.0.

Anyways confirmed a regression in that it worked in 4.1.0.
Comment 3 Andrew Pinski 2006-04-23 16:10:04 UTC
Also here is the backtrace:
#0  split_di (operands=0xc0c768, num=0, lo_half=0x7fffff89ab58, 
    hi_half=0x7fffff89ab48)
    at /home/pinskia/src/newtest/trunk/gcc/config/i386/i386.c:8037
#1  0x00000000007ff0eb in ix86_expand_branch (code=<value optimized out>, 
    label=0x2aaaaae037d0)
    at /home/pinskia/src/newtest/trunk/gcc/config/i386/i386.c:10196
#2  0x00000000006c0ec6 in gen_bne (operand0=0x2aaaaae037d0) at i386.md:12951
#3  0x0000000000725a1b in expand_compare_and_swap_loop (mem=0x2aaaaafb3d20, 
    old_reg=0x2aaaaafb3d40, new_reg=0x2aaaaafb3f60, seq=<value optimized out>)
    at /home/pinskia/src/newtest/trunk/gcc/optabs.c:5960
#4  0x000000000072bfdc in expand_sync_operation (mem=0x2aaaaafb3d20, 
    val=<value optimized out>, code=AND)
    at /home/pinskia/src/newtest/trunk/gcc/optabs.c:6048
#5  0x0000000000533587 in expand_builtin (exp=0x2aaaaae03410, 
    target=0xafafafafafafafaf, subtarget=0x0, mode=12633960, ignore=13)
    at /home/pinskia/src/newtest/trunk/gcc/builtins.c:6279
#6  0x00000000005c37ae in expand_expr_real_1 (exp=<value optimized out>, 
    target=<value optimized out>, tmode=<value optimized out>, 
    modifier=EXPAND_NORMAL, alt_rtl=0x0)
    at /home/pinskia/src/newtest/trunk/gcc/expr.c:7584


This proves this is a target specific bug.
Comment 4 Andrew Pinski 2006-05-08 07:51:13 UTC
Janis could you do a regression hunt for this bug?
Comment 5 Janis Johnson 2006-05-09 23:57:32 UTC
A regression hunt using an i686-linux cross compiler on powerpc-linux with the testcase attached in comment #1 identified this large merge from gomp-branch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=108997

    r108997 | rth | 2005-12-23 00:43:34 +0000 (Fri, 23 Dec 2005)
Comment 6 Kazu Hirata 2006-05-20 08:00:26 UTC
Reduced down to:

signed long long sll;

void
foo (void)
{
  __sync_fetch_and_add (&sll, 1);
}
Comment 7 Kazu Hirata 2006-05-20 19:40:33 UTC
Posted a patch.

Comment 8 Richard Henderson 2006-05-22 17:38:04 UTC
Subject: Re:  [4.2 Regression] syncronization primitives cause ICE with -march=pentium or better

On Sat, May 20, 2006 at 07:40:33PM -0000, kazu at gcc dot gnu dot org wrote:
> Posted a patch.

Patch ok.


r~
Comment 9 Kazu Hirata 2006-05-22 17:56:02 UTC
Subject: Bug 27266

Author: kazu
Date: Mon May 22 17:55:53 2006
New Revision: 113987

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113987
Log:
gcc/
	PR target/27266
	* config/i386/i386.c (ix86_expand_branch): Jump to simple if
	ix86_compare_emitted is non-NULL.

gcc/testsuite/
	PR target/27266
	* gcc.target/i386/pr27266.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr27266.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Kazu Hirata 2006-05-22 17:56:35 UTC
Checked in a patch.