Commit 45c8c47f by Uros Bizjak Committed by Uros Bizjak

i386.c (ix86_prepare_fp_compare_args): Do not force operand 0.0 into register in XFmode.

        * config/i386/i386.c (ix86_prepare_fp_compare_args): Do not
        force operand 0.0 into register in XFmode. Also do not force
        operand 0.0 into register if !TARGET_CMOVE.

        * config/i386/i386.md (*cmpfp_0): Delete. Remove comment.
        (*cmpfp_0_sf, cmpfp_0_df, cmpfp_0_xf): New patterns to
        implement ftst x87 instruction.
        (*fp_jcc_7): New insn pattern. Change corresponding split
        pattern to handle "general_operand" instead of
        "nonimmediate_operand".

----------------------------------------------------------------------

From-SVN: r87173
parent 70d5fb1c
2004-09-08 Uros Bizjak <uros@kss-loka.si>
* config/i386/i386.c (ix86_prepare_fp_compare_args): Do not
force operand 0.0 into register in XFmode. Also do not force
operand 0.0 into register if !TARGET_CMOVE.
* config/i386/i386.md (*cmpfp_0): Delete. Remove comment.
(*cmpfp_0_sf, cmpfp_0_df, cmpfp_0_xf): New patterns to
implement ftst x87 instruction.
(*fp_jcc_7): New insn pattern. Change corresponding split
pattern to handle "general_operand" instead of
"nonimmediate_operand".
2004-09-08 Ben Elliston <bje@au.ibm.com> 2004-09-08 Ben Elliston <bje@au.ibm.com>
* doc/rtl.texi (Insns): Document NOTE_INSN_FUNCTION_BEG. * doc/rtl.texi (Insns): Document NOTE_INSN_FUNCTION_BEG.
......
...@@ -7941,12 +7941,15 @@ ix86_prepare_fp_compare_args (enum rtx_code code, rtx *pop0, rtx *pop1) ...@@ -7941,12 +7941,15 @@ ix86_prepare_fp_compare_args (enum rtx_code code, rtx *pop0, rtx *pop1)
int is_sse = SSE_REG_P (op0) | SSE_REG_P (op1); int is_sse = SSE_REG_P (op0) | SSE_REG_P (op1);
/* All of the unordered compare instructions only work on registers. /* All of the unordered compare instructions only work on registers.
The same is true of the XFmode compare instructions. The same is The same is true of the fcomi compare instructions. The same is
true of the fcomi compare instructions. */ true of the XFmode compare instructions if not comparing with
zero (ftst insn is used in this case). */
if (!is_sse if (!is_sse
&& (fpcmp_mode == CCFPUmode && (fpcmp_mode == CCFPUmode
|| op_mode == XFmode || (op_mode == XFmode
&& ! (standard_80387_constant_p (op0) == 1
|| standard_80387_constant_p (op1) == 1))
|| ix86_use_fcomi_compare (code))) || ix86_use_fcomi_compare (code)))
{ {
op0 = force_reg (op_mode, op0); op0 = force_reg (op_mode, op0);
...@@ -7973,10 +7976,16 @@ ix86_prepare_fp_compare_args (enum rtx_code code, rtx *pop0, rtx *pop1) ...@@ -7973,10 +7976,16 @@ ix86_prepare_fp_compare_args (enum rtx_code code, rtx *pop0, rtx *pop1)
if (CONSTANT_P (op1)) if (CONSTANT_P (op1))
{ {
if (standard_80387_constant_p (op1)) int tmp = standard_80387_constant_p (op1);
op1 = force_reg (op_mode, op1); if (tmp == 0)
else
op1 = validize_mem (force_const_mem (op_mode, op1)); op1 = validize_mem (force_const_mem (op_mode, op1));
else if (tmp == 1)
{
if (TARGET_CMOVE)
op1 = force_reg (op_mode, op1);
}
else
op1 = force_reg (op_mode, op1);
} }
} }
......
...@@ -797,41 +797,65 @@ ...@@ -797,41 +797,65 @@
;; CCFPmode compare with exceptions ;; CCFPmode compare with exceptions
;; CCFPUmode compare with no exceptions ;; CCFPUmode compare with no exceptions
;; %%% It is an unfortunate fact that ftst has no non-popping variant, (define_insn "*cmpfp_0_sf"
;; and that fp moves clobber the condition codes, and that there is [(set (match_operand:HI 0 "register_operand" "=a")
;; currently no way to describe this fact to reg-stack. So there are (unspec:HI
;; no splitters yet for this. [(compare:CCFP
(match_operand:SF 1 "register_operand" "f")
;; %%% YIKES! This scheme does not retain a strong connection between (match_operand:SF 2 "const0_operand" "X"))]
;; the real compare and the ultimate cc0 user, so CC_REVERSE does not UNSPEC_FNSTSW))]
;; work! Only allow tos/mem with tos in op 0. "TARGET_80387"
;; {
;; Hmm, of course, this is what the actual _hardware_ does. Perhaps if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
;; things aren't as bad as they sound... {
output_asm_insn ("ftst\;fnstsw\t%0", operands);
return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1";
}
else
return "ftst\;fnstsw\t%0";
}
[(set_attr "type" "multi")
(set_attr "mode" "SF")])
(define_insn "*cmpfp_0" (define_insn "*cmpfp_0_df"
[(set (match_operand:HI 0 "register_operand" "=a") [(set (match_operand:HI 0 "register_operand" "=a")
(unspec:HI (unspec:HI
[(compare:CCFP (match_operand 1 "register_operand" "f") [(compare:CCFP
(match_operand 2 "const0_operand" "X"))] (match_operand:DF 1 "register_operand" "f")
UNSPEC_FNSTSW))] (match_operand:DF 2 "const0_operand" "X"))]
"TARGET_80387 UNSPEC_FNSTSW))]
&& FLOAT_MODE_P (GET_MODE (operands[1])) "TARGET_80387"
&& GET_MODE (operands[1]) == GET_MODE (operands[2])"
{ {
if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
return "ftst\;fnstsw\t%0\;fstp\t%y0"; {
output_asm_insn ("ftst\;fnstsw\t%0", operands);
return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1";
}
else else
return "ftst\;fnstsw\t%0"; return "ftst\;fnstsw\t%0";
} }
[(set_attr "type" "multi") [(set_attr "type" "multi")
(set (attr "mode") (set_attr "mode" "DF")])
(cond [(match_operand:SF 1 "" "")
(const_string "SF") (define_insn "*cmpfp_0_xf"
(match_operand:DF 1 "" "") [(set (match_operand:HI 0 "register_operand" "=a")
(const_string "DF") (unspec:HI
] [(compare:CCFP
(const_string "XF")))]) (match_operand:XF 1 "register_operand" "f")
(match_operand:XF 2 "const0_operand" "X"))]
UNSPEC_FNSTSW))]
"TARGET_80387"
{
if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
{
output_asm_insn ("ftst\;fnstsw\t%0", operands);
return TARGET_USE_FFREEP ? "ffreep\t%y1" : "fstp\t%y1";
}
else
return "ftst\;fnstsw\t%0";
}
[(set_attr "type" "multi")
(set_attr "mode" "XF")])
;; We may not use "#" to split and emit these, since the REG_DEAD notes ;; 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. ;; used to manage the reg stack popping would not be preserved.
...@@ -13322,6 +13346,25 @@ ...@@ -13322,6 +13346,25 @@
&& ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
"#") "#")
(define_insn "*fp_jcc_7"
[(set (pc)
(if_then_else (match_operator 0 "comparison_operator"
[(match_operand 1 "register_operand" "f")
(match_operand 2 "const_double_operand" "C")])
(label_ref (match_operand 3 "" ""))
(pc)))
(clobber (reg:CCFP FPSR_REG))
(clobber (reg:CCFP FLAGS_REG))
(clobber (match_scratch:HI 4 "=a"))]
"TARGET_80387
&& FLOAT_MODE_P (GET_MODE (operands[1]))
&& operands[2] == CONST0_RTX (GET_MODE (operands[1]))
&& !ix86_use_fcomi_compare (GET_CODE (operands[0]))
&& SELECT_CC_MODE (GET_CODE (operands[0]),
operands[1], operands[2]) == CCFPmode
&& ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
"#")
(define_split (define_split
[(set (pc) [(set (pc)
(if_then_else (match_operator 0 "comparison_operator" (if_then_else (match_operator 0 "comparison_operator"
...@@ -13343,17 +13386,14 @@ ...@@ -13343,17 +13386,14 @@
[(set (pc) [(set (pc)
(if_then_else (match_operator 0 "comparison_operator" (if_then_else (match_operator 0 "comparison_operator"
[(match_operand 1 "register_operand" "") [(match_operand 1 "register_operand" "")
(match_operand 2 "nonimmediate_operand" "")]) (match_operand 2 "general_operand" "")])
(match_operand 3 "" "") (match_operand 3 "" "")
(match_operand 4 "" ""))) (match_operand 4 "" "")))
(clobber (reg:CCFP FPSR_REG)) (clobber (reg:CCFP FPSR_REG))
(clobber (reg:CCFP FLAGS_REG)) (clobber (reg:CCFP FLAGS_REG))
(clobber (match_scratch:HI 5 "=a"))] (clobber (match_scratch:HI 5 "=a"))]
"reload_completed" "reload_completed"
[(set (pc) [(const_int 0)]
(if_then_else (match_dup 6)
(match_dup 3)
(match_dup 4)))]
{ {
ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2], ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
operands[3], operands[4], operands[5]); operands[3], operands[4], operands[5]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment