Promoting code tweaks

Jan Hubicka hubicka@atrey.karlin.mff.cuni.cz
Sat Jan 22 05:13:00 GMT 2000


Wed Jan 19 19:47:10 CET 2000  Jan Hubicka  <jh@suse.cz>
	* i386.h (PREDICATE_CODES): Add aligned_operand.
	* i386.c (aligned_operand): New function.
	(ix86_aligned_p): Kill.
	* i386.md (movhi_1): Emit mov for aligned operands.
	(promoting peep2s): Use aligned_operand.

*** i386.h.nos	Wed Dec 15 19:56:56 1999
--- i386.h	Wed Dec 22 12:15:36 1999
*************** do { long l;						\
*** 2422,2427 ****
--- 2425,2432 ----
  
  #define PREDICATE_CODES							\
    {"symbolic_operand", {SYMBOL_REF, LABEL_REF, CONST}},			\
+   {"aligned_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,	\
+ 		       LABEL_REF, SUBREG, REG, MEM}},			\
    {"pic_symbolic_operand", {CONST}},					\
    {"call_insn_operand", {MEM}},						\
    {"expander_call_insn_operand", {MEM}},				\
*** i386.c.nos	Wed Dec 15 19:57:08 1999
--- i386.c	Wed Dec 22 12:15:48 1999
*************** optimization_options (level, size)
*** 617,673 ****
  #endif
  }
  
- /* Return nonzero if the rtx is known aligned.  */
- /* ??? Unused.  */
- 
- int
- ix86_aligned_p (op)
-      rtx op;
- {
-   struct ix86_address parts;
- 
-   /* Registers and immediate operands are always "aligned". */
-   if (GET_CODE (op) != MEM)
-     return 1;
- 
-   /* Don't even try to do any aligned optimizations with volatiles. */
-   if (MEM_VOLATILE_P (op))
-     return 0;
- 
-   op = XEXP (op, 0);
- 
-   /* Pushes and pops are only valid on the stack pointer.  */
-   if (GET_CODE (op) == PRE_DEC
-       || GET_CODE (op) == POST_INC)
-     return 1;
- 
-   /* Decode the address.  */
-   if (! ix86_decompose_address (op, &parts))
-     abort ();
- 
-   /* Look for some component that isn't known to be aligned.  */
-   if (parts.index)
-     {
-       if (parts.scale < 4
- 	  && REGNO_POINTER_ALIGN (REGNO (parts.index)) < 4)
- 	return 0;
-     }
-   if (parts.base)
-     {
-       if (REGNO_POINTER_ALIGN (REGNO (parts.index)) < 4)
- 	return 0;
-     }
-   if (parts.disp)
-     {
-       if (GET_CODE (parts.disp) != CONST_INT
- 	  || (INTVAL (parts.disp) & 3) != 0)
- 	return 0;
-     }
- 
-   /* Didn't find one -- this must be an aligned address.  */
-   return 1;
- }
- 
  /* Return nonzero if IDENTIFIER with arguments ARGS is a valid machine specific
     attribute for DECL.  The attributes in ATTRIBUTES have previously been
     assigned to DECL.  */
--- 617,622 ----
*************** long_memory_operand (op, mode)
*** 1298,1303 ****
--- 1273,1332 ----
  
    return memory_address_length (op) != 0;
  }
