summaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-29 15:18:24 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-29 15:18:24 +0000
commit9c42dd286eb8af0872f07596312c4f3c6ef6af03 (patch)
tree600dc261e4509a381886cd337eccdaf4e4fccd41 /gcc/builtins.c
parent630e568cbe4352038bdf71de79bece6068d10929 (diff)
downloadgcc-9c42dd286eb8af0872f07596312c4f3c6ef6af03.tar.gz
2006-10-29 Richard Guenther <rguenther@suse.de>
* genopinit.c (optabs): Change lfloor_optab and lceil_optab to conversion optabs. * optabs.c (init_optabs): Initialize lfloor_optab and lceil_optab as conversion optab. * optabs.h (enum optab_index): Remove OTI_lfloor and OTI_lceil. (enum convert_optab_index): Add COI_lfloor and COI_lceil. (lfloor_optab, lceil_optab): Adjust defines. * builtins.c (expand_builtin_int_roundingfn): Adjust for lfloor and lceil optabs now being conversion optabs. * config/i386/i386-protos.h (ix86_expand_lfloorceil): Declare. * config/i386/i386.c (ix86_expand_sse_compare_and_jump): New static helper function. (ix86_expand_lfloorceil): New function to expand lfloor and lceil inline. * config/i386/i386.md (lfloor<mode>2): Split into ... (lfloorxf<mode>2): ... x87 variant (lfloor<mode>di2, lfloor<mode>si2): ... and SSE variants using ix86_expand_lfloorceil. (lceil<mode>2, lceilxf<mode>2, lceil<mode>di2, lceil<mode>si2): Likewise. * doc/md.texi (lfloorMN, lceilMN): Document. * gcc.target/i386/math-torture/lfloor.c: New testcase. * gcc.target/i386/math-torture/lceil.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118143 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index aedecc9afd0..b7d23c379bd 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2222,7 +2222,7 @@ expand_builtin_sincos (tree exp)
static rtx
expand_builtin_int_roundingfn (tree exp, rtx target, rtx subtarget)
{
- optab builtin_optab;
+ convert_optab builtin_optab;
rtx op0, insns, tmp;
tree fndecl = get_callee_fndecl (exp);
tree arglist = TREE_OPERAND (exp, 1);
@@ -2257,44 +2257,37 @@ expand_builtin_int_roundingfn (tree exp, rtx target, rtx subtarget)
/* Make a suitable register to place result in. */
mode = TYPE_MODE (TREE_TYPE (exp));
- /* Before working hard, check whether the instruction is available. */
- if (builtin_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
- {
- target = gen_reg_rtx (mode);
-
- /* Wrap the computation of the argument in a SAVE_EXPR, as we may
- need to expand the argument again. This way, we will not perform
- side-effects more the once. */
- narg = builtin_save_expr (arg);
- if (narg != arg)
- {
- arg = narg;
- arglist = build_tree_list (NULL_TREE, arg);
- exp = build_function_call_expr (fndecl, arglist);
- }
-
- op0 = expand_expr (arg, subtarget, VOIDmode, 0);
+ target = gen_reg_rtx (mode);
- start_sequence ();
+ /* Wrap the computation of the argument in a SAVE_EXPR, as we may
+ need to expand the argument again. This way, we will not perform
+ side-effects more the once. */
+ narg = builtin_save_expr (arg);
+ if (narg != arg)
+ {
+ arg = narg;
+ arglist = build_tree_list (NULL_TREE, arg);
+ exp = build_function_call_expr (fndecl, arglist);
+ }
- /* Compute into TARGET.
- Set TARGET to wherever the result comes back. */
- target = expand_unop (mode, builtin_optab, op0, target, 0);
+ op0 = expand_expr (arg, subtarget, VOIDmode, 0);
- if (target != 0)
- {
- /* Output the entire sequence. */
- insns = get_insns ();
- end_sequence ();
- emit_insn (insns);
- return target;
- }
+ start_sequence ();
- /* If we were unable to expand via the builtin, stop the sequence
- (without outputting the insns). */
+ /* Compute into TARGET. */
+ if (expand_sfix_optab (target, op0, builtin_optab))
+ {
+ /* Output the entire sequence. */
+ insns = get_insns ();
end_sequence ();
+ emit_insn (insns);
+ return target;
}
+ /* If we were unable to expand via the builtin, stop the sequence
+ (without outputting the insns). */
+ end_sequence ();
+
/* Fall back to floating point rounding optab. */
fallback_fndecl = mathfn_built_in (TREE_TYPE (arg), fallback_fn);
/* We shouldn't get here on targets without TARGET_C99_FUNCTIONS.