Bug 30825 - [4.3 Regression] current mainline fails to bootstrap when -msse is used
Summary: [4.3 Regression] current mainline fails to bootstrap when -msse is used
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P3 critical
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, ice-on-valid-code, ssemmx
: 30921 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-02-16 16:14 UTC by Julian v. Bock
Modified: 2007-02-23 18:20 UTC (History)
3 users (show)

See Also:
Host: i386-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-02-23 07:34:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julian v. Bock 2007-02-16 16:14:30 UTC
Hi,

current mainline (revision 122038) produces an ICE in stage 2 when configured with --with-arch=athlon64:

~/rcs-data/gcc-svn/configure --prefix=$HOME/env/gcc --enable-languages=c --with-arch=athlon64 && make

...

/home/julian/build/bld.gcc/./gcc/xgcc -B/home/julian/build/bld.gcc/./gcc/ -B/home/julian/env/gcc/i686-pc-linux-gnu/bin/ -B/home/julian/env/gcc/i686-pc-linux-gnu/lib/ -isystem /home/julian/env/gcc/i686-pc-linux-gnu/include -isystem /home/julian/env/gcc/i686-pc-linux-gnu/sys-include -O2 -g -O2 -O2  -O2 -g -O2  -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED   -I. -I. -I../.././gcc -I/home/julian/rcs-data/gcc-svn/libgcc -I/home/julian/rcs-data/gcc-svn/libgcc/. -I/home/julian/rcs-data/gcc-svn/libgcc/../gcc -I/home/julian/rcs-data/gcc-svn/libgcc/../include -I/home/julian/rcs-data/gcc-svn/libgcc/../libdecnumber -I../../libdecnumber -o _fixunsxfdi.o -MT _fixunsxfdi.o -MD -MP -MF _fixunsxfdi.dep -DL_fixunsxfdi -c /home/julian/rcs-data/gcc-svn/libgcc/../gcc/libgcc2.c \
          -fvisibility=hidden -DHIDE_EXPORTS
