This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/55369] New: expmed.c is miscompiled in stage1 bootstrap at -O1
- From: "danglin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 Nov 2012 20:13:19 +0000
- Subject: [Bug middle-end/55369] New: expmed.c is miscompiled in stage1 bootstrap at -O1
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55369
Bug #: 55369
Summary: expmed.c is miscompiled in stage1 bootstrap at -O1
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: danglin@gcc.gnu.org
Host: hppa64-hp-hpux11.11
Target: hppa64-hp-hpux11.11
Build: hppa64-hp-hpux11.11
Created attachment 28721
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28721
Preprocessed source
I have seen the following ICE with 4.4.7, 4.6.3 and 4.7.2:
libtool: compile: /test/gnu/gcc/objdir/./gcc/xgcc -shared-libgcc
-B/test/gnu/gc
c/objdir/./gcc -nostdinc++
-L/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/libstdc++-v3/src
-L/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/libstdc++-v3/src/.libs -B/opt/
gnu64/gcc/gcc-4.8/hppa64-hp-hpux11.11/bin/
-B/opt/gnu64/gcc/gcc-4.8/hppa64-hp-hp
ux11.11/lib/ -isystem /opt/gnu64/gcc/gcc-4.8/hppa64-hp-hpux11.11/include
-isystem /opt/gnu64/gcc/gcc-4.8/hppa64-hp-hpux11.11/sys-include
-I/test/gnu/gcc/gcc/lib
stdc++-v3/../libgcc
-I/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/libstdc++-v3/incl
ude/hppa64-hp-hpux11.11
-I/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/libstdc++-v3/include
-I/test/gnu/gcc/gcc/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -Wall -Wext
ra -Wwrite-strings -Wcast-qual -Wabi -fdiagnostics-show-location=once
-ffunction
-sections -fdata-sections -frandom-seed=eh_alloc.lo -g -O2 -c
../../../../gcc/li
bstdc++-v3/libsupc++/eh_alloc.cc -DPIC -D_GLIBCXX_SHARED -o eh_alloc.o
../../../../gcc/libstdc++-v3/libsupc++/eh_alloc.cc: In function 'void
__cxxabiv1
::__cxa_free_dependent_exception(__cxxabiv1::__cxa_dependent_exception*)':
../../../../gcc/libstdc++-v3/libsupc++/eh_alloc.cc:213:28: internal compiler
err
or: in expand_divmod, at expmed.c:4103
= (unsigned) (ptr - base) / sizeof (__cxa_dependent_exception);
^
../../../../gcc/libstdc++-v3/libsupc++/eh_alloc.cc:213:28: internal compiler
error: Aborted
xgcc: internal compiler error: Aborted (program cc1plus)
../libtool[11]: 22165 Abort(coredump)
make[5]: *** [eh_alloc.lo] Error 1
This is with the following make command:
make STAGE1_CFLAGS="-g -O1" -j2 bootstrap
The ICE appears to be caused by the bootstrap compiler miscompiling
choose_multiplier. In particular, this hunk is incorrectly compiled:
/* Reduce to lowest terms. */
for (post_shift = lgup; post_shift > 0; post_shift--)
{
int shft = HOST_BITS_PER_WIDE_INT - 1;
unsigned HOST_WIDE_INT ml_lo = (mlow.high << shft) | (mlow.low >> 1);
unsigned HOST_WIDE_INT mh_lo = (mhigh.high << shft) | (mhigh.low >> 1);
if (ml_lo >= mh_lo)
break;
mlow = double_int::from_uhwi (ml_lo);
mhigh = double_int::from_uhwi (mh_lo);
}
The combine pass drops the or of "(mhigh.high << shft)" into mh_lo.
Strangely, the same doesn't happen for ml_lo. As a result, ml_lo is
greater than mh_lo and the reduction fails.
L$BB3244:
; ../../gcc/gcc/expmed.c:3349
L$M1779:
ldd -256(%r30),%r31
depd,z %r31,0,1,%r31
ldd -264(%r30),%r28
extrd,u %r28,62,63,%r28
or %r31,%r28,%r31
L$VL1332:
; ../../gcc/gcc/expmed.c:3350
L$M1780:
extrd,u %r6,62,63,%r6
L$VL1333:
; ../../gcc/gcc/expmed.c:3351
L$M1781:
cmpb,*>> %r6,%r31,L$0883
copy %r9,%r28
; basic block 17
; ../../gcc/gcc/expmed.c:3358
Before combine, we have:
(insn 243 242 244 16 (set (reg:DI 182)
(ashift:DI (reg:DI 103 [ mhigh$high ])
(const_int 63 [0x3f]))) ../../gcc/gcc/expmed.c:3350 228
{*pa.md:6415
}
(nil))
(insn 244 243 245 16 (set (reg:DI 183)
(lshiftrt:DI (reg:DI 155)
(const_int 1 [0x1]))) ../../gcc/gcc/expmed.c:3350 238 {lshrdi3}
(expr_list:REG_DEAD (reg:DI 155)
(nil)))
(insn 245 244 246 16 (set (reg/v:DI 107 [ mh_lo ])
(ior:DI (reg:DI 182)
(reg:DI 183))) ../../gcc/gcc/expmed.c:3350 182 {*pa.md:5716}
(expr_list:REG_DEAD (reg:DI 183)
(expr_list:REG_DEAD (reg:DI 182)
(nil))))
(debug_insn 246 245 22 16 (var_location:DI mh_lo (reg/v:DI 107 [ mh_lo ]))
../..
/gcc/gcc/expmed.c:3350 -1
(nil))
After combine,
(note 243 242 244 16 NOTE_INSN_DELETED)
(note 244 243 245 16 NOTE_INSN_DELETED)
(insn 245 244 246 16 (set (reg/v:DI 107 [ mh_lo ])
(lshiftrt:DI (reg:DI 155)
(const_int 1 [0x1]))) ../../gcc/gcc/expmed.c:3350 238 {lshrdi3}
(expr_list:REG_DEAD (reg:DI 155)
(nil)))
(debug_insn 246 245 22 16 (var_location:DI mh_lo (reg/v:DI 107 [ mh_lo ]))
../..
/gcc/gcc/expmed.c:3350 -1
(nil))
Trying 243 -> 245:
Successfully matched this instruction:
(set (reg/v:DI 107 [ mh_lo ])
(reg:DI 183))
deferring deletion of insn with uid = 243.
modifying insn i3 245 r107:DI=r183:DI
REG_DEAD: r183:DI
deferring rescan insn with uid = 245.
Trying 244 -> 245:
Successfully matched this instruction:
(set (reg/v:DI 107 [ mh_lo ])
(lshiftrt:DI (reg:DI 155)
(const_int 1 [0x1])))
deferring deletion of insn with uid = 244.
modifying insn i3 245 r107:DI=r155:DI 0>>0x1
REG_DEAD: r155:DI
deferring rescan insn with uid = 245.
Here is cc1plus args:
-fpreprocessed expmed.ii -quiet -dumpbase expmed.c -da -dA -auxbase-strip
expmed.o -g -O1 -Wextra -Wall -Wwrite-strings -Wcast-qual
-Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Wno-error -version -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -fno-common -o expmed.s -dA
I was able to duplicate with x86 4.6.3 cross.