Hello!

Attached patch converts FP compares inside FP jcc combine helpers.

2012-11-22  Uros Bizjak  <ubiz...@gmail.com>

        * config/i386/i386.md (*jcc<mode>_0_i387): Macroize insn
        from *fp_jcc_3_387 using X87MODEF mode iterator.
        (*jcc<mode>_0_r_i387): New.
        (*jccxf_i387): Ditto.
        (*jccxf_r_i387): Ditto.
        (*jcc<mode>_i387): Macroize insn from *fp_jcc_1_387 using
        MODEF mode iterator.
        (*jcc<mode>_r_i387): Macroize insn from *fp_jcc_1r_387 using
        MODEF mode iterator.
        (*jccu<mode>_i387): Macroize insn from *fp_jcc_2_387 using
        X87MODEF mode iterator.
        (*jccu<mode>_r_i387): Macroize insn from *fp_jcc_2r_387 using
        X87MODEF mode iterator.
        (*jcc{,u}<mode>_i387 splitters): Macroize splitters using
        X87MODEF mode iterator.
        (*jcc<X87MODEF:mode>_<SWI24:mode>_i387): Macroize insn
        from *fp_jcc_4_<mode>_387 using X87MODEF mode iterator.
        (*jcc<X87MODEF:mode>_<SWI24:mode>_r_i387): New.
        (*jcc<X87MODEF:mode>_<SWI24:mode>_i387 splitters): Macroize
        splitters using X87MODEF and SWI24 mode iterators.

Tested on x86_64-linux-gnu {,-m32}, committed to mainline SVN.

This is the last patch of my i386.md cleanups.

Uros.
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md (revision 193731)
+++ config/i386/i386.md (working copy)
@@ -10948,89 +10948,110 @@
 ;; Define combination compare-and-branch fp compare instructions to help
 ;; combine.
 
