diff mbox

[i386] : Fix PR target/44546, ICE in extract_insn, at recog.c:2103 with -ffast-math -Os

Message ID 1277069783.10276.9.camel@localhost
State New
Headers show

Commit Message

Uros Bizjak June 20, 2010, 9:36 p.m. UTC
Hello!

*fp_jcc_8<mode>_387 splits with swapped operands and comparison
operator.  We should use different predicate that looks at swapped
condition.  The patch also renames fp_jcc patterns.

2010-06-20  Uros Bizjak  <ubizjak@gmail.com>

	PR target/44546
	* config/i386/predicates.md (ix86_swapped_fp_comparsion_operator):
	New predicate.
	* config/i386/i386.md (*fp_jcc_8<mode>_387): Use
	ix86_swapped_fp_comparsion_operator instead of
	ix86_fp_comparison_operator.

	(*fp_jcc_1_387): Rename from *fp_jcc_3_387.
	(*fp_jcc_1r_387): Rename from *fp_jcc_4_387.
	(*fp_jcc_2_387): Rename from *fp_jcc_5_387.
	(*fp_jcc_2r_387): Rename from *fp_jcc_6_387.
	(*fp_jcc_3_387): Rename from *fp_jcc_7_387.
	(*fp_jcc_4_<mode>_387): Rename from *fp_jcc_8<mode>_387.

testsuite/ChangeLog:

2010-06-20  Uros Bizjak  <ubizjak@gmail.com>

	PR target/44546
	* gcc.target/i386/pr44546.c: New test.

Patch was bootstrapped and tested on x86_64-pc-linux-gnu.  Patch is
committed to mainline, will be committed to 4.5 branch.

Uros.

Comments

Paolo Bonzini June 21, 2010, 8:43 a.m. UTC | #1
> *fp_jcc_8<mode>_387 splits with swapped operands and comparison
> operator.  We should use different predicate that looks at swapped
> condition.

Thanks, looks fine!

Paolo
diff mbox

Patch

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 161046)
+++ config/i386/i386.md	(working copy)
@@ -11086,7 +11086,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")
@@ -11104,7 +11104,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")
@@ -11122,7 +11122,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")
@@ -11137,7 +11137,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")
@@ -11152,7 +11152,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")
@@ -11169,29 +11169,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)
 	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
@@ -11227,12 +11204,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_swapped_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"
-			[(match_operator 1 "float_operator"
-			   [(match_operand:X87MODEI12 2 "memory_operand" "")])
-			   (match_operand 3 "register_operand" "")])
+	(if_then_else
+	  (match_operator 0 "ix86_swapped_fp_comparison_operator"
+	    [(match_operator 1 "float_operator"
+	      [(match_operand:X87MODEI12 2 "memory_operand" "")])
+	     (match_operand 3 "register_operand" "")])
 	  (match_operand 4 "" "")
 	  (match_operand 5 "" "")))
    (clobber (reg:CCFP FPSR_REG))
@@ -11252,10 +11254,11 @@ 
 ;; %%% Kill this when reload knows how to do it.
 (define_split
   [(set (pc)
-	(if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-			[(match_operator 1 "float_operator"
-			   [(match_operand:X87MODEI12 2 "register_operand" "")])
-			   (match_operand 3 "register_operand" "")])
+	(if_then_else
+	  (match_operator 0 "ix86_swapped_fp_comparison_operator"
+	    [(match_operator 1 "float_operator"
+	      [(match_operand:X87MODEI12 2 "register_operand" "")])
+	     (match_operand 3 "register_operand" "")])
 	  (match_operand 4 "" "")
 	  (match_operand 5 "" "")))
    (clobber (reg:CCFP FPSR_REG))
Index: config/i386/predicates.md
===================================================================
--- config/i386/predicates.md	(revision 161046)
+++ config/i386/predicates.md	(working copy)
@@ -1053,6 +1053,19 @@ 
                (match_operand 0 "comparison_operator")
                (match_operand 0 "ix86_trivial_fp_comparison_operator")))
 
+;; Same as above, but for swapped comparison used in fp_jcc_4_387.
+(define_predicate "ix86_swapped_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.
Index: testsuite/gcc.target/i386/pr44546.c
===================================================================
--- testsuite/gcc.target/i386/pr44546.c	(revision 0)
+++ testsuite/gcc.target/i386/pr44546.c	(revision 0)
@@ -0,0 +1,22 @@ 
+/* { dg-do compile } */
+/* { dg-options "-Os -ffast-math -mfpmath=387" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef struct
+{
+  float *ewgts;
+} vtx_data;
+
+extern void *zmalloc (size_t);
+extern int whatever (vtx_data *);
+
+float *
+compute_apsp_artifical_weights_packed (vtx_data * graph, int n)
+{
+  float *weights;
+
+  weights = (float *) zmalloc (n * sizeof (float));
+  weights[n] =
+    whatever (graph) > graph[n].ewgts[n] ?
+    whatever (graph) : graph[n].ewgts[n];
+}