PR81747, ICE in operator[]

Message ID 20170809112831.GH16312@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Aug. 9, 2017, 11:28 a.m.
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)
                    (pc)))
            (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.

Comments

Alan Modra Aug. 16, 2017, 3:27 a.m. | #1
Ping?

On Wed, Aug 09, 2017 at 08:58:31PM +0930, Alan Modra wrote:
> 	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 *ebb_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))
Jeff Law Aug. 24, 2017, 9:10 p.m. | #2
On 08/15/2017 09:27 PM, Alan Modra wrote:
> Ping?
> 
> On Wed, Aug 09, 2017 at 08:58:31PM +0930, Alan Modra wrote:
>> 	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.
OK.  Sorry I didn't see this one in my queue.  Thanks for pinging it.

jeff

Patch

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 *ebb_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))