-(define_insn "*fp_jcc_1_387"
+(define_insn "*jcc<mode>_0_i387"
   [(set (pc)
-       (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-                       [(match_operand 1 "register_operand" "f")
-                        (match_operand 2 "nonimmediate_operand" "fm")])
+       (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator"
+                       [(match_operand:X87MODEF 1 "register_operand" "f")
+                        (match_operand:X87MODEF 2 "const0_operand")])
          (label_ref (match_operand 3))
          (pc)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
    (clobber (match_scratch:HI 4 "=a"))]
-  "TARGET_80387
-   && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
-   && GET_MODE (operands[1]) == GET_MODE (operands[2])
-   && SELECT_CC_MODE (GET_CODE (operands[0]),
-                     operands[1], operands[2]) == CCFPmode
-   && !TARGET_CMOVE"
+  "TARGET_80387 && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_1r_387"
+(define_insn "*jcc<mode>_0_r_i387"
   [(set (pc)
-       (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-                       [(match_operand 1 "register_operand" "f")
-                        (match_operand 2 "nonimmediate_operand" "fm")])
+       (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator"
+                       [(match_operand:X87MODEF 1 "register_operand" "f")
+                        (match_operand:X87MODEF 2 "const0_operand")])
          (pc)
          (label_ref (match_operand 3))))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
    (clobber (match_scratch:HI 4 "=a"))]
-  "TARGET_80387
-   && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
-   && GET_MODE (operands[1]) == GET_MODE (operands[2])
-   && SELECT_CC_MODE (GET_CODE (operands[0]),
-                     operands[1], operands[2]) == CCFPmode
-   && !TARGET_CMOVE"
+  "TARGET_80387 && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_2_387"
+(define_insn "*jccxf_i387"
   [(set (pc)
-       (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-                       [(match_operand 1 "register_operand" "f")
-                        (match_operand 2 "register_operand" "f")])
+       (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator"
+                       [(match_operand:XF 1 "register_operand" "f")
+                        (match_operand:XF 2 "register_operand" "f")])
          (label_ref (match_operand 3))
          (pc)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
    (clobber (match_scratch:HI 4 "=a"))]
-  "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
-   && GET_MODE (operands[1]) == GET_MODE (operands[2])
-   && !TARGET_CMOVE"
+  "TARGET_80387 && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_2r_387"
+(define_insn "*jccxf_r_i387"
   [(set (pc)
-       (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-                       [(match_operand 1 "register_operand" "f")
-                        (match_operand 2 "register_operand" "f")])
+       (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator"
+                       [(match_operand:XF 1 "register_operand" "f")
+                        (match_operand:XF 2 "register_operand" "f")])
          (pc)
          (label_ref (match_operand 3))))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
    (clobber (match_scratch:HI 4 "=a"))]
-  "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
-   && GET_MODE (operands[1]) == GET_MODE (operands[2])
-   && !TARGET_CMOVE"
+  "TARGET_80387 && !TARGET_CMOVE"
   "#")
 
-(define_insn "*fp_jcc_3_387"
+(define_insn "*jcc<mode>_i387"
   [(set (pc)
-       (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-                       [(match_operand 1 "register_operand" "f")
-                        (match_operand 2 "const0_operand")])
+       (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator"
+                       [(match_operand:MODEF 1 "register_operand" "f")
+                        (match_operand:MODEF 2 "nonimmediate_operand" "fm")])
          (label_ref (match_operand 3))
          (pc)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
    (clobber (match_scratch:HI 4 "=a"))]
-  "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
-   && GET_MODE (operands[1]) == GET_MODE (operands[2])
-   && SELECT_CC_MODE (GET_CODE (operands[0]),
-                     operands[1], operands[2]) == CCFPmode
-   && !TARGET_CMOVE"
+  "TARGET_80387 && !TARGET_CMOVE"
   "#")
 
+(define_insn "*jcc<mode>_r_i387"
+  [(set (pc)
+       (if_then_else (match_operator:CCFP 0 "ix86_fp_comparison_operator"
+                       [(match_operand:MODEF 1 "register_operand" "f")
+                        (match_operand:MODEF 2 "nonimmediate_operand" "fm")])
+         (pc)
+         (label_ref (match_operand 3))))
+   (clobber (reg:CCFP FPSR_REG))
+   (clobber (reg:CCFP FLAGS_REG))
+   (clobber (match_scratch:HI 4 "=a"))]
+  "TARGET_80387 && !TARGET_CMOVE"
+  "#")
+
+(define_insn "*jccu<mode>_i387"
+  [(set (pc)
+       (if_then_else (match_operator:CCFPU 0 "ix86_fp_comparison_operator"
+                       [(match_operand:X87MODEF 1 "register_operand" "f")
+                        (match_operand:X87MODEF 2 "register_operand" "f")])
+         (label_ref (match_operand 3))
+         (pc)))
+   (clobber (reg:CCFP FPSR_REG))
+   (clobber (reg:CCFP FLAGS_REG))
+   (clobber (match_scratch:HI 4 "=a"))]
+  "TARGET_80387 && !TARGET_CMOVE"
+  "#")
+
+(define_insn "*jccu<mode>_r_i387"
+  [(set (pc)
+       (if_then_else (match_operator:CCFPU 0 "ix86_fp_comparison_operator"
+                       [(match_operand:X87MODEF 1 "register_operand" "f")
+                        (match_operand:X87MODEF 2 "register_operand" "f")])
+         (pc)
+         (label_ref (match_operand 3))))
+   (clobber (reg:CCFP FPSR_REG))
+   (clobber (reg:CCFP FLAGS_REG))
+   (clobber (match_scratch:HI 4 "=a"))]
+  "TARGET_80387 && !TARGET_CMOVE"
+  "#")
+
 (define_split
   [(set (pc)
        (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
@@ -11040,7 +11061,8 @@
          (match_operand 4)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))]
-  "reload_completed"
+  "TARGET_80387 && !TARGET_CMOVE
+   && reload_completed"
   [(const_int 0)]
 {
   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
@@ -11051,14 +11073,15 @@
 (define_split
   [(set (pc)
        (if_then_else (match_operator 0 "ix86_fp_comparison_operator"
-                       [(match_operand 1 "register_operand")
-                        (match_operand 2 "general_operand")])
+                       [(match_operand:X87MODEF 1 "register_operand")
+                        (match_operand:X87MODEF 2 "general_operand")])
          (match_operand 3)
          (match_operand 4)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
-   (clobber (match_scratch:HI 5 "=a"))]
-  "reload_completed"
+   (clobber (match_scratch:HI 5))]
+  "TARGET_80387 && !TARGET_CMOVE
+   && reload_completed"
   [(const_int 0)]
 {
   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
@@ -11066,49 +11089,63 @@
   DONE;
 })
 
-;; The order of operands in *fp_jcc_4_387 is forced by combine in
+;; The order of operands in *jcc<fp>_<int>_i387 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"
+(define_insn "*jcc<X87MODEF:mode>_<SWI24:mode>_i387"
   [(set (pc)
        (if_then_else
-         (match_operator 0 "ix86_swapped_fp_comparison_operator"
-           [(match_operator 1 "float_operator"
+         (match_operator:CCFP 0 "ix86_swapped_fp_comparison_operator"
+           [(match_operator:X87MODEF 1 "float_operator"
              [(match_operand:SWI24 2 "nonimmediate_operand" "m,?r")])
-            (match_operand 3 "register_operand" "f,f")])
+            (match_operand:X87MODEF 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"
+  "TARGET_80387 && !TARGET_CMOVE
+   && (TARGET_USE_<SWI24:MODE>MODE_FIOP
+       || optimize_function_for_size_p (cfun))"
   "#")
 
+(define_insn "*jcc<X87MODEF:mode>_<SWI24:mode>_r_i387"
+  [(set (pc)
+       (if_then_else
+         (match_operator:CCFP 0 "ix86_swapped_fp_comparison_operator"
+           [(match_operator:X87MODEF 1 "float_operator"
+             [(match_operand:SWI24 2 "nonimmediate_operand" "m,?r")])
+            (match_operand:X87MODEF 3 "register_operand" "f,f")])
+         (pc)
+         (label_ref (match_operand 4))))
+   (clobber (reg:CCFP FPSR_REG))
+   (clobber (reg:CCFP FLAGS_REG))
+   (clobber (match_scratch:HI 5 "=a,a"))]
+  "TARGET_80387 && !TARGET_CMOVE
+   && (TARGET_USE_<SWI24:MODE>MODE_FIOP
+       || optimize_function_for_size_p (cfun))"
+  "#")
+
 (define_split
   [(set (pc)
        (if_then_else
-         (match_operator 0 "ix86_swapped_fp_comparison_operator"
-           [(match_operator 1 "float_operator"
+         (match_operator:CCFP 0 "ix86_swapped_fp_comparison_operator"
+           [(match_operator:X87MODEF 1 "float_operator"
              [(match_operand:SWI24 2 "memory_operand")])
-            (match_operand 3 "register_operand")])
+            (match_operand:X87MODEF 3 "register_operand")])
          (match_operand 4)
          (match_operand 5)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
-   (clobber (match_scratch:HI 6 "=a"))]
-  "reload_completed"
+   (clobber (match_scratch:HI 6))]
+  "TARGET_80387 && !TARGET_CMOVE
+   && reload_completed"
   [(const_int 0)]
 {
-  operands[7] = gen_rtx_FLOAT (GET_MODE (operands[1]), operands[2]);
-
-  ix86_split_fp_branch (swap_condition (GET_CODE (operands[0])),
-                       operands[3], operands[7],
+  ix86_split_fp_branch (swap_condition (GET_CODE (operands[0])), operands[3],
+                       gen_rtx_FLOAT (GET_MODE (operands[1]), operands[2]),
                        operands[4], operands[5], operands[6], NULL_RTX);
   DONE;
 })
@@ -11117,23 +11154,23 @@
 (define_split
   [(set (pc)
        (if_then_else
-         (match_operator 0 "ix86_swapped_fp_comparison_operator"
-           [(match_operator 1 "float_operator"
+         (match_operator:CCFP 0 "ix86_swapped_fp_comparison_operator"
+           [(match_operator:X87MODEF 1 "float_operator"
              [(match_operand:SWI24 2 "register_operand")])
-            (match_operand 3 "register_operand")])
+            (match_operand:X87MODEF 3 "register_operand")])
          (match_operand 4)
          (match_operand 5)))
    (clobber (reg:CCFP FPSR_REG))
    (clobber (reg:CCFP FLAGS_REG))
-   (clobber (match_scratch:HI 6 "=a"))]
-  "reload_completed"
+   (clobber (match_scratch:HI 6))]
+  "TARGET_80387 && !TARGET_CMOVE
+   && reload_completed"
   [(const_int 0)]
 {
-  operands[7] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
-  operands[7] = gen_rtx_FLOAT (GET_MODE (operands[1]), operands[7]);
+  rtx tmp = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
 
-  ix86_split_fp_branch (swap_condition (GET_CODE (operands[0])),
-                       operands[3], operands[7],
+  ix86_split_fp_branch (swap_condition (GET_CODE (operands[0])), operands[3],
+                       gen_rtx_FLOAT (GET_MODE (operands[1]), tmp),
                        operands[4], operands[5], operands[6], operands[2]);
   DONE;
 })
Index: config/i386/predicates.md
===================================================================
--- config/i386/predicates.md   (revision 193728)
+++ config/i386/predicates.md   (working copy)
@@ -1110,7 +1110,7 @@
                (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.
+;; Same as above, but for swapped comparison used in *jcc<fp>_<int>_i387.
 (define_predicate "ix86_swapped_fp_comparison_operator"
   (match_operand 0 "comparison_operator")
 {

Reply via email to