<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 - Conversion to TMHH gives wrong result"
href="https://bugs.llvm.org/show_bug.cgi?id=35529">35529</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Conversion to TMHH gives wrong result
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: SystemZ
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paulsson@linux.vnet.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19519" name="attach_19519" title="reduced csmith program (pre-processed)">attachment 19519</a> <a href="attachment.cgi?id=19519&action=edit" title="reduced csmith program (pre-processed)">[details]</a></span>
reduced csmith program (pre-processed)
Csmith discovered a program which gave a differing checksum with clang -O0:
*** Analyzing wrong6.c (seed= 15242346099534488386, size= 153640):
3F15FE04: 16
88680976: 2
Different reduced builds (18):
3F15FE04: /root/llvm/build/llvm-dev/bin/clang -O3 -march=z10 wrong6.c
-I/root/csmith/runtime -o a.out -w
3F15FE04: gcc -O0 -march=z10 wrong6.c -I/root/csmith/runtime -o a.out -w
3F15FE04: gcc -O1 -march=z10 wrong6.c -I/root/csmith/runtime -o a.out -w
3F15FE04: gcc -O0 -march=z13 wrong6.c -I/root/csmith/runtime -o a.out -w
3F15FE04: gcc -O1 -march=z13 wrong6.c -I/root/csmith/runtime -o a.out -w
88680976: /root/llvm/build/llvm-dev/bin/clang -O0 -march=z10 wrong6.c
-I/root/csmith/runtime -o a.out -w
88680976: /root/llvm/build/llvm-dev/bin/clang -O0 -march=z13 wrong6.c
-I/root/csmith/runtime -o a.out -w
3F15FE04: /root/llvm/build/llvm-dev/bin/clang -O3 -march=z13 wrong6.c
-I/root/csmith/runtime -o a.out -w
opt -instsimplify corrected the output... The non-simplified condition check
was not correctly handled.
I am not sure exactly what goes wrong, but by commenting out like
// Check whether the mask is suitable for TMHH, TMHL, TMLH or TMLL.
// if (!SystemZ::isImmLL(Mask) && !SystemZ::isImmLH(Mask) &&
// !SystemZ::isImmHL(Mask) && !SystemZ::isImmHH(Mask))
return 0;
, the correct checksum is printed, which makes it seem that the TMHH conversion
contains the bug.
This if statement is always false (and with -instsimplify it is removed):
static int16_t g_5 = (-9L);
...
int64_t p_3 = g_5;
if (((0 > p_3) >= 3L))
(*g_1619) = 0;
The store of 0 to g_1619 should never happen (a jump *should* be made to
BB0_17, past BB0_16 which contains the store)
The diff of the .s files is actually very small in this block:
correct bad
.LBB0_15: .LBB0_15:
brasl %r14, platform_main_b brasl %r14, platform_main_b
brasl %r14, crc32_gentab@PL brasl %r14, crc32_gentab@PL
lghrl %r0, g_5 lghrl %r0, g_5
srlg %r1, %r0, 63 | tmhh %r0, 32768
stg %r0, 184(%r15) stg %r0, 184(%r15)
cgijl %r1, 3, .LBB0_17 | je .LBB0_17
It seems that to the left both the check for p_3 being negative and then
comparing that to 3, while the tmhh just checks for the sign bit and forgets
the check against 3L..?
bin/clang -O0 -march=z13 w6.i -o a.out -w
./a.out
checksum = 6522DF69 // BAD checksum
bin/clang -O1 -march=z13 w6.i -o a.out -w
./a.out
checksum = B5499A84 // GOOD checksum</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>