[llvm-bugs] [Bug 32713] New: mips/mipsel i128 sub/add generates wrong code
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 19 08:47:57 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32713
Bug ID: 32713
Summary: mips/mipsel i128 sub/add generates wrong code
Product: libraries
Version: 3.9
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: MIPS
Assignee: unassignedbugs at nondot.org
Reporter: simonas+llvm.org at kazlauskas.me
CC: llvm-bugs at lists.llvm.org
i128 subtraction on 32bit MIPSes seems to fail to propagate the carry bit from
lower 64 bits to higher 64 bits.
Therefore on x86(_64) the foo function from IR below returns `~0` (i128 with
all bits set), whereas on MIPS it returns something like
0000_0000_0000_0000_ffff_ffff_ffff_ffff.
`add i128 %a, %b` where `%a = i128 -1` and `%b = i128 1` seems to also not
produce `0` as a result.
Reproduction IR (subtraction):
target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
target triple = "mipsel-unknown-linux-gnu"
define i128 @foo(i128, i128) unnamed_addr #0 {
start:
%a = sub i128 %0, %1
ret i128 %a
}
define i32 @main(i32, i8**) unnamed_addr {
start:
%r = tail call i128 @foo(i128 0, i128 1)
%c = icmp ne i128 %r, -1
%x = zext i1 %c to i32
ret i32 %x
}
attributes #0 = { norecurse nounwind readnone uwtable noinline }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}
Reproduction IR (addition):
target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
target triple = "mipsel-unknown-linux-gnu"
define i128 @foo(i128, i128) unnamed_addr #0 {
start:
%a = add i128 %0, %1
ret i128 %a
}
define i32 @main(i32, i8**) unnamed_addr {
start:
%r = tail call i128 @foo(i128 -1, i128 1)
%c = icmp ne i128 %r, 0
%x = zext i1 %c to i32
ret i32 %x
}
attributes #0 = { norecurse nounwind readnone uwtable noinline }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}
Testing procedure:
llc file.ll -filetype=obj && cc file.o && ./a.out && echo "success"
LLVM Version:
3.9.1. Do not have 4.0 handy to test with it.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170419/158cb83d/attachment.html>
More information about the llvm-bugs
mailing list