From 9220456e93ac46a3151be4add6042a2ee44a9610 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Thu, 22 Nov 2012 17:59:18 +0100 Subject: [PATCH] i386.md (FPCMP): New mode iterator. * config/i386/i386.md (FPCMP): New mode iterator. (unord): New mode attribute. (*cmp_0_i387): Macroize insn from *cmpfp_0 using X87MODEF mode iterator. (*cmp_0_cc_i387): Macroize insn from *cmpfp_0_cc using X87MODEF mode iterator. (*cmpxf_i387): Rename from *cmpfp_xf. (*cmpxf_cc_i387): Rename from *cmpfp_xf_cc. (*cmp_i387): Rename from *cmpfp_. (*cmp_cc_i387): Rename from *cmpfp__cc. (*cmpu_i387): Macroize insn from *cmpfp_u using X87MODEF mode iterator. (*cmpu_cc_i387): Macroize insn from *cmpfp_u_cc using X87MODEF mode iterator. (*cmp__i387): Macroize_insn from *cmpfp_ using X87MODEF mode iterator. (*cmp__cc_i387): Macroize_insn from *cmpfp__cc using X87MODEF mode iterator. (*cmpi_mixed): Macroize insn from *cmpfp_i{,u}_mixed using FPCMP and MODEF mode iterators. (*cmpi_mixed): Macroize insn from *cmpfp_i{,u}_sse using FPCMP and MODEF mode iterators. (*cmpi_i387): Macroize insn from *cmpfp_i{,u}_387 using FPCMP and X87MODEF mode iterators. From-SVN: r193731 --- gcc/ChangeLog | 27 +++++ gcc/config/i386/i386.md | 254 ++++++++++++++---------------------------------- 2 files changed, 98 insertions(+), 183 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d0ede90..f76c873 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2012-11-22 Uros Bizjak + + * config/i386/i386.md (FPCMP): New mode iterator. + (unord): New mode attribute. + (*cmp_0_i387): Macroize insn from *cmpfp_0 + using X87MODEF mode iterator. + (*cmp_0_cc_i387): Macroize insn from *cmpfp_0_cc using + X87MODEF mode iterator. + (*cmpxf_i387): Rename from *cmpfp_xf. + (*cmpxf_cc_i387): Rename from *cmpfp_xf_cc. + (*cmp_i387): Rename from *cmpfp_. + (*cmp_cc_i387): Rename from *cmpfp__cc. + (*cmpu_i387): Macroize insn from *cmpfp_u using X87MODEF + mode iterator. + (*cmpu_cc_i387): Macroize insn from *cmpfp_u_cc using X87MODEF + mode iterator. + (*cmp__i387): Macroize_insn from + *cmpfp_ using X87MODEF mode iterator. + (*cmp__cc_i387): Macroize_insn from + *cmpfp__cc using X87MODEF mode iterator. + (*cmpi_mixed): Macroize insn from + *cmpfp_i{,u}_mixed using FPCMP and MODEF mode iterators. + (*cmpi_mixed): Macroize insn from + *cmpfp_i{,u}_sse using FPCMP and MODEF mode iterators. + (*cmpi_i387): Macroize insn from + *cmpfp_i{,u}_387 using FPCMP and X87MODEF mode iterators. + 2012-11-22 Ian Bolton * config/aarch64/aarch64.md (bswaphi2): New pattern. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index b0821c0..69e7396 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1237,35 +1237,26 @@ ;; We may not use "#" to split and emit these, since the REG_DEAD notes ;; used to manage the reg stack popping would not be preserved. -(define_insn "*cmpfp_0" +(define_insn "*cmp_0_i387" [(set (match_operand:HI 0 "register_operand" "=a") (unspec:HI [(compare:CCFP - (match_operand 1 "register_operand" "f") - (match_operand 2 "const0_operand"))] + (match_operand:X87MODEF 1 "register_operand" "f") + (match_operand:X87MODEF 2 "const0_operand"))] UNSPEC_FNSTSW))] - "X87_FLOAT_MODE_P (GET_MODE (operands[1])) - && GET_MODE (operands[1]) == GET_MODE (operands[2])" + "TARGET_80387" "* return output_fp_compare (insn, operands, false, false);" [(set_attr "type" "multi") (set_attr "unit" "i387") - (set (attr "mode") - (cond [(match_operand:SF 1) - (const_string "SF") - (match_operand:DF 1) - (const_string "DF") - ] - (const_string "XF")))]) + (set_attr "mode" "")]) -(define_insn_and_split "*cmpfp_0_cc" +(define_insn_and_split "*cmp_0_cc_i387" [(set (reg:CCFP FLAGS_REG) (compare:CCFP - (match_operand 1 "register_operand" "f") - (match_operand 2 "const0_operand"))) + (match_operand:X87MODEF 1 "register_operand" "f") + (match_operand:X87MODEF 2 "const0_operand"))) (clobber (match_operand:HI 0 "register_operand" "=a"))] - "X87_FLOAT_MODE_P (GET_MODE (operands[1])) - && TARGET_SAHF && !TARGET_CMOVE - && GET_MODE (operands[1]) == GET_MODE (operands[2])" + "TARGET_80387 && TARGET_SAHF && !TARGET_CMOVE" "#" "&& reload_completed" [(set (match_dup 0) @@ -1277,15 +1268,9 @@ "" [(set_attr "type" "multi") (set_attr "unit" "i387") - (set (attr "mode") - (cond [(match_operand:SF 1) - (const_string "SF") - (match_operand:DF 1) - (const_string "DF") - ] - (const_string "XF")))]) + (set_attr "mode" "")]) -(define_insn "*cmpfp_xf" +(define_insn "*cmpxf_i387" [(set (match_operand:HI 0 "register_operand" "=a") (unspec:HI [(compare:CCFP @@ -1298,14 +1283,13 @@ (set_attr "unit" "i387") (set_attr "mode" "XF")]) -(define_insn_and_split "*cmpfp_xf_cc" +(define_insn_and_split "*cmpxf_cc_i387" [(set (reg:CCFP FLAGS_REG) (compare:CCFP (match_operand:XF 1 "register_operand" "f") (match_operand:XF 2 "register_operand" "f"))) (clobber (match_operand:HI 0 "register_operand" "=a"))] - "TARGET_80387 - && TARGET_SAHF && !TARGET_CMOVE" + "TARGET_80387 && TARGET_SAHF && !TARGET_CMOVE" "#" "&& reload_completed" [(set (match_dup 0) @@ -1319,7 +1303,7 @@ (set_attr "unit" "i387") (set_attr "mode" "XF")]) -(define_insn "*cmpfp_" +(define_insn "*cmp_i387" [(set (match_operand:HI 0 "register_operand" "=a") (unspec:HI [(compare:CCFP @@ -1332,14 +1316,13 @@ (set_attr "unit" "i387") (set_attr "mode" "")]) -(define_insn_and_split "*cmpfp__cc" +(define_insn_and_split "*cmp_cc_i387" [(set (reg:CCFP FLAGS_REG) (compare:CCFP (match_operand:MODEF 1 "register_operand" "f") (match_operand:MODEF 2 "nonimmediate_operand" "fm"))) (clobber (match_operand:HI 0 "register_operand" "=a"))] - "TARGET_80387 - && TARGET_SAHF && !TARGET_CMOVE" + "TARGET_80387 && TARGET_SAHF && !TARGET_CMOVE" "#" "&& reload_completed" [(set (match_dup 0) @@ -1353,35 +1336,26 @@ (set_attr "unit" "i387") (set_attr "mode" "")]) -(define_insn "*cmpfp_u" +(define_insn "*cmpu_i387" [(set (match_operand:HI 0 "register_operand" "=a") (unspec:HI [(compare:CCFPU - (match_operand 1 "register_operand" "f") - (match_operand 2 "register_operand" "f"))] + (match_operand:X87MODEF 1 "register_operand" "f") + (match_operand:X87MODEF 2 "register_operand" "f"))] UNSPEC_FNSTSW))] - "X87_FLOAT_MODE_P (GET_MODE (operands[1])) - && GET_MODE (operands[1]) == GET_MODE (operands[2])" + "TARGET_80387" "* return output_fp_compare (insn, operands, false, true);" [(set_attr "type" "multi") (set_attr "unit" "i387") - (set (attr "mode") - (cond [(match_operand:SF 1) - (const_string "SF") - (match_operand:DF 1) - (const_string "DF") - ] - (const_string "XF")))]) + (set_attr "mode" "")]) -(define_insn_and_split "*cmpfp_u_cc" +(define_insn_and_split "*cmpu_cc_i387" [(set (reg:CCFPU FLAGS_REG) (compare:CCFPU - (match_operand 1 "register_operand" "f") - (match_operand 2 "register_operand" "f"))) + (match_operand:X87MODEF 1 "register_operand" "f") + (match_operand:X87MODEF 2 "register_operand" "f"))) (clobber (match_operand:HI 0 "register_operand" "=a"))] - "X87_FLOAT_MODE_P (GET_MODE (operands[1])) - && TARGET_SAHF && !TARGET_CMOVE - && GET_MODE (operands[1]) == GET_MODE (operands[2])" + "TARGET_80387 && TARGET_SAHF && !TARGET_CMOVE" "#" "&& reload_completed" [(set (match_dup 0) @@ -1393,42 +1367,35 @@ "" [(set_attr "type" "multi") (set_attr "unit" "i387") - (set (attr "mode") - (cond [(match_operand:SF 1) - (const_string "SF") - (match_operand:DF 1) - (const_string "DF") - ] - (const_string "XF")))]) + (set_attr "mode" "")]) -(define_insn "*cmpfp_" +(define_insn "*cmp__i387" [(set (match_operand:HI 0 "register_operand" "=a") (unspec:HI [(compare:CCFP - (match_operand 1 "register_operand" "f") - (match_operator 3 "float_operator" + (match_operand:X87MODEF 1 "register_operand" "f") + (match_operator:X87MODEF 3 "float_operator" [(match_operand:SWI24 2 "memory_operand" "m")]))] UNSPEC_FNSTSW))] - "X87_FLOAT_MODE_P (GET_MODE (operands[1])) - && (TARGET_USE_MODE_FIOP || optimize_function_for_size_p (cfun)) - && (GET_MODE (operands [3]) == GET_MODE (operands[1]))" + "TARGET_80387 + && (TARGET_USE_MODE_FIOP + || optimize_function_for_size_p (cfun))" "* return output_fp_compare (insn, operands, false, false);" [(set_attr "type" "multi") (set_attr "unit" "i387") (set_attr "fp_int_src" "true") - (set_attr "mode" "")]) + (set_attr "mode" "")]) -(define_insn_and_split "*cmpfp__cc" +(define_insn_and_split "*cmp__cc_i387" [(set (reg:CCFP FLAGS_REG) (compare:CCFP - (match_operand 1 "register_operand" "f") - (match_operator 3 "float_operator" + (match_operand:X87MODEF 1 "register_operand" "f") + (match_operator:X87MODEF 3 "float_operator" [(match_operand:SWI24 2 "memory_operand" "m")]))) (clobber (match_operand:HI 0 "register_operand" "=a"))] - "X87_FLOAT_MODE_P (GET_MODE (operands[1])) - && TARGET_SAHF && !TARGET_CMOVE - && (TARGET_USE_MODE_FIOP || optimize_function_for_size_p (cfun)) - && (GET_MODE (operands [3]) == GET_MODE (operands[1]))" + "TARGET_80387 && TARGET_SAHF && !TARGET_CMOVE + && (TARGET_USE_MODE_FIOP + || optimize_function_for_size_p (cfun))" "#" "&& reload_completed" [(set (match_dup 0) @@ -1443,7 +1410,7 @@ [(set_attr "type" "multi") (set_attr "unit" "i387") (set_attr "fp_int_src" "true") - (set_attr "mode" "")]) + (set_attr "mode" "")]) ;; FP compares, step 2 ;; Move the fpsw to ax. @@ -1483,93 +1450,22 @@ ;; Pentium Pro can do steps 1 through 3 in one go. ;; comi*, ucomi*, fcomi*, ficomi*, fucomi* ;; (these i387 instructions set flags directly) -(define_insn "*cmpfp_i_mixed" - [(set (reg:CCFP FLAGS_REG) - (compare:CCFP (match_operand 0 "register_operand" "f,x") - (match_operand 1 "nonimmediate_operand" "f,xm")))] - "TARGET_MIX_SSE_I387 - && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[1])" - "* return output_fp_compare (insn, operands, true, false);" - [(set_attr "type" "fcmp,ssecomi") - (set_attr "prefix" "orig,maybe_vex") - (set (attr "mode") - (if_then_else (match_operand:SF 1) - (const_string "SF") - (const_string "DF"))) - (set (attr "prefix_rep") - (if_then_else (eq_attr "type" "ssecomi") - (const_string "0") - (const_string "*"))) - (set (attr "prefix_data16") - (cond [(eq_attr "type" "fcmp") - (const_string "*") - (eq_attr "mode" "DF") - (const_string "1") - ] - (const_string "0"))) - (set_attr "athlon_decode" "vector") - (set_attr "amdfam10_decode" "direct") - (set_attr "bdver1_decode" "double")]) - -(define_insn "*cmpfp_i_sse" - [(set (reg:CCFP FLAGS_REG) - (compare:CCFP (match_operand 0 "register_operand" "x") - (match_operand 1 "nonimmediate_operand" "xm")))] - "TARGET_SSE_MATH - && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[1])" - "* return output_fp_compare (insn, operands, true, false);" - [(set_attr "type" "ssecomi") - (set_attr "prefix" "maybe_vex") - (set (attr "mode") - (if_then_else (match_operand:SF 1) - (const_string "SF") - (const_string "DF"))) - (set_attr "prefix_rep" "0") - (set (attr "prefix_data16") - (if_then_else (eq_attr "mode" "DF") - (const_string "1") - (const_string "0"))) - (set_attr "athlon_decode" "vector") - (set_attr "amdfam10_decode" "direct") - (set_attr "bdver1_decode" "double")]) -(define_insn "*cmpfp_i_i387" - [(set (reg:CCFP FLAGS_REG) - (compare:CCFP (match_operand 0 "register_operand" "f") - (match_operand 1 "register_operand" "f")))] - "X87_FLOAT_MODE_P (GET_MODE (operands[0])) - && TARGET_CMOVE - && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH) - && GET_MODE (operands[0]) == GET_MODE (operands[1])" - "* return output_fp_compare (insn, operands, true, false);" - [(set_attr "type" "fcmp") - (set (attr "mode") - (cond [(match_operand:SF 1) - (const_string "SF") - (match_operand:DF 1) - (const_string "DF") - ] - (const_string "XF"))) - (set_attr "athlon_decode" "vector") - (set_attr "amdfam10_decode" "direct") - (set_attr "bdver1_decode" "double")]) +(define_mode_iterator FPCMP [CCFP CCFPU]) +(define_mode_attr unord [(CCFP "") (CCFPU "u")]) -(define_insn "*cmpfp_iu_mixed" - [(set (reg:CCFPU FLAGS_REG) - (compare:CCFPU (match_operand 0 "register_operand" "f,x") - (match_operand 1 "nonimmediate_operand" "f,xm")))] +(define_insn "*cmpi_mixed" + [(set (reg:FPCMP FLAGS_REG) + (compare:FPCMP + (match_operand:MODEF 0 "register_operand" "f,x") + (match_operand:MODEF 1 "nonimmediate_operand" "f,xm")))] "TARGET_MIX_SSE_I387 - && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[1])" - "* return output_fp_compare (insn, operands, true, true);" + && SSE_FLOAT_MODE_P (mode)" + "* return output_fp_compare (insn, operands, true, + mode == CCFPUmode);" [(set_attr "type" "fcmp,ssecomi") (set_attr "prefix" "orig,maybe_vex") - (set (attr "mode") - (if_then_else (match_operand:SF 1) - (const_string "SF") - (const_string "DF"))) + (set_attr "mode" "") (set (attr "prefix_rep") (if_then_else (eq_attr "type" "ssecomi") (const_string "0") @@ -1585,20 +1481,18 @@ (set_attr "amdfam10_decode" "direct") (set_attr "bdver1_decode" "double")]) -(define_insn "*cmpfp_iu_sse" - [(set (reg:CCFPU FLAGS_REG) - (compare:CCFPU (match_operand 0 "register_operand" "x") - (match_operand 1 "nonimmediate_operand" "xm")))] +(define_insn "*cmpi_sse" + [(set (reg:FPCMP FLAGS_REG) + (compare:FPCMP + (match_operand:MODEF 0 "register_operand" "x") + (match_operand:MODEF 1 "nonimmediate_operand" "xm")))] "TARGET_SSE_MATH - && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) - && GET_MODE (operands[0]) == GET_MODE (operands[1])" - "* return output_fp_compare (insn, operands, true, true);" + && SSE_FLOAT_MODE_P (mode)" + "* return output_fp_compare (insn, operands, true, + mode == CCFPUmode);" [(set_attr "type" "ssecomi") (set_attr "prefix" "maybe_vex") - (set (attr "mode") - (if_then_else (match_operand:SF 1) - (const_string "SF") - (const_string "DF"))) + (set_attr "mode" "") (set_attr "prefix_rep" "0") (set (attr "prefix_data16") (if_then_else (eq_attr "mode" "DF") @@ -1608,26 +1502,20 @@ (set_attr "amdfam10_decode" "direct") (set_attr "bdver1_decode" "double")]) -(define_insn "*cmpfp_iu_387" - [(set (reg:CCFPU FLAGS_REG) - (compare:CCFPU (match_operand 0 "register_operand" "f") - (match_operand 1 "register_operand" "f")))] - "X87_FLOAT_MODE_P (GET_MODE (operands[0])) - && TARGET_CMOVE - && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH) - && GET_MODE (operands[0]) == GET_MODE (operands[1])" - "* return output_fp_compare (insn, operands, true, true);" +(define_insn "*cmpi_i387" + [(set (reg:FPCMP FLAGS_REG) + (compare:FPCMP + (match_operand:X87MODEF 0 "register_operand" "f") + (match_operand:X87MODEF 1 "register_operand" "f")))] + "TARGET_80387 && TARGET_CMOVE + && !(SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH)" + "* return output_fp_compare (insn, operands, true, + mode == CCFPUmode);" [(set_attr "type" "fcmp") - (set (attr "mode") - (cond [(match_operand:SF 1) - (const_string "SF") - (match_operand:DF 1) - (const_string "DF") - ] - (const_string "XF"))) + (set_attr "mode" "") (set_attr "athlon_decode" "vector") (set_attr "amdfam10_decode" "direct") - (set_attr "bdver1_decode" "direct")]) + (set_attr "bdver1_decode" "double")]) ;; Push/pop instructions. -- 2.7.4