PR target/37055

Jan Hubicka jh@suse.cz
Sat Aug 9 08:38:00 GMT 2008


Hi,
this patch makes expand_fix to be prepared for expansion to fail as now happens
on some SSE conversions.  I've also added code to remove generated junk, since
we do this from loop and produce some unnecessary instructions and noticed
that my previous expand_sfix_optab was wrong in a way terminating loop before
all options was tested.

Bootstrapped/regtested i686-linux, OK?

Honza

	PR target/37055
	* optabs.c (maybe_emit_unop_insn): Remove produced code if expansion
	* failed.
	(expand_fix): Be prepared for expansion to fail.
	(expand_sfix_optab): Remove instructions if expansion failed.
Index: optabs.c
===================================================================
*** optabs.c	(revision 138862)
--- optabs.c	(working copy)
*************** maybe_emit_unop_insn (int icode, rtx tar
*** 3769,3774 ****
--- 3769,3775 ----
    rtx temp;
    enum machine_mode mode0 = insn_data[icode].operand[1].mode;
    rtx pat;
+   rtx last = get_last_insn ();
  
    temp = target;
  
*************** maybe_emit_unop_insn (int icode, rtx tar
*** 3782,3788 ****
  
    pat = GEN_FCN (icode) (temp, op0);
    if (!pat)
!     return false;
  
    if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX && code != UNKNOWN)
      add_equal_note (pat, temp, code, op0, NULL_RTX);
--- 3783,3792 ----
  
    pat = GEN_FCN (icode) (temp, op0);
    if (!pat)
!     {
!       delete_insns_since (last);
!       return false;
!     }
  
    if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX && code != UNKNOWN)
      add_equal_note (pat, temp, code, op0, NULL_RTX);
*************** expand_fix (rtx to, rtx from, int unsign
*** 5157,5162 ****
--- 5161,5167 ----
  
  	if (icode != CODE_FOR_nothing)
  	  {
+ 	    rtx last = get_last_insn ();
  	    if (fmode != GET_MODE (from))
  	      from = convert_to_mode (fmode, from, 0);
  
*************** expand_fix (rtx to, rtx from, int unsign
*** 5170,5180 ****
  	    if (imode != GET_MODE (to))
  	      target = gen_reg_rtx (imode);
  
! 	    emit_unop_insn (icode, target, from,
! 			    doing_unsigned ? UNSIGNED_FIX : FIX);
! 	    if (target != to)
! 	      convert_move (to, target, unsignedp);
! 	    return;
  	  }
        }
  
--- 5175,5188 ----
  	    if (imode != GET_MODE (to))
  	      target = gen_reg_rtx (imode);
  
! 	    if (maybe_emit_unop_insn (icode, target, from,
! 				      doing_unsigned ? UNSIGNED_FIX : FIX))
! 	      {
! 		if (target != to)
! 		  convert_move (to, target, unsignedp);
! 		return;
! 	      }
! 	    delete_insns_since (last);
  	  }
        }
  
*************** expand_sfix_optab (rtx to, rtx from, con
*** 5382,5387 ****
--- 5390,5396 ----
  	icode = convert_optab_handler (tab, imode, fmode)->insn_code;
  	if (icode != CODE_FOR_nothing)
  	  {
+ 	    rtx last = get_last_insn ();
  	    if (fmode != GET_MODE (from))
  	      from = convert_to_mode (fmode, from, 0);
  
*************** expand_sfix_optab (rtx to, rtx from, con
*** 5389,5395 ****
  	      target = gen_reg_rtx (imode);
  
  	    if (!maybe_emit_unop_insn (icode, target, from, UNKNOWN))
! 	      return false;
  	    if (target != to)
  	      convert_move (to, target, 0);
  	    return true;
--- 5398,5407 ----
  	      target = gen_reg_rtx (imode);
  
  	    if (!maybe_emit_unop_insn (icode, target, from, UNKNOWN))
! 	      {
! 	        delete_insns_since (last);
! 		continue;
! 	      }
  	    if (target != to)
  	      convert_move (to, target, 0);
  	    return true;



More information about the Gcc-patches mailing list