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]

RFA: fix gcc.dg/builtins-6.c execution failure on sh-elf


-- 
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658
After the gcse pessimizer pass has run, we end up with:

(insn 68 67 71 4 0x40216268 (set (reg:SI 178)
        (reg:SI 0 r0)) 122 {movsi_i} (nil)
    (insn_list:REG_RETVAL 66 (expr_list:REG_EQUAL (expr_list (use (mem:BLK (scra
tch) [0 A8]))
                (expr_list (reg/f:SI 177)
                    (expr_list (reg/v:DF 159 [ x ])
                        (nil))))
            (nil))))
...
(insn 149 148 150 12 0x40216268 (set (reg/v:DF 159 [ x ])
        (const_double:DF -939524096 [0xc8000000] 1.0e+2 [0x0.c8p+7])) 141 {movdf
_k} (nil)
    (nil))
...
(insn 208 207 211 16 0x40216268 (set (reg:SI 220)
        (reg:SI 0 r0)) 122 {movsi_i} (nil)
    (insn_list:REG_RETVAL 206 (expr_list:REG_EQUAL (expr_list (use (mem:BLK (scr
atch) [0 A8]))
                (expr_list (reg/f:SI 177)
                    (expr_list (reg/v:DF 159 [ x ])
                        (nil))))
            (nil))))

All six uses of reg/v:DF 159 [ x ]) after the last set have been replaced
with the more expensive constant, leaving only references in the reg notes.
delete_trivially_dead_insns deletes insn 149, even though a reference
remains in the reg note of insn 208 (and others).
cse2 then uses the notes to use common subexpression elimination on the
function calls, thus ending up with the wrong value for the calls that
used to be after the deleted assignment.

count_reg_usage tries to count references in reg notes too, but it
just calls itself recursively and then sees and EXPR_LIST, which it thinks
is a list of notes, and hence it ignores REGs in there.

2003-05-20  J"orn Rennecke <joern.rennecke@superh.com>

	* cse.c (count_reg_usage): When processing an INSNs REG_EQUAL
	note containing an EXPR_LIST, process all the arguments.

Index: cse.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cse.c,v
retrieving revision 1.260
diff -p -r1.260 cse.c
*** cse.c	3 May 2003 14:25:21 -0000	1.260
--- cse.c	20 May 2003 14:12:45 -0000
*************** count_reg_usage (x, counts, dest, incr)
*** 7512,7518 ****
  
        note = find_reg_equal_equiv_note (x);
        if (note)
!         count_reg_usage (XEXP (note, 0), counts, NULL_RTX, incr);
        return;
  
      case EXPR_LIST:
--- 7512,7532 ----
  
        note = find_reg_equal_equiv_note (x);
        if (note)
! 	{
! 	  rtx eqv = XEXP (note, 0);
! 
! 	  if (GET_CODE (eqv) == EXPR_LIST)
! 	  /* This REG_EQUAL note describes the result of a function call.
! 	     Process all the arguments.  */
! 	    do
! 	      {
! 		count_reg_usage (XEXP (eqv, 0), counts, NULL_RTX, incr);
! 		eqv = XEXP (eqv, 1);
! 	      }
! 	    while (eqv && GET_CODE (eqv) == EXPR_LIST);
! 	  else
! 	    count_reg_usage (eqv, counts, NULL_RTX, incr);
! 	}
        return;
  
      case EXPR_LIST:

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