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]

Re: cfg merge part 19 - gcse tweek


> In message <20020606213140.GD16130@atrey.karlin.mff.cuni.cz>, Jan Hubicka write
> s:
>  > > 
>  > > The problem is that gcse_emit_move_after, called from pre_delete creates a
>  > n
>  > > instruction:
>  > > 
>  > > 
>  > > (insn 858 467 468 25 (nil) (set (reg/v:SF 210)
>  > >         (reg:SF 258)) -1 (nil)
>  > >     (nil))
>  > > 
>  > > If you are trying to generate a move insn that 'just works', I suggest you
>  >  look
>  > > at
>  > > gen_move_insn.
>  > 
>  > Hmm, I sitll keep it reading that way.  want_to_gcse does:
>  > 
>  > 
>  >   /* Otherwise, check if we can make a valid insn from it.  First initialize
>  >      our test insn if we haven't already.  */
>  >   if (test_insn == 0)
>  >     {
>  >       test_insn
>  > 	= make_insn_raw (gen_rtx_SET (VOIDmode,
>  > 				      gen_rtx_REG (word_mode,
>  > 						   FIRST_PSEUDO_REGISTER * 2),
>  > 				      const0_rtx));
>  >       NEXT_INSN (test_insn) = PREV_INSN (test_insn) = 0;
>  >     }
>  > 
>  >   /* Now make an insn like the one we would make when GCSE'ing and see if
>  >      valid.  */
>  >   PUT_MODE (SET_DEST (PATTERN (test_insn)), GET_MODE (x));
>  >   SET_SRC (PATTERN (test_insn)) = x;
>  >   return ((icode = recog (PATTERN (test_insn), test_insn, &num_clobbers)) >=
>  >  0
>  > 	  && (num_clobbers == 0 || ! added_clobbers_hard_reg_p (icode)));
>  > 
>  > So basically it test that (set (destination) (register)) is a valid
>  > instruction and that is exactly what I emit.  What did I missed?
>  > What I am affraid of is the fact that the dest don't have to be
>  > gneeral_operand, so passing it into gen_move is de-facto invalid.
> No, you're missing the point. 
> 
> 
> 
> The original expression might look like
> 
> [(set (reg) (expression))
>  (clobber flags)]
> 
> We can't simply do a replacement of (expression) with a new pseudo reg and
> assume that the result will be valid.  You need to either check that it
> is valid or generate a new insn for the set and emit it.

No, the test_insn is always just ((set) (possibly some garbage) (reg))

The attached patch appears to do the trick.  i386 bootstrap is in
progress, OK if it suceeds?

Thu Jun  6 23:42:06 CEST 2002  Jan Hubicka  <jh@suse.cz>
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
retrieving revision 1.201
diff -c -3 -p -r1.201 gcse.c
*** gcse.c	4 Jun 2002 11:30:29 -0000	1.201
--- gcse.c	6 Jun 2002 21:42:03 -0000
*************** gcse_emit_move_after (src, dest, insn)
*** 5158,5163 ****
--- 5158,5168 ----
  
    new = emit_insn_after (gen_rtx_SET (VOIDmode, dest, src), insn);
  
+   /* want_to_gcse_p verifies that this move will be valid.  Still this call
+      is mandatory as it may create clobbers required by the pattern.  */
+   if (insn_invalid_p (insn))
+     abort ();
+ 
    /* Note the equivalence for local CSE pass.  */
    if ((note = find_reg_equal_equiv_note (insn)))
      eqv = XEXP (note, 0);


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