fix code alignment

Jan Hubicka jh@suse.cz
Thu Nov 8 06:33:00 GMT 2001


Hi,
the last align_* cleanup has killed i386 max_skip code, that is quite
imporant trick. The LABEL_ALIGN_MAX_SKIP is defined to (align_labels-1)
and the LABEL_ALIGN_MAX_SKIP in i386.h is gone.

I've fixed it by introducing the max_skip familly of variables I set
to proper values.  I've also moved i386.c from negative-numbers hack
to have explicit bot alignments and skips as it makes it easier to tune
for new chips.

If it makes sense, I can followup by adding and command line parameters
for this, but I am not quite sure what to do if target does not support
the feature. (I should probably warn, but how to detect it?)

Honza
Thu Nov  8 15:30:01 CET 2001  Jan Hubicka  <jh@suse.cz>

	* final.c (*_MAX_SKIP): Use *_max_skip variables.
	* flags.h (align_loops_max_skip, align_jumps_max_skip,
	align_labels_max_skip): New global variables.
	* toplev.c (align_loops_max_skip, align_jumps_max_skip,
	align_labels_max_skip): New global variables.
	(toplev_main): Set new variables.

Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.216
diff -c -3 -p -r1.216 final.c
*** final.c	2001/11/04 02:26:54	1.216
--- final.c	2001/11/08 14:20:11
*************** get_attr_length (insn)
*** 775,781 ****
  #endif
  
  #ifndef LABEL_ALIGN_MAX_SKIP
! #define LABEL_ALIGN_MAX_SKIP (align_labels-1)
  #endif
  
  #ifndef LOOP_ALIGN
--- 775,781 ----
  #endif
  
  #ifndef LABEL_ALIGN_MAX_SKIP
! #define LABEL_ALIGN_MAX_SKIP align_labels_max_skip
  #endif
  
  #ifndef LOOP_ALIGN
*************** get_attr_length (insn)
*** 783,789 ****
  #endif
  
  #ifndef LOOP_ALIGN_MAX_SKIP
! #define LOOP_ALIGN_MAX_SKIP (align_loops-1)
  #endif
  
  #ifndef LABEL_ALIGN_AFTER_BARRIER
--- 783,789 ----
  #endif
  
  #ifndef LOOP_ALIGN_MAX_SKIP
! #define LOOP_ALIGN_MAX_SKIP align_loops_max_skip
  #endif
  
  #ifndef LABEL_ALIGN_AFTER_BARRIER
*************** get_attr_length (insn)
*** 799,805 ****
  #endif
  
  #ifndef JUMP_ALIGN_MAX_SKIP
! #define JUMP_ALIGN_MAX_SKIP (align_jumps-1)
  #endif
  
  #ifndef ADDR_VEC_ALIGN
--- 799,805 ----
  #endif
  
  #ifndef JUMP_ALIGN_MAX_SKIP
! #define JUMP_ALIGN_MAX_SKIP align_jumps_max_skip
  #endif
  
  #ifndef ADDR_VEC_ALIGN
Index: flags.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flags.h,v
retrieving revision 1.69
diff -c -3 -p -r1.69 flags.h
*** flags.h	2001/10/20 10:03:51	1.69
--- flags.h	2001/11/08 14:20:12
*************** extern int g_switch_set;
*** 590,599 ****
--- 590,602 ----
  
  extern int align_loops;
  extern int align_loops_log;
+ extern int align_loops_max_skip;
  extern int align_jumps;
  extern int align_jumps_log;
+ extern int align_jumps_max_skip;
  extern int align_labels;
  extern int align_labels_log;
+ extern int align_labels_max_skip;
  extern int align_functions;
  extern int align_functions_log;
  
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.533
diff -c -3 -p -r1.533 toplev.c
*** toplev.c	2001/11/06 21:12:07	1.533
--- toplev.c	2001/11/08 14:20:13
*************** int flag_renumber_insns = 1;
*** 924,933 ****
--- 924,936 ----
  
  int align_loops;
  int align_loops_log;
+ int align_loops_max_skip;
  int align_jumps;
  int align_jumps_log;
+ int align_jumps_max_skip;
  int align_labels;
  int align_labels_log;
+ int align_labels_max_skip;
  int align_functions;
  int align_functions_log;
  
*************** toplev_main (argc, argv)
*** 4873,4883 ****
--- 4876,4892 ----
    /* Set up the align_*_log variables, defaulting them to 1 if they
       were still unset.  */
    if (align_loops <= 0) align_loops = 1;
