<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 - Result of __builtin_ctzs() and __tzcnt_u16() not matching after 2af95a52"
href="https://bugs.llvm.org/show_bug.cgi?id=50569">50569</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Result of __builtin_ctzs() and __tzcnt_u16() not matching after 2af95a52
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>douglas_yung@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>We have an internal test that attempts to verify intrinsics are working
correctly, and the test for __tzcnt_u16 started to fail after upstream commit
2af95a527580333940333c532679356d99b88e3d. I have extracted the following repro
which should demonstrate the issue when compiled with "-mavx -mbmi -O3":
/* test.cpp */
#include <x86intrin.h>
#include <stdio.h>
typedef union {
double d64;
short i16;
} _data2;
int main(int argc, char *argv[]) {
_data2 v1, v2;
v1.d64 = v2.d64 = (short) rand();
printf("Original: v1.d64 = %lf\n", v1.d64);
printf("Original: v1.i16 = %d\n", (short) v1.d64);
v1.i16 = __builtin_ctzs( v1.i16 );
printf("__builtin_ctzs( v1.i16 ): %lf\n", v1.d64);
v2.i16 = __tzcnt_u16( v2.i16 );
printf("__tzcnt_u16( v2.i16 ): %lf\n", v2.d64);
if( v1.d64 != v2.d64 ) {
printf("Difference detected: v1.d64 = %lf, v2.d64 = %lf\n", v1.d64,
v2.d64);
printf("Difference detected: v1.i16 = 0x%x, v2.i16 = 0x%x\n", v1.i16,
v2.i16);
printf("Test failed\n");
return 1;
}
printf("Test passed\n");
return 0;
}
/* End test.cpp */
Here is a link comparing the generated assembly/run output for clang 12
(d28af7c65) vs. trunk (b2c8bcbab) on godbolt: <a href="https://godbolt.org/z/44T7eT3e6">https://godbolt.org/z/44T7eT3e6</a>
When the version compiled by clang 12 is run, it produces the following output:
Original: v1.d64 = 17767.000000
Original: v1.i16 = 17767
__builtin_ctzs( v1.i16 ): 17767.000000
__tzcnt_u16( v2.i16 ): 17767.000000
Test passed
When the version compiled by clang trunk is run, it produces the following
output:
Original: v1.d64 = 17767.000000
Original: v1.i16 = 17767
__builtin_ctzs( v1.i16 ): 17767.000000
__tzcnt_u16( v2.i16 ): 17767.000000
Difference detected: v1.d64 = 17767.000000, v2.d64 = 17767.000000
Difference detected: v1.i16 = 0x20, v2.i16 = 0x10
Test failed
Bisecting this issue pointed to commit 2af95a527580333940333c532679356d99b88e3d
as the cause of this issue.</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>