<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/80373>80373</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LlVm 15.0.7: If operand to CreateLogicalAnd was created by CreateAtomicCmpXchng, the evaluation order is wrong.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Bob64375
</td>
</tr>
</table>
<pre>
Both of these statements generate code that evaluates CreateAtomicCmpXchg first (we use the 2nd i1 return from CreateAtomicCmpXchg). This makes it a bit awkward to short circuit the evaluation of CreateAtomicCmpXchg because the evaluation is never left-to-right.
if ( x!=0 && CreateAtomicCmpXchg )
or, swapping operands to CreateLogicalAnd,
if ( CreateAtomicCmpXchg && x!=0 )
09710063 mov edi,dword ptr [ebp+8]
09710066 mov edx,dword ptr [edi+28h]
09710069 mov ecx,dword ptr [edi+2Ch]
0971006C mov bl,1
0971006E xor eax,eax
09710070 lock cmpxchg byte ptr [edx],bl <------------------- CreateAtomicCmpXchg
09710074 fldz
09710076 fldz
09710078 jne 097100CE
0971007A fstp st(1)
0971007C fstp st(0)
0971007E test ecx,ecx <-------------------------- x!=0
09710080 fldz
It would be nice if the evaluation were in the order of operands given to CreateLogicalAnd.
Sorry if it's already been fixed, but thanks!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VMGOozgQ_RrnUurIGAhw4JCQjjTS3Ha12quxC_C0sZFtQrJfv4J0ppM0w8HIrnqvXpWrzL1XrUEsSXog6XHDx9BZVx5svUviLN3UVl7Lgw0d2AZChx7BBx6wRxM8tGjQ8YAgrEQIHQ-AZ65HHtBD5ZAH3AfbK1H1w7-ia6FRzgcgLJ8QRj9DEJiRoCJwGEZnoHG2X4MSVmzh70556PkHelABONTzOn1M3EkIFnxnXQChnBhVWLg_1ShrZv1rimoU_K7kwVt5MHhGBxqb8Bbsm1NtF7aEHgnd31bVzInAhbCIxEcKhO0I260GIay4YawjrAI_8WFQpgU7oONG-ln8DffTtkpwvTeSsOopzjrvEvJBQvGokBZZROkuBujtGe4fSkVYJSfrJAzBAUkPWA-EHXKSHgGeoLsbFOXlG2RmObC8-w4qXuKJP4GrBfyErZ6xtSasil743wEu1n3x85kf-eXJK6MA2ooPEP1wWS76GvAr_oWkR8KqWgOQuHr7_q324CN_AtBo-d-ztmy3epoD_DIIt131_mLdAzQ-DPd8fCAsjwgrXtyqT7fFTr_b3wEC-vBcdhSXebOe4z3Ve_880uX0OZPb-iPAZEctoUYwSiCo5nVyJnQIyizH1kl08-T9bvRWndGstfvnaP1lnbvOrCoQlnng2iGXV6gRDTTqgvNcQD3O483Nhycs2sgylkVc8A2WUUZ3eZzHSbrpyoKKhglJZZTEeZLVoiiYjGVC0yTPkxw3qmSUJZRRRqMkTdItS5OCJVGEuYjindyRhGLPld5qfe631rUb5f2IZU7jLN5oXqP2y8vJmMEJFiNhbH5IXTlj3uqx9SShWvngv1iCChrLn_qfHqJ0S7cZiffw43eZ1uoDE_cglkMJ9XWlPU07l-b11VtuQHmYnDXtdjM6XXYhDJ7Ee8JOhJ1aFbqx3grbE3aaFX7-3gZnf6EIhJ2WvDxhpyXv_wMAAP__wfvaVA">