The testcase in this PR is failing in cse2 when processing the
following basic block.

(note 31 30 389 9 [bb 9] NOTE_INSN_BASIC_BLOCK)
(jump_insn 389 31 39 9 (parallel [
            (set (pc)
                (if_then_else (ne (reg:DI 138)
                        (const_int 1 [0x1]))
                    (label_ref:DI 39)
            (set (reg:DI 138)
                (plus:DI (reg:DI 138)
                    (const_int -1 [0xffffffffffffffff])))
            (clobber (scratch:CC))
            (clobber (scratch:DI))
        ]) "/home/alan/src/tmp/pr81747.c":19 832 {ctrdi_internal1}
     (int_list:REG_BR_PROB 38000 (nil))
 -> 39)
;;  succ:       13 [always (guessed)]  (FALLTHRU,LOOP_EXIT)

The insn is rather odd.  It meets single_set by virtue of reg 138
being dead, and since the branch destination is the fall-through, the
whole basic block could be deleted..

Regardless of whether this insn should have been deleted earlier, it
seems wrong to try to infer anything about the condition based on the
jump destination when we have a degenerate conditional jump that
branches to its fall-through.

Bootstrapped and regression tested powerpc64le-linux.  OK?

        PR rtl-optimization/81747
        * cse.c (cse_extended_basic_block): Don't attempt to record
        equivalences for degenerate conditional jumps that branch
        to their fall-through.

diff --git a/gcc/cse.c b/gcc/cse.c
index 6a968d1..85be372 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -6640,6 +6640,7 @@ cse_extended_basic_block (struct cse_basic_block_data 
         equivalences due to the condition being tested.  */
       insn = BB_END (bb);
       if (path_entry < path_size - 1
+         && EDGE_COUNT (bb->succs) == 2
          && JUMP_P (insn)
          && single_set (insn)
          && any_condjump_p (insn))

Alan Modra
Australia Development Lab, IBM

Reply via email to