Subject: Reordering of __builtin functions around inline asm volatile
Ricardo Cosme <[email protected]> Sat, 23 Sep 2023 22:48:09 -0300
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_3982323_1799942781.1695520089583
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi,
I have a question regarding the reordering of statements involving a builti=
n function and extended asm volatile expressions in avr-gcc.
Consider the following code snippet:
//C++
{
=C2=A0 asm volatile(/* template plus operands */);
=C2=A0 __builtin_avr_delay_cycles(cycles);
=C2=A0 asm volatile(/* template plus operands */);
}
I understand that the compiler is allowed to reorder statements as long as =
it doesn't affect the observable behavior of the program. However, in this =
specific case, the __builtin_avr_delay_cycles function is a compiler intrin=
sic.
Assuming there are no other expressions on the above block, is it possible =
for the compiler to reorder the three statements?
Cheers,
Ricardo Cosme
------=_Part_3982323_1799942781.1695520089583
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>=
<meta content=3D"text/html;charset=3DUTF-8" http-equiv=3D"Content-Type"></h=
ead><body ><div style=3D"font-family: Verdana, Arial, Helvetica, sans-serif=
; font-size: 10pt;"><div>Hi,<br></div><div><br></div><div>I have a question=
regarding the reordering of statements involving a builtin function and ex=
tended asm volatile expressions in avr-gcc.<br></div><div><br></div><div>Co=
nsider the following code snippet:<br></div><div><br></div><div>//C++<br></=
div><div>{<br></div><div> asm volatile(/* template plus operands */);=
<br></div><div> __builtin_avr_delay_cycles(cycles);<br></div><div>&nb=
sp; asm volatile(/* template plus operands */);<br></div><div>}<br></div><d=
iv><br></div><div>I understand that the compiler is allowed to reorder stat=
ements as long as it doesn't affect the observable behavior of the program.=
However, in this specific case, the __builtin_avr_delay_cycles function is=
a compiler intrinsic.<br></div><div><br></div><div>Assuming there are no o=
ther expressions on the above block, is it possible for the compiler to reo=
rder the three statements?<br></div><div><br></div><div>Cheers,<br></div><d=
iv>Ricardo Cosme<br></div><div><br></div></div><br></body></html>
------=_Part_3982323_1799942781.1695520089583--