attached proposed patch to fix gcc 4.5 bug 4456

--- gcc-4.5.0/gcc/config/i386/i386.md.vanilla	2010-12-23 11:27:32.000000000 +0000
+++ gcc-4.5.0/gcc/config/i386/i386.md	2010-12-23 11:52:18.000000000 +0000
@@ -13183,7 +13183,7 @@
 ;; Define combination compare-and-branch fp compare instructions to help
 ;; combine.
 
-(define_insn "*fp_jcc_3_387"
+(define_insn "*fp_jcc_1_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13201,7 +13201,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_4_387"
+(define_insn "*fp_jcc_1r_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13219,7 +13219,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_5_387"
+(define_insn "*fp_jcc_2_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13234,7 +13234,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_6_387"
+(define_insn "*fp_jcc_2r_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13249,7 +13249,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_7_387"
+(define_insn "*fp_jcc_3_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13266,28 +13266,6 @@
    && !TARGET_CMOVE"
   "#")
 
-;; The order of operands in *fp_jcc_8_387 is forced by combine in
-;; simplify_comparison () function. Float operator is treated as RTX_OBJ
-;; with a precedence over other operators and is always put in the first
-;; place. Swap condition and operands to match ficom instruction.
-
-(define_insn "*fp_jcc_8<mode>_387"
-  [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-			[(match_operator 1 "float_operator"
-			   [(match_operand:X87MODEI12 2 "nonimmediate_operand" "m,?r")])
-			   (match_operand 3 "register_operand" "f,f")])
-	  (label_ref (match_operand 4 "" ""))
-	  (pc)))
-   (clobber (reg:CCFP FPSR_REG))
-   (clobber (reg:CCFP FLAGS_REG))
-   (clobber (match_scratch:HI 5 "=a,a"))]
-  "X87_FLOAT_MODE_P (GET_MODE (operands[3]))
-   && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
-   && GET_MODE (operands[1]) == GET_MODE (operands[3])
-   && ix86_fp_compare_mode (swap_condition (GET_CODE (operands[0]))) == CCFPmode
-   && !TARGET_CMOVE"
-  "#")
 
 (define_split
   [(set (pc)
@@ -13324,9 +13302,37 @@
   DONE;
 })
 
+
+;; The order of operands in *fp_jcc_4_387 is forced by combine in
+;; simplify_comparison () function. Float operator is treated as RTX_OBJ
+;; with a precedence over other operators and is always put in the first
+;; place. Swap condition and operands to match ficom instruction.
+(define_insn "*fp_jcc_4_<mode>_387"
+  [(set (pc)
+    (if_then_else
+	  (match_operator 0 "ix86_reversed_fp_comparison_operator"
+	  [(match_operator 1 "float_operator"
+	    [(match_operand:X87MODEI12 2 "nonimmediate_operand" "m,?r")])
+	    (match_operand 3 "register_operand" "f,f")])
+	    (label_ref (match_operand 4 "" ""))
+	    (pc)))
+	    (clobber (reg:CCFP FPSR_REG))
+	    (clobber (reg:CCFP FLAGS_REG))
+	    (clobber (match_scratch:HI 5 "=a,a"))]
+	    "X87_FLOAT_MODE_P (GET_MODE (operands[3]))
+	    && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
+	    && GET_MODE (operands[1]) == GET_MODE (operands[3])
+	    && ix86_fp_compare_mode (swap_condition (GET_CODE (operands[0]))) == CCFPmode
+	    && !TARGET_CMOVE"
+    "#")
+
+
+
+
+
 (define_split
   [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
+	(if_then_else (match_operator 0 "ix86_reversed_fp_comparison_operator"
 			[(match_operator 1 "float_operator"
 			   [(match_operand:X87MODEI12 2 "memory_operand" "")])
 			   (match_operand 3 "register_operand" "")])
@@ -13348,7 +13354,7 @@
 ;; %%% Kill this when reload knows how to do it.
 (define_split
   [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
+	(if_then_else (match_operator 0 "ix86_reversed_fp_comparison_operator"
 			[(match_operator 1 "float_operator"
 			   [(match_operand:X87MODEI12 2 "register_operand" "")])
 			   (match_operand 3 "register_operand" "")])
--- gcc-4.5.0/gcc/config/i386/predicates.md.vanilla	2010-12-23 11:53:06.000000000 +0000
+++ gcc-4.5.0/gcc/config/i386/predicates.md	2010-12-23 11:57:49.000000000 +0000
@@ -1083,6 +1083,19 @@
                (match_operand 0 "comparison_operator")
                (match_operand 0 "ix86_trivial_fp_comparison_operator")))
 
+;; Same as above, but for reversed comparison used in fp_jcc_4_387.
+(define_predicate "ix86_reversed_fp_comparison_operator"
+  (match_operand 0 "comparison_operator")
+  {
+    enum rtx_code code = GET_CODE (op);
+      int ret;
+        PUT_CODE (op, swap_condition (code));
+          ret = ix86_fp_comparison_operator (op, mode);
+            PUT_CODE (op, code);
+              return ret;
+             })
+
+
 ;; Nearly general operand, but accept any const_double, since we wish
 ;; to be able to drop them into memory rather than have them get pulled
 ;; into registers.
--- gcc-4.5.0/gcc/config/i386/i386.md.vanilla	2010-12-23 11:27:32.000000000 +0000
+++ gcc-4.5.0/gcc/config/i386/i386.md	2010-12-23 11:52:18.000000000 +0000
@@ -13183,7 +13183,7 @@
 ;; Define combination compare-and-branch fp compare instructions to help
 ;; combine.
 
-(define_insn "*fp_jcc_3_387"
+(define_insn "*fp_jcc_1_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13201,7 +13201,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_4_387"
+(define_insn "*fp_jcc_1r_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13219,7 +13219,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_5_387"
+(define_insn "*fp_jcc_2_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13234,7 +13234,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_6_387"
+(define_insn "*fp_jcc_2r_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13249,7 +13249,7 @@
    && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_7_387"
+(define_insn "*fp_jcc_3_387"
   [(set (pc)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
 			[(match_operand 1 "register_operand" "f")
@@ -13266,28 +13266,6 @@
    && !TARGET_CMOVE"
   "#")
 
-;; The order of operands in *fp_jcc_8_387 is forced by combine in
-;; simplify_comparison () function. Float operator is treated as RTX_OBJ
-;; with a precedence over other operators and is always put in the first
-;; place. Swap condition and operands to match ficom instruction.
-
-(define_insn "*fp_jcc_8<mode>_387"
-  [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-			[(match_operator 1 "float_operator"
-			   [(match_operand:X87MODEI12 2 "nonimmediate_operand" "m,?r")])
-			   (match_operand 3 "register_operand" "f,f")])
-	  (label_ref (match_operand 4 "" ""))
-	  (pc)))
-   (clobber (reg:CCFP FPSR_REG))
-   (clobber (reg:CCFP FLAGS_REG))
-   (clobber (match_scratch:HI 5 "=a,a"))]
-  "X87_FLOAT_MODE_P (GET_MODE (operands[3]))
-   && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
-   && GET_MODE (operands[1]) == GET_MODE (operands[3])
-   && ix86_fp_compare_mode (swap_condition (GET_CODE (operands[0]))) == CCFPmode
-   && !TARGET_CMOVE"
-  "#")
 
 (define_split
   [(set (pc)
@@ -13324,9 +13302,37 @@
   DONE;
 })
 
+
+;; The order of operands in *fp_jcc_4_387 is forced by combine in
+;; simplify_comparison () function. Float operator is treated as RTX_OBJ
+;; with a precedence over other operators and is always put in the first
+;; place. Swap condition and operands to match ficom instruction.
+(define_insn "*fp_jcc_4_<mode>_387"
+  [(set (pc)
+    (if_then_else
+	  (match_operator 0 "ix86_reversed_fp_comparison_operator"
+	  [(match_operator 1 "float_operator"
+	    [(match_operand:X87MODEI12 2 "nonimmediate_operand" "m,?r")])
+	    (match_operand 3 "register_operand" "f,f")])
+	    (label_ref (match_operand 4 "" ""))
+	    (pc)))
+	    (clobber (reg:CCFP FPSR_REG))
+	    (clobber (reg:CCFP FLAGS_REG))
+	    (clobber (match_scratch:HI 5 "=a,a"))]
+	    "X87_FLOAT_MODE_P (GET_MODE (operands[3]))
+	    && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
+	    && GET_MODE (operands[1]) == GET_MODE (operands[3])
+	    && ix86_fp_compare_mode (swap_condition (GET_CODE (operands[0]))) == CCFPmode
+	    && !TARGET_CMOVE"
+    "#")
+
+
+
+
+
 (define_split
   [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
+	(if_then_else (match_operator 0 "ix86_reversed_fp_comparison_operator"
 			[(match_operator 1 "float_operator"
 			   [(match_operand:X87MODEI12 2 "memory_operand" "")])
 			   (match_operand 3 "register_operand" "")])
@@ -13348,7 +13354,7 @@
 ;; %%% Kill this when reload knows how to do it.
 (define_split
   [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
+	(if_then_else (match_operator 0 "ix86_reversed_fp_comparison_operator"
 			[(match_operator 1 "float_operator"
 			   [(match_operand:X87MODEI12 2 "register_operand" "")])
 			   (match_operand 3 "register_operand" "")])
--- gcc-4.5.0/gcc/config/i386/predicates.md.vanilla	2010-12-23 11:53:06.000000000 +0000
+++ gcc-4.5.0/gcc/config/i386/predicates.md	2010-12-23 11:57:49.000000000 +0000
@@ -1083,6 +1083,19 @@
                (match_operand 0 "comparison_operator")
                (match_operand 0 "ix86_trivial_fp_comparison_operator")))
 
+;; Same as above, but for reversed comparison used in fp_jcc_4_387.
+(define_predicate "ix86_reversed_fp_comparison_operator"
+  (match_operand 0 "comparison_operator")
+  {
+    enum rtx_code code = GET_CODE (op);
+      int ret;
+        PUT_CODE (op, swap_condition (code));
+          ret = ix86_fp_comparison_operator (op, mode);
+            PUT_CODE (op, code);
+              return ret;
+             })
+
+
 ;; Nearly general operand, but accept any const_double, since we wish
 ;; to be able to drop them into memory rather than have them get pulled
 ;; into registers.
----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[email protected] with a subject of: unsubscribe t2

Reply via email to