[Bug rtl-optimization/78416] New: wrong code for division by (u128)~INT64_MAX at -O0
zsojka at seznam dot cz
gcc-bugzilla@gcc.gnu.org
Fri Nov 18 11:21:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78416
Bug ID: 78416
Summary: wrong code for division by (u128)~INT64_MAX at -O0
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Created attachment 40079
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40079&action=edit
reduced testcase
Compiler output:
$ gcc testcase.c
$ ./a.out
Aborted
$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-242583-checking-yes-rtl-df-extra-nobootstrap-nographite-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --without-cloog --without-ppl --without-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-242583-checking-yes-rtl-df-extra-nobootstrap-nographite-amd64
Thread model: posix
gcc version 7.0.0 20161118 (experimental) (GCC)
All tested 64bit targets seem to be affected:
aarch64-unknown-linux-gnu
powerpc64-unknown-linux-gnu
sparc64-unknown-linux-gnu
x86_64-pc-linux-gnu
x86_64-pc-linux-gnux32
The .expand dump has:
;; x_2 = x_1 / 0xffffffffffffffff8000000000000000;
(insn 6 5 7 (set (reg:TI 90)
(mem/c:TI (plus:DI (reg/f:DI 82 virtual-stack-vars)
(const_int -16 [0xfffffffffffffff0])) [1 xD.1797+0 S16 A128]))
"testcase.c":7 -1
(nil))
(insn 7 6 8 (parallel [
(set (reg:TI 89)
(lshiftrt:TI (reg:TI 90)
(const_int 63 [0x3f])))
(clobber (reg:CC 17 flags))
]) "testcase.c":7 -1
(expr_list:REG_EQUAL (udiv:TI (reg:TI 90)
(const_int -9223372036854775808 [0x8000000000000000]))
(nil)))
Which, I think, is wrong. But I have been wrong many times already.
More information about the Gcc-bugs
mailing list