<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92217>92217</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bad codegen after commit 3aae916
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dyung
</td>
</tr>
</table>
<pre>
We have an internal test that recently started producing incorrect output which I bisected back to commit 3aae916ff7fe9d0953aa63b2ba1d0e871f6f76fc.
Consider the following code:
```c++
static void init(unsigned char pred, volatile void *data, unsigned size) {
unsigned char *bytes = (unsigned char *)data;
for (unsigned i = 0; i != size; ++i) {
bytes[i] = pred + i;
}
}
#define INIT(PRED, VAR) init(PRED, &VAR, sizeof(VAR))
#include <x86intrin.h>
int main(int argc, char *argv[])
{
__m256 id7702;
INIT(243, id7702);
__m256 id7701 = _mm256_sqrt_ps(id7702);
volatile int id7700 = _mm256_movemask_ps(id7701);
//printf("id7700:%x\n", id7700);
return id7700;
}
```
If compiled with optimizations and `-mavx` and the resulting binary is run, the return value changes after 3aae916ff7fe9d0953aa63b2ba1d0e871f6f76fc:
```
$ ~/src/upstream/3aae916ff7fe9d0953aa63b2ba1d0e871f6f76fc-linux/bin/clang -O2 -mavx repro.cpp -o repro.bad.out
$ ~/src/upstream/f658d84e01bcdd49e27dc9ef80e1a6cc5f9417fe-linux/bin/clang -O2 -mavx repro.cpp -o repro.good.out
$ ./repro.good.out
$ echo $?
7
$ ./repro.bad.out
$ echo $?
0
```
You can also see the difference on godbolt comparing with 18.1.0:
https://godbolt.org/z/KPbK4jcGc
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v4zYT_jX0ZRBDGn0ffEji1YtggbeLRdGip4AiRxJ3JVIlKSfZQ397QdqJ7c2i3RqETHJmnvl6BuTOqUET7Vhxx4r9hq9-NHYnX1Y9bDojX3a_E4z8QMA1KO3Jaj6B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