tree-optimization/125545 - reassoc insering after asm goto
Checks
Commit Message
There's one case we can handle just fine which is when the asm goto
has a single successor (it's fallthru edge, possibly shared with
an asm goto label). As we're using dominance based insertion
point discovery we have to handle this case.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/125545
* tree-ssa-reassoc.cc (insert_stmt_after): Allow asm goto
with a single successor.
* gcc.dg/torture/pr125545.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr125545.c | 9 +++++++++
gcc/tree-ssa-reassoc.cc | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr125545.c
new file mode 100644
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+int b(int c)
+{
+ int a;
+ __asm__ goto("" : "=r"(a) : : : d);
+d:
+ return c && a != 42 && a >= 42;
+}
@@ -1521,7 +1521,8 @@ insert_stmt_after (gimple *stmt, gimple *insert_point)
return;
}
else if (gimple_code (insert_point) == GIMPLE_ASM
- && gimple_asm_nlabels (as_a <gasm *> (insert_point)) != 0)
+ && gimple_asm_nlabels (as_a <gasm *> (insert_point)) != 0
+ && !single_succ_p (gimple_bb (insert_point)))
/* We have no idea where to insert - it depends on where the
uses will be placed. */
gcc_unreachable ();