/home/julian/rcs-data/gcc-svn/libgcc/../gcc/libgcc2.c: In function '__fixunsxfdi':
/home/julian/rcs-data/gcc-svn/libgcc/../gcc/libgcc2.c:1245: error: verify_flow_info: Wrong probability of edge 7->9 -2147483648
/home/julian/rcs-data/gcc-svn/libgcc/../gcc/libgcc2.c:1245: error: verify_flow_info: Wrong probability of edge 7->8 -2147473648
/home/julian/rcs-data/gcc-svn/libgcc/../gcc/libgcc2.c:1245: internal compiler error: verify_flow_info failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[3]: *** [_fixunsxfdi.o] Error 1
make[3]: Leaving directory `/home/julian/build/bld.gcc/i686-pc-linux-gnu/libgcc'
make[2]: *** [all-stage2-target-libgcc] Error 2
make[2]: Leaving directory `/home/julian/build/bld.gcc'
make[1]: *** [stage2-bubble] Error 2
make[1]: Leaving directory `/home/julian/build/bld.gcc'
make: *** [all] Error 2


When configured without --with-arch=athlon64 the build succeeds. The problem has probably been introduced since 2007-02-09.
Comment 1 Andrew Pinski 2007-02-23 00:43:39 UTC
*** Bug 30921 has been marked as a duplicate of this bug. ***
Comment 2 Uroš Bizjak 2007-02-23 07:34:39 UTC
It is -msse that breaks the bootstrap.

'gmake bootstrap BOOT_CFLAGS="-O2"' bootstraps OK.
'gmake bootstrap BOOT_CFLAGS="-O2 -msse"' crashes.
Comment 3 Uroš Bizjak 2007-02-23 10:22:26 UTC
There is something wrong in combine_predictions_for_insn(). Perhaps stack gets corrupted, but from the comment:

	/* Use FP math to avoid overflows of 32bit integers.  */

combined_probability variable is _sometimes_ calculated as nan. Tracing through asm, it looks that it happens because fildl from stack loads 0x00001388, pushed to stack earlier.

BTW: For some reason gdb can't trace through this source, so it is really something strange going on.
Comment 4 Uroš Bizjak 2007-02-23 13:54:34 UTC
Got it.

This regression is indeed introduced by patch that fixes inter-unit moves
(http://gcc.gnu.org/viewcvs?view=rev&revision=121767) as was found out in PR 30921.

The failure is due to slight register preference change introduced by the above patch. The consequence of this change is, that a mmx register is allocated when -mmmx (or -msseX) is used in bootstrap flags. This affects all subsequent x87 FP calculations, so they always show "nan" in active shared x87/mm registers due to missing emms insn.

Attached patch tries to set register preferences back as they were before inter-unit moves patch. Using this patch, I was able to bootstrap gcc using "-O2 -msse" and "-O2 -march=pentium4" BOOT_CFLAGS. For the former case, patch was also regression tested for c testsuite without new failures.

2007-02-23  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.md (*movdi_1_rex64, zero_extendsidi2_32,
	zero_extendsidi2_rex64): Penalize MMX register<->memory moves.
	(*movsf_1): Penalize MMX moves.

Index: i386.md
===================================================================
--- i386.md	(revision 122219)
+++ i386.md	(working copy)
@@ -2022,9 +2022,9 @@
 
 (define_insn "*movdi_1_rex64"
   [(set (match_operand:DI 0 "nonimmediate_operand"
-	  "=r,r  ,r,m ,!m,*y,*y,?r ,m ,?*Ym,*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
+	  "=r,r  ,r,m ,!m,*y,*y,?r ,?m,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
 	(match_operand:DI 1 "general_operand"
-	  "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r   ,m ,C ,*x,*Yi,*x,r  ,m ,*Ym,*x"))]
+	  "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r   ,m  ,C ,*x,*Yi,*x,r  ,m ,*Ym,*x"))]
   "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
 {
   switch (get_attr_type (insn))
@@ -2326,9 +2326,9 @@
 
 (define_insn "*movsf_1"
   [(set (match_operand:SF 0 "nonimmediate_operand"
-	  "=f,m,f,r  ,m ,x,x,x ,m,*y,m ,*y,Yi,r ,*Ym,r  ")
+	  "=f,m,f,r  ,m ,x,x,x ,m,!*y,!m ,!*y,!Yi,!r ,!*Ym,!r ")
 	(match_operand:SF 1 "general_operand"
-	  "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y,r ,Yi,r  ,*Ym"))]
+	  "fm,f,G,rmF,Fr,C,x,xm,x,m  , *y, *y,r  ,Yi ,r   ,*Ym"))]
   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
    && (reload_in_progress || reload_completed
        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
@@ -3401,9 +3401,9 @@
 })
 
 (define_insn "zero_extendsidi2_32"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,*y,?*Yi,*Y2")
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,?*Y2")
 	(zero_extend:DI
-	 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r   ,m ,r   ,m")))
+	 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r   ,m  ,r   ,m")))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT"
   "@
@@ -3418,9 +3418,9 @@
    (set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")])
 
 (define_insn "zero_extendsidi2_rex64"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,*y,?*Yi,*Y2")
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,?*Y2")
      (zero_extend:DI
-       (match_operand:SI 1 "nonimmediate_operand"  "rm,0,r   ,m ,r   ,m")))]
+       (match_operand:SI 1 "nonimmediate_operand"  "rm,0,r   ,m  ,r   ,m")))]
   "TARGET_64BIT"
   "@
    mov\t{%k1, %k0|%k0, %k1}
Comment 5 Richard Henderson 2007-02-23 16:12:25 UTC
Subject: Re:  [4.3 Regression] current mainline fails to bootstrap when -msse is used

On Fri, Feb 23, 2007 at 01:54:35PM -0000, ubizjak at gmail dot com wrote:
>         * config/i386/i386.md (*movdi_1_rex64, zero_extendsidi2_32,
>         zero_extendsidi2_rex64): Penalize MMX register<->memory moves.
>         (*movsf_1): Penalize MMX moves.

Ok.  I guess I really need to get around to disabling mmx when 
it's not supposed to be used.


r~
Comment 6 uros 2007-02-23 18:19:17 UTC
Subject: Bug 30825

Author: uros
Date: Fri Feb 23 18:19:07 2007
New Revision: 122268

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122268
Log:
        PR target/30825
        * config/i386/i386.md (*movdi_1_rex64, zero_extendsidi2_32,
        zero_extendsidi2_rex64): Penalize MMX register<->memory moves.
        (*movsf_1): Penalize MMX moves.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.md

Comment 7 Uroš Bizjak 2007-02-23 18:20:49 UTC
Fixed on mainline.