[llvm-bugs] [Bug 35529] New: Conversion to TMHH gives wrong result
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 5 06:03:58 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35529
Bug ID: 35529
Summary: Conversion to TMHH gives wrong result
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: SystemZ
Assignee: unassignedbugs at nondot.org
Reporter: paulsson at linux.vnet.ibm.com
CC: llvm-bugs at lists.llvm.org
Created attachment 19519
--> https://bugs.llvm.org/attachment.cgi?id=19519&action=edit
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 at PL brasl %r14, crc32_gentab at 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
--
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/20171205/fde6d782/attachment-0001.html>
More information about the llvm-bugs
mailing list