https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66727
Bug ID: 66727 Summary: Example artificial dependency incorrect Product: gcc Version: unknown Status: UNCONFIRMED Severity: minor Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: T.E.Baldwin99 at members dot leeds.ac.uk Target Milestone: --- The in the section on extended asm the manual states: The compiler may move the addition back before the volatile asm. To make it work as expected, add an artificial dependency to the asm by referencing a variable in the subsequent code, for example: asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv)); sum = x + y; However this addition does not depend on the asm and the code is permitted to be reordered to: sum = x + y; asm volatile ("mtfsf 255,%1" : "=X" (sum1) : "f" (fpenv)); The example should perhaps pass x or y though the asm: asm volatile ("mtfsf 255,%1" : "+g" (x) : "f" (fpenv)); sum = x + y;