johannes    02/09/25 12:24:24

  Modified:    gcc/config/rs6000 rs6000.c rs6000.md
  Log:
  Fix 20011029-1.c (elide emission of bcl insn following saveFP call)
  
  Revision  Changes    Path
  1.174     +65 -93    gcc3/gcc/config/rs6000/rs6000.c
  
  Index: rs6000.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/config/rs6000/rs6000.c,v
  retrieving revision 1.173
  retrieving revision 1.174
  diff -u -r1.173 -r1.174
  --- rs6000.c  2002/09/17 22:13:58     1.173
  +++ rs6000.c  2002/09/25 19:24:22     1.174
  @@ -3791,7 +3791,7 @@
                      adjust_address (operands[1], SImode, 4));
         return;
       }
  -  
  +
     if (! no_new_pseudos && GET_CODE (operands[0]) != REG)
       operands[1] = force_reg (mode, operands[1]);
   
  @@ -12333,6 +12333,15 @@
         int i, j, sz;
         rtx treg;
         rtvec p;
  +      int gen_following_label = 0;
  +
  +#ifdef INSN_SCHEDULING
  +      /* Prevent the compiler from crashing
  +      while scheduling insns after global_alloc!  */
  +      if (optimize == 0 || !flag_schedule_insns_after_reload)
  +#endif
  +      if (current_function_uses_pic_offset_table && flag_pic)
  +     gen_following_label = lr_already_set_up_for_pic = 1;
   
         /* The SAVE_WORLD and RESTORE_WORLD routines make a number of
         assumptions about the offsets of various bits of the stack
  @@ -12356,6 +12365,7 @@
   
         /* APPLE LOCAL preserve CR2 for save_world prologues */
         sz = 6;
  +      sz += gen_following_label;
         sz += 32 - info->first_gp_reg_save;
         sz += 64 - info->first_fp_reg_save;
         sz += LAST_ALTIVEC_REGNO - info->first_altivec_reg_save + 1;
  @@ -12367,6 +12377,8 @@
         RTVEC_ELT (p, j++) = gen_rtx_USE (VOIDmode,
                                        gen_rtx_SYMBOL_REF (Pmode,
                                                            "*save_world"));
  +      if ( gen_following_label )
  +     RTVEC_ELT (p, j++) = gen_rtx_USE (VOIDmode, const0_rtx);
         /* We do floats first so that the instruction pattern matches
         properly.  */
         for (i = 0; i < 64 - info->first_fp_reg_save; i++)
  @@ -12459,18 +12471,6 @@
                                    NULL_RTX, NULL_RTX);
            }
        }
  -
  -#ifdef INSN_SCHEDULING
  -      /* Prevent the compiler from crashing
  -      while scheduling insns after global_alloc!  */
  -      if (optimize == 0 || !flag_schedule_insns_after_reload)
  -#endif
  -      if (current_function_uses_pic_offset_table && flag_pic)
  -     {
  -       rtx picbase_label = gen_label_rtx ();
  -       insn = emit_label (picbase_label);
  -       lr_already_set_up_for_pic = 1;
  -     }
         callers_lr_already_saved = 1;
         saved_world = 1;
         goto world_saved;
  @@ -12509,10 +12509,28 @@
         char rname[30];
         const char *alloc_rname;
         rtvec p;
  +
  +      /* APPLE LOCAL begin Reduce code size / improve performance */
  +      int gen_following_label = 0;
  +      int count = 0;
  +
  +      if (current_function_uses_pic_offset_table && flag_pic
  +#ifdef INSN_SCHEDULING
  +       /* Prevent the compiler from crashing
  +          while scheduling insns after global_alloc!  */
  +       && (optimize == 0 || !flag_schedule_insns_after_reload)
  +#endif
  +       /* If this is the last CALL in the prolog, then we've got our PC.
  +          If we're saving AltiVec regs via a function, we're not last.  */
  +       && (info->first_altivec_reg_save > LAST_ALTIVEC_REGNO 
  +           || VECTOR_SAVE_INLINE (info->first_altivec_reg_save)))
  +     gen_following_label = lr_already_set_up_for_pic = 1;
  +
         /* APPLE LOCAL: +2 (could be conditionalized) */
  -      p = rtvec_alloc (2 + 64 - info->first_fp_reg_save + 2);
  +      p = rtvec_alloc (2 + 64 - info->first_fp_reg_save + 2
  +                     + gen_following_label);
         
  -      RTVEC_ELT (p, 0) = gen_rtx_CLOBBER (VOIDmode, 
  +      RTVEC_ELT (p, count++) = gen_rtx_CLOBBER (VOIDmode, 
                                          gen_rtx_REG (Pmode, 
                                                       LINK_REGISTER_REGNUM));
         /* APPLE LOCAL begin reduce code size */
  @@ -12536,9 +12554,12 @@
         /* APPLE LOCAL reduce code size */
   #endif /* TARGET_MACHO */
         alloc_rname = ggc_strdup (rname);
  -      RTVEC_ELT (p, 1) = gen_rtx_USE (VOIDmode,
  +      RTVEC_ELT (p, count++) = gen_rtx_USE (VOIDmode,
                                      gen_rtx_SYMBOL_REF (Pmode,
                                                          alloc_rname));
  +      /* APPLE LOCAL reduce code size */
  +      if ( gen_following_label )
  +     RTVEC_ELT (p, count++) = gen_rtx_USE (VOIDmode, const0_rtx);
         for (i = 0; i < 64 - info->first_fp_reg_save; i++)
        {
          rtx addr, reg, mem;
  @@ -12549,12 +12570,12 @@
          mem = gen_rtx_MEM (DFmode, addr);
          set_mem_alias_set (mem, rs6000_sr_alias_set);
   
  -       RTVEC_ELT (p, i + 2) = gen_rtx_SET (VOIDmode, mem, reg);
  +       RTVEC_ELT (p, count++) = gen_rtx_SET (VOIDmode, mem, reg);
        }
         /* APPLE LOCAL begin fix 2866661 */
   #if TARGET_MACHO
         /* Darwin version of these functions stores R0.  */
  -      RTVEC_ELT (p, i + 2) = gen_rtx_USE (VOIDmode, gen_rtx_REG (Pmode, 0));
  +      RTVEC_ELT (p, count++) = gen_rtx_USE (VOIDmode, gen_rtx_REG (Pmode, 0));
   
         /* If we saved LR, *tell* people about it!  */
         if (info->lr_save_p)
  @@ -12564,7 +12585,7 @@
          rtx mem = gen_rtx_MEM (Pmode, addr);
          /* This should not be of rs6000_sr_alias_set, because of
             __builtin_return_address.  */
  -       RTVEC_ELT (p, i + 3) = gen_rtx_SET (Pmode, mem, 
  +       RTVEC_ELT (p, count++) = gen_rtx_SET (Pmode, mem, 
                                gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM));
        }
   #endif
  @@ -12572,27 +12593,7 @@
         insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
         rs6000_frame_related (insn, frame_ptr_rtx, info->total_size, 
                            NULL_RTX, NULL_RTX);
  -
  -      /* APPLE LOCAL begin Reduce code size / improve performance */
  -#if TARGET_MACHO
         callers_lr_already_saved = 1;
  -
  -      if (current_function_uses_pic_offset_table && flag_pic
  -#ifdef INSN_SCHEDULING
  -       /* Prevent the compiler from crashing
  -          while scheduling insns after global_alloc!  */
  -       && (optimize == 0 || !flag_schedule_insns_after_reload)
  -#endif
  -       /* If this is the last CALL in the prolog, then we've got our PC.
  -          If we're saving AltiVec regs via a function, we're not last.  */
  -       && (info->first_altivec_reg_save > LAST_ALTIVEC_REGNO 
  -           || VECTOR_SAVE_INLINE (info->first_altivec_reg_save)))
  -     {
  -       rtx picbase_label = gen_label_rtx ();
  -       insn = emit_label (picbase_label);
  -       lr_already_set_up_for_pic = 1;
  -     }
  -#endif /* TARGET_MACHO */
       }
   
     /* Save GPRs.  This is done as a PARALLEL if we are using
  @@ -12808,13 +12809,26 @@
         const char *alloc_rname;
         int vregno = info->first_altivec_reg_save - FIRST_ALTIVEC_REGNO;
         rtvec p;
  -
  +      /* APPLE LOCAL begin performance enhancement */
  +      int j=0;
  +      int gen_following_label = 0;
  +      /* APPLE LOCAL end performance enhancement */
         rtx addr = gen_rtx_PLUS (Pmode, frame_reg_rtx,
                               GEN_INT (info->altivec_save_offset + 
                                        sp_offset + info->altivec_size));
         rtx treg = gen_rtx_REG (Pmode, 0);
         emit_move_insn (treg, addr);
   
  +      /* APPLE LOCAL begin performance enhancement */
  +#ifdef INSN_SCHEDULING
  +      /* Prevent the compiler from crashing
  +      while scheduling insns after global_alloc!  */
  +      if (optimize == 0 || !flag_schedule_insns_after_reload)
  +#endif
  +      if (current_function_uses_pic_offset_table && flag_pic)
  +     gen_following_label = lr_already_set_up_for_pic = 1;
  +      /* APPLE LOCAL end performance enhancement */
  +
   #if TARGET_MACHO
        /* A Darwin extension to the vector save routine is to have a
           variant which returns with VRsave in R11.  A clobber is
  @@ -12828,14 +12842,18 @@
   #endif
         alloc_rname = ggc_strdup (rname);
   
  -      p = rtvec_alloc (3 + LAST_ALTIVEC_REGNO+1 
  +      p = rtvec_alloc (3 + LAST_ALTIVEC_REGNO+1
  +             + gen_following_label
                - info->first_altivec_reg_save
                + ((TARGET_MACHO && info->vrsave_save_p) ? 1 : 0));
  -      RTVEC_ELT (p, 0) = gen_rtx_CLOBBER (VOIDmode, 
  +      RTVEC_ELT (p, j++) = gen_rtx_CLOBBER (VOIDmode, 
                                          gen_rtx_REG (Pmode, 
                                                       LINK_REGISTER_REGNUM));
  -      RTVEC_ELT (p, 1) = gen_rtx_USE (VOIDmode,
  -                                   gen_rtx_SYMBOL_REF (Pmode, alloc_rname));
  +      RTVEC_ELT (p, j++) = gen_rtx_USE (VOIDmode,
  +                                   gen_rtx_SYMBOL_REF (Pmode, alloc_rname)); 
  +      /* APPLE LOCAL performance enhancement */
  +      if ( gen_following_label )
  +     RTVEC_ELT (p, j++) = gen_rtx_USE (VOIDmode, const0_rtx);
   
         for (i = 0; info->first_altivec_reg_save + i <= LAST_ALTIVEC_REGNO; i++)
        {
  @@ -12846,36 +12864,18 @@
          rtx mem = gen_rtx_MEM (V4SImode, addr);
          set_mem_alias_set (mem, rs6000_sr_alias_set);
   
  -       RTVEC_ELT (p, i + 2) = gen_rtx_SET (VOIDmode, mem, reg);
  +       RTVEC_ELT (p, j++) = gen_rtx_SET (VOIDmode, mem, reg);
        }
         /* Prevent any attempt to delete the setting of treg!  */
  -      RTVEC_ELT (p, i + 2) = gen_rtx_USE (VOIDmode, treg);
  +      RTVEC_ELT (p, j++) = gen_rtx_USE (VOIDmode, treg);
   
         if ( TARGET_MACHO && info->vrsave_save_p )
  -     RTVEC_ELT (p, i + 3) = gen_rtx_CLOBBER (VOIDmode,
  +     RTVEC_ELT (p, j++) = gen_rtx_CLOBBER (VOIDmode,
                                    gen_rtx_REG (SImode, 11));
   
         insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
         rs6000_frame_related (insn, frame_ptr_rtx, info->total_size, 
                            NULL_RTX, NULL_RTX);
  -
  -#ifdef INSN_SCHEDULING
  -      /* Prevent the compiler from crashing
  -      while scheduling insns after global_alloc!  */
  -      if (optimize == 0 || !flag_schedule_insns_after_reload)
  -#endif
  -      if (current_function_uses_pic_offset_table && flag_pic)
  -     {
  -       /* this is the last CALL in the prolog --> we've got our PC.  */
  -       rtx picbase_label = gen_label_rtx ();
  -       insn = emit_label (picbase_label);
  -
  -#if TARGET_MACHO
  -       if (lr_already_set_up_for_pic)
  -         abort ();   /* Impossible  */
  -       lr_already_set_up_for_pic = 1;
  -#endif
  -     }
       }
   
   #if TARGET_MACHO
  @@ -12975,34 +12975,6 @@
           }
       }
     /* APPLE LOCAL end AltiVec */
  -
  -  /* non-Apple version of vrsave bits.  */
  -  if (0 && TARGET_ALTIVEC && info->vrsave_mask != 0)
  -    {
  -      rtx reg, vrsave, addr, mem;
  -
  -      /* Get VRSAVE onto a GPR.  */
  -      reg = gen_rtx_REG (SImode, 12);
  -      vrsave = gen_rtx_REG (SImode, VRSAVE_REGNO);
  -      emit_insn (gen_rtx_SET (VOIDmode, reg, vrsave));
  -
  -      /* Save VRSAVE.  */
  -      addr = gen_rtx_PLUS (Pmode, frame_reg_rtx,
  -                        GEN_INT (info->vrsave_save_offset + sp_offset));
  -      mem = gen_rtx_MEM (SImode, addr);
  -      set_mem_alias_set (mem, rs6000_sr_alias_set);
  -      insn = emit_move_insn (mem, reg);
  -      rs6000_frame_related (insn, frame_ptr_rtx, info->total_size,
  -                         NULL_RTX, NULL_RTX);
  -
  -      /* Include the registers in the mask.  */
  -      emit_insn (gen_iorsi3 (reg, reg, GEN_INT ((int) info->vrsave_mask)));
  -
  -      insn = emit_insn (generate_set_vrsave (reg, info, 0));
  -
  -      rs6000_frame_related (insn, frame_ptr_rtx, info->total_size,
  -                         NULL_RTX, NULL_RTX);
  -    }
   
     /* Set frame pointer, if needed.  */
     if (frame_pointer_needed)
  
  
  
  1.79      +41 -1     gcc3/gcc/config/rs6000/rs6000.md
  
  Index: rs6000.md
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/config/rs6000/rs6000.md,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- rs6000.md 2002/09/10 20:53:45     1.78
  +++ rs6000.md 2002/09/25 19:24:22     1.79
  @@ -15409,6 +15409,26 @@
    "TARGET_32BIT"
    "bl %z2")
   
  +/* APPLE LOCAL */
  +(define_insn "*save_fpregs_with_label_si"
  + [(match_parallel 0 "any_operand"
  +                  [(clobber (match_operand:SI 1 "register_operand" "=l"))
  +                (use (match_operand:SI 2 "call_operand" "s"))
  +                (use (match_operand:SI 3 "" ""))
  +                (set (match_operand:DF 4 "memory_operand" "=m")
  +                     (match_operand:DF 5 "gpc_reg_operand" "f"))])]
  + "TARGET_32BIT"
  + "*
  +#if TARGET_MACHO
  +  char *picbase = machopic_function_base_name ();
  +  operands[3] = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
  +#endif
  +  return \"bl %z2\\n%3:\";
  +"
  +  [(set_attr "type" "branch")
  +   (set_attr "length" "4")])
  +/* APPLE LOCAL end */
  +
   (define_insn "*save_fpregs_di"
    [(match_parallel 0 "any_operand"
                     [(clobber (match_operand:DI 1 "register_operand" "=l"))
  @@ -15426,7 +15446,27 @@
                   (set (match_operand:V4SI 3 "any_operand" "=m")
                        (match_operand:V4SI 4 "register_operand" "v"))])]
    "TARGET_32BIT"
  - "bl %z2")
  + "bl %z2"
  +  [(set_attr "type" "branch")
  +   (set_attr "length" "4")])
  +
  +(define_insn "*save_vregs_with_label_si"
  + [(match_parallel 0 "any_operand"
  +                  [(clobber (match_operand:SI 1 "register_operand" "=l"))
  +                (use (match_operand:SI 2 "call_operand" "s"))
  +                (use (match_operand:SI 3 "" ""))
  +                (set (match_operand:V4SI 4 "any_operand" "=m")
  +                     (match_operand:V4SI 5 "register_operand" "v"))])]
  + "TARGET_32BIT"
  + "*
  +#if TARGET_MACHO
  +  char *picbase = machopic_function_base_name ();
  +  operands[3] = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
  +#endif
  +  return \"bl %z2\\n%3:\";
  +"
  +  [(set_attr "type" "branch")
  +   (set_attr "length" "4")])
   ; APPLE LOCAL end AltiVec
   
   ; These are to explain that changes to the stack pointer should
  
  
  


Reply via email to