<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - mips/mipsel i128 sub/add generates wrong code"
href="https://bugs.llvm.org/show_bug.cgi?id=32713">32713</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>mips/mipsel i128 sub/add generates wrong code
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: MIPS
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>simonas+llvm.org@kazlauskas.me
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>