<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89008>89008</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] code generation issue with clang -march=amdfam10
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tonycoz
</td>
</tr>
</table>
<pre>
This was originally reported against perl as https://github.com/Perl/perl5/issues/22132 but appears to be a clang issue.
Reduced test case (as opposed to the perl source):
[22132.txt](https://github.com/llvm/llvm-project/files/15003957/22132.txt) (.txt since github didn't like .c)
This was originally reported against clang 17.0.6 as supplied with FreeBSD 13.3, but was reproducible on Debian Linux bookworm with the clang/llvm builds from apt.llvm.org since clang 15.
```
$ clang-14 -O2 -march=amdfam10 22132.c && ./a.out
required_even_ix
$ clang-15 -O2 -march=amdfam10 22132.c && ./a.out
requiredEven_ix
$ clang-16 -O2 -march=amdfam10 22132.c && ./a.out
requiredEven_ix
$ clang-17 -O2 -march=amdfam10 22132.c && ./a.out
requiredEven_ix
$ clang-18 -O2 -march=amdfam10 22132.c && ./a.out
requiredEven_ix
$ clang-18 -O2 -march=amdfam10 22132.c && ./a.out | hd
00000000 72 65 71 75 69 72 65 64 7f 45 76 65 6e 5f 69 78 |required.Even_ix|
00000010 0a |.|
00000011
$ clang-18 -O2 22132.c && ./a.out
required_even_ix
$ clang-18 -O2 -march=x86-64-v2 22132.c && ./a.out
required_even_ix
$ clang-18 --version
Debian clang version 18.1.4 (++20240410110204+b6ebea7972cd-1~exp1~20240410230232.97)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang-17 --version
Debian clang version 17.0.6 (++20231208085813+6009708b4367-1~exp1~20231208085906.81)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ clang-18 -O2 -fsanitize=address 22132.c && ./a.out
required_even_ix
$ clang-18 -O2 -fsanitize=undefined 22132.c && ./a.out
required_even_ix
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVt9v2zYQ_mvol4MEkvr94Ic4troCbROkyYA9GZR4trnKokZSSdqH_u0DRTlL2yVI13WYYdgm7_jdd2fxuxPWqn2PuCTZimTrhRjdQZul0_3HVn9aNFp-XF4flIU7YUEbtVe96LqPYHDQxqEEsReqtw4GNB0ICwfnBkuSM8Jrwuu9coexiVt9JLy-RNMRXnvPjPBaWTuiJbzmnCUcmtGBGAYUxoLT0CAIaDvR72FyjAldE3oWPq9Qji1KcGgdtMIiEF56gsOgrd_X4A4YOFk9mhYJrzypgJGtppCxu3ckWxNePkO6625PX9Fg9O_YOsLrneom6iyjNKmy4pTFBMkrT8f_BKv6FiEAglSyJ7xw0KkPCHHrOT1K6kVlDhVhRUzj3JfbjsPQKZRwp9wBaoO4er8GlsQJ4edTTT2iwcFoObaq6RB0D2tslOjhjerHe2i0_nCnzTFA-LpNQeakoRlVJy3sjD6CGFzsN2Nt9nNuM6Hsi_-H5HR-hyVPg1_EUoguOERHYdoDSdbiKHfiyCiE6rVAeE54DjHhtYj16AKAwT9GZVBu8Rb7rbr_Bjb7IdjNE6j5T0Etfgpq-b9ABVKcw0EGHDq_AAoOeQYFgyKDvJqXeQpQ7CDNoMinNUK2m8ylhzlRi0_civPHsIwCUOEd468t7Ik0fvAZ-6oW92Ue5Wl0-2_gRrdorNJ9sM23M9ys2QKsjFmcemEhfEX4ilOe0pRRxiinKeGrJscGRVEVvJUR-4z3A_t8cuIJ5QmPq-JBcq6F2aMjyRncl_k2T6OhjTovB9G-H096ZFBIOGqJnXcctD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