+   if (align_loops_max_skip > align_loops || !align_loops)
+     align_loops_max_skip = align_loops - 1;
    align_loops_log = floor_log2 (align_loops * 2 - 1);
    if (align_jumps <= 0) align_jumps = 1;
+   if (align_jumps_max_skip > align_jumps || !align_jumps)
+     align_jumps_max_skip = align_jumps - 1;
    align_jumps_log = floor_log2 (align_jumps * 2 - 1);
    if (align_labels <= 0) align_labels = 1;
    align_labels_log = floor_log2 (align_labels * 2 - 1);
+   if (align_labels_max_skip > align_labels || !align_labels)
+     align_labels_max_skip = align_labels - 1;
    if (align_functions <= 0) align_functions = 1;
    align_functions_log = floor_log2 (align_functions * 2 - 1);
  
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.333
diff -c -3 -p -r1.333 i386.c
*** i386.c	2001/11/07 12:35:14	1.333
--- i386.c	2001/11/08 14:20:18
*************** override_options ()
*** 796,814 ****
        const int target_enable;			/* Target flags to enable.  */
        const int target_disable;			/* Target flags to disable.  */
        const int align_loop;			/* Default alignments.  */
        const int align_jump;
        const int align_func;
        const int branch_cost;
      }
    const processor_target_table[PROCESSOR_max] =
      {
!       {&i386_cost, 0, 0, 2, 2, 2, 1},
!       {&i486_cost, 0, 0, 4, 4, 4, 1},
!       {&pentium_cost, 0, 0, -4, -4, -4, 1},
!       {&pentiumpro_cost, 0, 0, 4, -4, 4, 1},
!       {&k6_cost, 0, 0, -5, -5, 4, 1},
!       {&athlon_cost, 0, 0, 4, -4, 4, 1},
!       {&pentium4_cost, 0, 0, 2, 2, 2, 1}
      };
  
    static struct pta
--- 796,816 ----
        const int target_enable;			/* Target flags to enable.  */
        const int target_disable;			/* Target flags to disable.  */
        const int align_loop;			/* Default alignments.  */
+       const int align_loop_max_skip;
        const int align_jump;
+       const int align_jump_max_skip;
        const int align_func;
        const int branch_cost;
      }
    const processor_target_table[PROCESSOR_max] =
      {
!       {&i386_cost, 0, 0, 2, 3, 2, 3, 2, 1},
!       {&i486_cost, 0, 0, 4, 15, 4, 15, 4, 1},
!       {&pentium_cost, 0, 0, 4, 7, 4, 7, 4, 1},
!       {&pentiumpro_cost, 0, 0, 4, 15, 4, 7, 4, 1},
!       {&k6_cost, 0, 0, 5, 7, 5, 7, 1},
!       {&athlon_cost, 0, 0, 4, 7, 6, 7, 6, 1},
!       {&pentium4_cost, 0, 0, 0, 0, 0, 0, 0, 1}
      };
  
    static struct pta
*************** override_options ()
*** 967,977 ****
    /* Default align_* from the processor table.  */
  #define abs(n) (n < 0 ? -n : n)
    if (align_loops == 0)
!     align_loops = 1 << abs (processor_target_table[ix86_cpu].align_loop);
    if (align_jumps == 0)
!     align_jumps = 1 << abs (processor_target_table[ix86_cpu].align_jump);
    if (align_functions == 0)
!     align_functions = 1 << abs (processor_target_table[ix86_cpu].align_func);
  
    /* Validate -mpreferred-stack-boundary= value, or provide default.
       The default of 128 bits is for Pentium III's SSE __m128, but we
--- 969,987 ----
    /* Default align_* from the processor table.  */
  #define abs(n) (n < 0 ? -n : n)
    if (align_loops == 0)
!     {
!       align_loops = 1 << abs (processor_target_table[ix86_cpu].align_loop);
!       align_loops_max_skip = processor_target_table[ix86_cpu].align_loop_max_skip;
!     }
    if (align_jumps == 0)
!     {
!       align_jumps = 1 << abs (processor_target_table[ix86_cpu].align_jump);
!       align_jumps_max_skip = processor_target_table[ix86_cpu].align_jump_max_skip;
!     }
    if (align_functions == 0)
!     {
!       align_functions = 1 << abs (processor_target_table[ix86_cpu].align_func);
!     }
  
    /* Validate -mpreferred-stack-boundary= value, or provide default.
       The default of 128 bits is for Pentium III's SSE __m128, but we



More information about the Gcc-patches mailing list