This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] for PR 26087


Hello,

in CFG layout mode, jumps are implicit and there do not need to be labels at
beginning of a basic block.  This means that canonicalize_condition
(called through get_condition) may sometimes cross bb boundary, ignoring
the real control flow.  This is what happens in this testcase; ordering
of blocks is

preheader (implicit jump to header)

bb

header

rest of loop

and when get_condition is called on a statement in bb, it finds
definition in preheader (causing ice in df, as we only scanned
insns in loop).

This patch makes get_condition look at BLOCK_FOR_INSN.  The only use
where it is not entirely correct is in loop.c, where we do not
necessarily preserve basic block information.  However, the change
is still conservatively correct -- the worst that can happen is that
get_condition unnecessarily stops sooner.  And of course, I still hope
that we will be able to get rid of loop.c in 4.2, anyway :-)

Zdenek

	PR rtl-optimization/26087
	* rtlanal.c (canonicalize_condition): Do not cross basic block
	boundaries.

Index: rtlanal.c
===================================================================
*** rtlanal.c	(revision 110555)
--- rtlanal.c	(working copy)
*************** canonicalize_condition (rtx insn, rtx co
*** 4508,4513 ****
--- 4508,4514 ----
    rtx op0, op1;
    int reverse_code = 0;
    enum machine_mode mode;
+   basic_block bb = BLOCK_FOR_INSN (insn);
  
    code = GET_CODE (cond);
    mode = GET_MODE (cond);
*************** canonicalize_condition (rtx insn, rtx co
*** 4569,4575 ****
  
        if ((prev = prev_nonnote_insn (prev)) == 0
  	  || !NONJUMP_INSN_P (prev)
! 	  || FIND_REG_INC_NOTE (prev, NULL_RTX))
  	break;
  
        set = set_of (op0, prev);
--- 4570,4580 ----
  
        if ((prev = prev_nonnote_insn (prev)) == 0
  	  || !NONJUMP_INSN_P (prev)
! 	  || FIND_REG_INC_NOTE (prev, NULL_RTX)
! 	  /* In cfglayout mode, there do not have to be labels at the
! 	     beginning of a block, or jumps at the end, so the previous
! 	     conditions would not stop us when we reach bb boundary.  */
! 	  || BLOCK_FOR_INSN (prev) != bb)
  	break;
  
        set = set_of (op0, prev);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]