@@ -38852,7 +38852,8 @@ ix86_avoid_jump_mispredicts (void)
while (nbytes + max_skip >= 16)
{
start = NEXT_INSN (start);
- if (JUMP_P (start) || CALL_P (start))
+ if ((JUMP_P (start) && asm_noperands (PATTERN (start)) < 0)
+ || CALL_P (start))
njumps--, isjump = 1;
else
isjump = 0;
@@ -38867,7 +38868,8 @@ ix86_avoid_jump_mispredicts (void)
if (dump_file)
fprintf (dump_file, "Insn %i estimated to %i bytes\n",
INSN_UID (insn), min_size);
- if (JUMP_P (insn) || CALL_P (insn))
+ if ((JUMP_P (insn) && asm_noperands (PATTERN (insn)) < 0)
+ || CALL_P (insn))
njumps++;
else
continue;
@@ -38875,7 +38877,8 @@ ix86_avoid_jump_mispredicts (void)
while (njumps > 3)
{
start = NEXT_INSN (start);
- if (JUMP_P (start) || CALL_P (start))
+ if ((JUMP_P (start) && asm_noperands (PATTERN (start)) < 0)
+ || CALL_P (start))
njumps--, isjump = 1;
else
isjump = 0;
@@ -0,0 +1,36 @@
+/* PR target/59625 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mtune=atom" } */
+
+int
+foo (void)
+{
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ asm goto ("" : : : : lab);
+ return 0;
+lab:
+ return 1;
+}
+
+/* Verify we don't consider asm goto as a jump for four jumps limit
+ optimization. asm goto doesn't have to contain a jump at all,
+ the branching to labels can happen through different means. */
+/* { dg-final { scan-assembler-not "p2align\[^\n\r\]*\[\n\r]*\[^\n\r\]*p2align\[^\n\r\]*\[\n\r]*\[^\n\r\]*p2align\[^\n\r\]*\[\n\r]*\[^\n\r\]*p2align\[^\n\r\]*\[\n\r]*\[^\n\r\]*p2align\[^\n\r\]*\[\n\r]*\[^\n\r\]*p2align" } } */