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]

cse_insn using wrong label_ref


I was debugging a case where this insn:


(jump_insn 983 982 991 21 0x4022a528 (parallel [
            (set (pc)
                (if_then_else (eq:SI (reg:SI 44 [ a ])
                        (const_int 0 [0x0]))
                    (label_ref 622)
                    (pc)))
            (clobber (reg:SI 44 [ a ]))
        ]) 34 {*eqbranchsi} (nil)
    (expr_list:REG_EQUAL (if_then_else (ne:SI (reg/v:SI 40 [ a ])
                (const_int 0 [0x0]))
            (label_ref 182)
            (pc))
        (expr_list:REG_BR_PROB (const_int 500 [0x1f4])
            (nil))))

was converted to this insn:

(jump_insn 983 982 2255 21 0x4022a528 (parallel [
            (set (pc)
                (label_ref 182))
            (clobber (reg:SI 44 [ a ]))
        ]) 34 {*eqbranchsi} (nil)
    (expr_list:REG_EQUAL (label_ref 182)
        (expr_list:REG_BR_PROB (const_int 500 [0x1f4])
            (nil))))

(note that the wrong LABEL_REF is used)

The attached patch seems to fix it, but I'm not sure if this is the
right place to be addressing this problem (i.e. there might be cases
where src_eqv is not fully reduced, yet still has the wrong label and
is still used, or it might be that the REG_EQUAL is supposed to have
the right label).  I'll start a test run in case this is the right way
to fix it ;-)

2003-05-14  DJ Delorie  <dj@redhat.com>

	* cse.c (cse_insn): Make sure we use the right LABEL_REF.

Index: cse.c
===================================================================
RCS file: /cvs/uberbaum/gcc/cse.c,v
retrieving revision 1.260
diff -p -2 -r1.260 cse.c
*** cse.c	3 May 2003 14:25:21 -0000	1.260
--- cse.c	14 May 2003 03:59:31 -0000
*************** cse_insn (insn, libcall_insn)
*** 4910,4913 ****
--- 4910,4919 ----
        src_eqv = fold_rtx (canon_reg (XEXP (tem, 0), NULL_RTX), insn);
        XEXP (tem, 0) = src_eqv;
+ 
+       /* If we reduced src_eqv to a single LABEL_REF, it might be an
+ 	 obsolete LABEL_REF.  Use the actual JUMP_LABEL instead.  */
+       if (GET_CODE (src_eqv) == LABEL_REF
+ 	  && GET_CODE (insn) == JUMP_INSN)
+ 	src_eqv = gen_rtx_LABEL_REF (VOIDmode, JUMP_LABEL (insn));
      }
  


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