+ 
+ /* Return nonzero if the rtx is known aligned.  */
+ 
+ int
+ aligned_operand (op, mode)
+      rtx op;
+      enum machine_mode mode;
+ {
+   struct ix86_address parts;
+ 
+   if (!general_operand (op, mode))
+     return 0;
+ 
+   /* Registers and immediate operands are always "aligned". */
+   if (GET_CODE (op) != MEM)
+     return 1;
+ 
+   /* Don't even try to do any aligned optimizations with volatiles. */
+   if (MEM_VOLATILE_P (op))
+     return 0;
+ 
+   op = XEXP (op, 0);
+ 
+   /* Pushes and pops are only valid on the stack pointer.  */
+   if (GET_CODE (op) == PRE_DEC
+       || GET_CODE (op) == POST_INC)
+     return 1;
+ 
+   /* Decode the address.  */
+   if (! ix86_decompose_address (op, &parts))
+     abort ();
+ 
+   /* Look for some component that isn't known to be aligned.  */
+   if (parts.index)
+     {
+       if (parts.scale < 4
+ 	  && REGNO_POINTER_ALIGN (REGNO (parts.index)) < 4)
+ 	return 0;
+     }
+   if (parts.base)
+     {
+       if (REGNO_POINTER_ALIGN (REGNO (parts.base)) < 4)
+ 	return 0;
+     }
+   if (parts.disp)
+     {
+       if (GET_CODE (parts.disp) != CONST_INT
+ 	  || (INTVAL (parts.disp) & 3) != 0)
+ 	return 0;
+     }
+ 
+   /* Didn't find one -- this must be an aligned address.  */
+   return 1;
+ }
  
  /* Return true if the constant is something that can be loaded with
     a special instruction.  Only handle 0.0 and 1.0; others are less
*** i386.md.nos	Wed Dec 15 19:56:53 1999
--- i386.md	Tue Jan  4 20:52:24 2000
***************
*** 1298,1304 ****
      }
  }"
    [(set (attr "type")
!      (cond [(eq_attr "alternative" "0")
  	      (const_string "imov")
  	    (and (ne (symbol_ref "TARGET_MOVX")
  		     (const_int 0))
--- 1298,1305 ----
      }
  }"
    [(set (attr "type")
!      (cond [(and (eq_attr "alternative" "0,1")
! 		 (match_operand:HI 1 "aligned_operand" ""))
  	      (const_string "imov")
  	    (and (ne (symbol_ref "TARGET_MOVX")
  		     (const_int 0))
***************
*** 1309,1317 ****
      (set (attr "length_prefix")
        (cond [(eq_attr "type" "imovx")
  	       (const_string "0")
! 	     (and (eq_attr "alternative" "0")
! 		  (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
! 		      (const_int 0)))
  	       (const_string "0")
  	    ]
  	    (const_string "1")))
--- 1310,1319 ----
      (set (attr "length_prefix")
        (cond [(eq_attr "type" "imovx")
  	       (const_string "0")
! 	     (and (eq_attr "alternative" "0,1")
! 		  (and (match_operand:HI 1 "aligned_operand" "")
! 		       (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
! 			   (const_int 0))))
  	       (const_string "0")
  	    ]
  	    (const_string "1")))
*** i386-protos.h.old	Wed Jan 19 19:45:09 2000
--- i386-protos.h	Wed Jan 19 19:45:23 2000
*************** extern int promotable_binary_operator PA
*** 64,69 ****
--- 64,70 ----
  extern int memory_displacement_operand PARAMS ((rtx, enum machine_mode));
  extern int cmpsi_operand PARAMS ((rtx, enum machine_mode));
  extern int long_memory_operand PARAMS ((rtx, enum machine_mode));
+ extern int aligned_operand PARAMS ((rtx, enum machine_mode));
  
  
  extern int legitimate_pic_address_disp_p PARAMS ((rtx));
*** i386.md.old	Wed Jan 19 19:39:21 2000
--- i386.md	Wed Jan 19 19:41:14 2000
***************
*** 1397,1403 ****
      }
  }"
    [(set (attr "type")
!      (cond [(eq_attr "alternative" "0")
  	      (const_string "imov")
  	    (and (ne (symbol_ref "TARGET_MOVX")
  		     (const_int 0))
--- 1397,1404 ----
      }
  }"
    [(set (attr "type")
!      (cond [(and (eq_attr "alternative" "0,1")
! 		 (match_operand:HI 1 "aligned_operand" ""))
  	      (const_string "imov")
  	    (and (ne (symbol_ref "TARGET_MOVX")
  		     (const_int 0))
***************
*** 1408,1416 ****
      (set (attr "length_prefix")
        (cond [(eq_attr "type" "imovx")
  	       (const_string "0")
! 	     (and (eq_attr "alternative" "0")
! 		  (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
! 		      (const_int 0)))
  	       (const_string "0")
  	    ]
  	    (const_string "1")))
--- 1409,1418 ----
      (set (attr "length_prefix")
        (cond [(eq_attr "type" "imovx")
  	       (const_string "0")
! 	     (and (eq_attr "alternative" "0,1")
! 		  (and (match_operand:HI 1 "aligned_operand" "")
! 		       (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
! 			   (const_int 0))))
  	       (const_string "0")
  	    ]
  	    (const_string "1")))
***************
*** 8562,8568 ****
    [(set (match_operand 0 "register_operand" "")
  	(match_operator 3 "promotable_binary_operator"
  	   [(match_operand 1 "register_operand" "")
! 	    (match_operand 2 "nonmemory_operand" "")]))
     (clobber (reg:CC 17))]
    "! TARGET_PARTIAL_REG_STALL && reload_completed
     && ((GET_MODE (operands[0]) == HImode 
--- 8564,8570 ----
    [(set (match_operand 0 "register_operand" "")
  	(match_operator 3 "promotable_binary_operator"
  	   [(match_operand 1 "register_operand" "")
! 	    (match_operand 2 "aligned_operand" "")]))
     (clobber (reg:CC 17))]
    "! TARGET_PARTIAL_REG_STALL && reload_completed
     && ((GET_MODE (operands[0]) == HImode 
***************
*** 8581,8587 ****
  
  (define_split
    [(set (reg:CCNO 17)
! 	(compare:CCNO (and (match_operand 1 "register_operand" "")
  			   (match_operand 2 "immediate_operand" ""))
  		      (const_int 0)))
     (set (match_operand 0 "register_operand" "")
--- 8583,8589 ----
  
  (define_split
    [(set (reg:CCNO 17)
! 	(compare:CCNO (and (match_operand 1 "aligned_operand" "")
  			   (match_operand 2 "immediate_operand" ""))
  		      (const_int 0)))
     (set (match_operand 0 "register_operand" "")
***************
*** 8601,8607 ****
  
  (define_split
    [(set (reg:CCNO 17)
! 	(compare:CCNO (and (match_operand 0 "register_operand" "")
  			   (match_operand 1 "immediate_operand" ""))
  		      (const_int 0)))]
    "! TARGET_PARTIAL_REG_STALL && reload_completed
--- 8603,8609 ----
  
  (define_split
    [(set (reg:CCNO 17)
! 	(compare:CCNO (and (match_operand 0 "aligned_operand" "")
  			   (match_operand 1 "immediate_operand" ""))
  		      (const_int 0)))]
    "! TARGET_PARTIAL_REG_STALL && reload_completed


More information about the Gcc-patches mailing list