diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 539887c1831..9a3e4539fb7 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3064,6 +3064,12 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx cond, if (!insn_valid_noce_process_p (last_insn, cc)) return false; + + /* Punt on blocks ending with asm goto or jumps with other side-effects, + last_active_insn ignores JUMP_INSNs. */ + if (JUMP_P (BB_END (test_bb)) && !onlyjump_p (BB_END (test_bb))) + return false; + last_set = single_set (last_insn); rtx x = SET_DEST (last_set); diff --git a/gcc/testsuite/gcc.target/i386/pr103908.c b/gcc/testsuite/gcc.target/i386/pr103908.c new file mode 100644 index 00000000000..7c57e1ddf6a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr103908.c @@ -0,0 +1,24 @@ +/* PR rtl-optimization/103908 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdisable-tree-cselim -fno-tree-sink" } */ +/* { dg-final { scan-assembler "# insn 1" } } */ +/* { dg-final { scan-assembler "# insn 2" } } */ + +int a, b; + +void +foo (void) +{ + if (a) + { + b = 1; + asm goto ("# insn 1" : : : : lab1); + lab1:; + } + else + { + b = 1; + asm goto ("# insn 2" : : : : lab2); + lab2:; + } +}