Open Quuxplusone opened 14 years ago
Attached bugpoint-reduced-simplified.bc
(588 bytes, application/octet-stream): bugpoint reduced problem
Ping?
Can someone at least reproduce?
Still seeing it with TOT@107143.
Should i add a testcase in C?
Greetings
Jan
(In reply to comment #1)
> Ping?
> Can someone at least reproduce?
> Still seeing it with TOT@107143.
> Should i add a testcase in C?
>
> Greetings
> Jan
Yes, please add a test case so we can reproduce at the frontend level. This is
likely a backend bug, but being able to generate the .ll file directly from a
.c file is handy.
Attached test5.c
(201 bytes, text/x-csrc): testcase in C
Here is a reduced testcase:
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-
f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-darwin10.0.0"
define void @MUL_BIG() nounwind ssp {
entry:
%conv = zext i64 undef to i128 ; <i128> [#uses=1]
%conv2 = zext i64 undef to i128 ; <i128> [#uses=1]
%mul = mul i128 %conv, %conv2 ; <i128> [#uses=1]
%add = add i128 %mul, 0 ; <i128> [#uses=1]
store i128 %add, i128* undef
ret void
}
The short version is that llc is trying to lower the i128 multiply to a
libcall, which lowers to 4 i32 result regs, but the x86 backend only specifies
2 possible 32-bit reg results (EAX/EDX). Given that this function doesn't
exist in compiler_rt or libgcc in 32-bit mode, I think that trying to lower to
the libcall is the bug, not the lack of result registers.
Still fails, updated testcase:
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-darwin10.0.0"
define void @MUL_BIG(i64 %a, i64 %b) nounwind ssp {
entry:
%conv = zext i64 %a to i128 ; <i128> [#uses=1]
%conv2 = zext i64 %b to i128 ; <i128> [#uses=1]
%mul = mul i128 %conv, %conv2 ; <i128> [#uses=1]
%add = add i128 %mul, 0 ; <i128> [#uses=1]
store i128 %add, i128* undef
ret void
}
It appears i128 add and several other operators are also broken on x86-32. Until someone volunteers to implement and maintain i128 codegen for 32-bit targets, clang should reject it so that configure scripts don't autodetect it.
i128 add used to work on x86-32. It is i128 mul that can't be expected to work.
Hi Duncan,
Can you be a little bit more verbose what you mean with "i128 mul can't be
expected to work"?
Because as a poor user i would go with Dan, either the basic ops can be lowered
(libcall or whatever, fairy dust if it helps), or the compiler should refuse TI-
mode. Some Semi-in-between-state ... is suboptimal. This leads to a lot of
configure testing + ugly ifdefery and explodes the testvector.
Greetings
Jan
i128 mul cannot be expected to work on x86-32 because there is no library
support
for it (libgcc only supports i64 mul on x86-32). If library support was added,
or llvm output an appropriate function on the fly, then it would work of course.
GCC gets this right:
$ gcc -m32 -c -o /dev/null test5.c
test5.c:1:1: error: unable to emulate 'TI'
bugpoint-reduced-simplified.bc
(588 bytes, application/octet-stream)test5.c
(201 bytes, text/x-csrc)