aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
AgeCommit message (Collapse)AuthorFilesLines
2003-06-15builtins.c (expand_builtin_expect_jump): Remove redundant tests that are ↵Kazu Hirata1-7/+2
also in any_condjump_p(). * builtins.c (expand_builtin_expect_jump): Remove redundant tests that are also in any_condjump_p(). From-SVN: r67966
2003-06-13builtins.c: Fix comment typos.Kazu Hirata1-1/+1
* builtins.c: Fix comment typos. * fold-const.c: Likewise. From-SVN: r67907
2003-06-10builtins.c (fold_builtin): Optimize cos(-x) as cos(x).Roger Sayle1-0/+8
* builtins.c (fold_builtin): Optimize cos(-x) as cos(x). * fold-const.c (fold <NEGATE_EXPR>): Convert -f(x) into f(-x) when x is easily negated and f is sin, tan or atan. (fold <MULT_EXPR>): Optimize tan(x)*cos(x) and cos(x)*tan(x) as sin(x) with flag_unsafe_math_optimizations. (fold <RDIV_EXPR>): With flag_unsafe_math_optimizations fold sin(x)/cos(x) as tan(x) and cos(x)/sin(x) as 1.0/tan(x). * gcc.dg/builtins-20.c: New test case. From-SVN: r67701
2003-06-06fold-const.c (fold <ABS_EXPR>): Re-fold the result of folding fabs(-x) into ↵Roger Sayle1-0/+99
fabs(x). * fold-const.c (fold <ABS_EXPR>): Re-fold the result of folding fabs(-x) into fabs(x). Use tree_expr_nonnegative_p to determine when the ABS_EXPR (fabs or abs) is not required. (tree_expr_nonnegative_p): Move the logic that sqrt and exp are always nonnegative from fold to here. Additionally, cabs and fabs are always non-negative, and pow and atan are non-negative if their first argument is non-negative. * builtins.c (fold_builtin_cabs): New function to fold cabs{,f,l}. Evaluate cabs of a constant at compile-time. Convert cabs of a non-complex argument into fabs. Convert cabs(z) into sqrt(z.r*z.r + z.i*z.i) at the tree-level with -ffast-math or -funsafe-math-optimizations or -ffast-math. (fold_builtin): Convert BUILT_IN_FABS{,F,L} into an ABS_EXPR. Fold BUILT_IN_CABS{,F,L} using fold_builtin_cabs. * gcc.dg/builtins-2.c: Add some more tests. * gcc.dg/builtins-18.c: New test case. * gcc.dg/builtins-19.c: New test case. From-SVN: r67541
2003-06-04builtins.c (dconstpi, dconste): New mathematical constants.Roger Sayle1-2/+104
* builtins.c (dconstpi, dconste): New mathematical constants. (init_builtin_dconsts): New function to initialize dconstpi and dconste. (fold_builtin): Optimize exp(1.0) = e. Evaluate exp(x) at compile time with -ffast-math when x is an integer constant. Optimize tan(0.0) = 0.0. Optimize atan(0.0) = 0.0, atan(1.0) = pi/4 and tan(atan(x)) = x with -ffast-math. * gcc.dg/builtins-2.c: Add tests for tan(atan(x)). * gcc.dg/builtins-3.c: Add tests for tan(0.0) and atan(0.0). * gcc.dg/builtins-7.c: Add tests for tan(atan(x)) == x. * gcc.dg/builtins-17.c: New test case. * gcc.dg/i386-387-4.c: New test case. * gcc.c-torture/execute/ieee/mzero4.c: New test case. From-SVN: r67438
2003-06-03builtins.def (BUILT_IN_CABS, [...]): New builtins representing ISO C99's ↵Roger Sayle1-2/+71
cabs, cabsf and cabsl. * builtins.def (BUILT_IN_CABS, BUILT_IN_CABSF, BUILT_IN_CABSL): New builtins representing ISO C99's cabs, cabsf and cabsl. * builtins.c (expand_builtin_fabs): New function. (expand_builtin_cabs): New function. (expand_builtin): Expand BUILT_IN_FABS{,F,L} and BUILT_IN_CABS{,F,L} using expand_builtin_fabs and expand_builtin_cabs respectively. * doc/extend.texi: Document new cabs, cabsf and cabsl builtins. * gcc.dg/builtins-16.c: New test case. From-SVN: r67368
2003-06-03builtins.c (expand_builtin_memcpy): Remove endp argument and endp != 0 handling.Jakub Jelinek1-72/+99
* builtins.c (expand_builtin_memcpy): Remove endp argument and endp != 0 handling. Pass 0 to store_by_pieces. (expand_builtin_mempcpy): Add endp argument. Don't call expand_builtin_memcpy, call store_by_pieces resp. move_by_pieces directly. If ignoring result, only do expand_call. (expand_builtin_stpcpy): Likewise. Call expand_builtin_mempcpy otherwise. (expand_builtin_strncpy, expand_builtin_memset): Adjust store_by_pices callers. (expand_builtin): Adjust expand_builtin_memcpy and expand_builtin_mempcpy callers. * expr.c (can_move_by_pieces): New function. (move_by_pieces): Add endp argument, return to resp. memory at end or one byte earlier depending on endp. (store_by_pieces): Likewise. (emit_block_move): Adjust call to move_by_pieces. (emit_push_insn): Adjust move_by_pieces caller. * expr.h (can_move_by_pieces): New prototype. (store_by_pieces): Adjust prototypes. * rtl.h (move_by_pieces): Adjust prototype. * config/mips/mips.c (expand_block_move): Adjust move_by_pieces caller. * gcc.c-torture/execute/builtins/string-4.c (main_test): Remove mempcpy test with post-increments. * gcc.c-torture/execute/string-opt-3.c: New test. * gcc.dg/string-opt-1.c: New test. From-SVN: r67358
2003-05-27tree.h (contains_placeholder_p): Now returns bool.Richard Kenner1-2/+2
* tree.h (contains_placeholder_p): Now returns bool. (CONTAINS_PLACEHOLDER_P): New macro. (type_contains_placeholder_p): New function. * tree.c (save_expr): Remove code avoiding folding COMPONENT_REF. (contains_placeholder_p): Now returns bool. Rework to use CONTAINS_PLACEHOLDER_P macro. (type_contains_placeholder_p): New function. * fold-const.c (fold, case COMPONENT_REF): Don't fold if type_contains_placeholder_p. (fold_range_test, fold_mathfn_compare, fold_inf_compare, fold): Use CONTAINS_PLACEHOLDER_P macro. * builtins.c (fold_builtin): Likewise. * calls.c (initialize_argument_information): Likewise. * emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise. * explow.c (expr_size): Likewise. * expr.c (store_constructor, get_inner_reference): Likewise. * function.c (assign_parms): Likewise. * stor-layout.c (variable_size): Likewise. From-SVN: r67189
2003-05-24builtins.c (expand_builtin_memcpy): Use mode of dest_addr for intermediate ↵Matt Kraai1-1/+1
computation. * builtins.c (expand_builtin_memcpy): Use mode of dest_addr for intermediate computation. From-SVN: r67154
2003-05-23builtins.def: Defome atan...Roger Sayle1-0/+36
* builtins.def: Defome atan, atanf, atanl, tan, tanf and tanl builtin functions (and their __builtin_* variants). * builtins.c (mathfn_built_in): Handle tan{,f,l} and atan{,f,l}. (expand_builtin): Don't expand tan{,f,l} or atan{,f,l} when not optimizing. * doc/extend.texi: Document new tan and atan builtins, and their float and long double variants. * gcc.dg/builtins-1.c: Add tests for tan and atan. * gcc.dg/builtins-4.c: Add test for fmod. From-SVN: r67137
2003-05-18re PR middle-end/10472 (ICE in instantiate_virtual_regs_lossage)Roger Sayle1-6/+19
PR middle-end/10472 * builtins.c (expand_builtin_memcpy): Call force_operand on expressions and use simplify_gen_binary to create the addition. * gcc.c-torture/compile/20030518-1.c: New test case. Co-Authored-By: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Co-Authored-By: Zack Weinberg <zack@codesourcery.com> From-SVN: r66941
2003-05-17builtins.c (validate_arglist): Eliminate libiberty VA_ macros, always use ↵Kaveh R. Ghazi1-5/+5
stdarg. gcc: * builtins.c (validate_arglist): Eliminate libiberty VA_ macros, always use stdarg. * c-errors.c (pedwarn_c99): Likewise. * c-format.c (status_warning): Likewise. * c-semantics.c (build_stmt): Likewise. * calls.c (emit_library_call, emit_library_call_value): Likewise. * collect2.c (notice, fatal_perror, fatal, error): Likewise. * cpperror.c (cpp_error, cpp_error_with_line): Likewise. * diagnostic.c (build_message_string, output_printf, output_verbatim, verbatim, inform, warning, pedwarn, error, sorry, fatal_error, internal_error, warning_with_decl, pedwarn_with_decl, error_with_decl, fnotice): Likewise. * dwarf2asm.c (dw2_asm_output_data, dw2_asm_output_delta, dw2_asm_output_offset, dw2_asm_output_pcrel, dw2_asm_output_addr, dw2_asm_output_addr_rtx, dw2_asm_output_nstring, dw2_asm_output_data_uleb128, dw2_asm_output_data_sleb128, dw2_asm_output_delta_uleb128, dw2_asm_output_delta_sleb128, dw2_asm_output_encoded_addr_rtx): Likewise. * emit-rtl.c (gen_rtx, gen_rtvec): Likewise. * errors.c (warning, error, fatal, internal_error): Likewise. * final.c (output_operand_lossage, asm_fprintf): Likewise. * fix-header.c (fatal): Likewise. * gcc.c (fatal, error, notice): Likewise. * gcov.c (fnotice): Likewise. * genattrtab.c (attr_rtx, attr_printf): Likewise. * gengtype.c (error_at_line, xasprintf, oprintf): Likewise. * gensupport.c (message_with_line): Likewise. * mips-tfile.c (fatal, error): Likewise. * protoize.c (notice): Likewise. * ra-debug.c (ra_debug_msg): Likewise. * read-rtl.c (fatal_with_file_and_line): Likewise. * rtl-error.c (error_for_asm, warning_for_asm): Likewise. * tree.c (build, build_nt, build_function_type_list): Likewise. cp: * error.c (cp_error_at, cp_warning_at, cp_pedwarn_at): Eliminate libiberty VA_ macros, always use stdarg. * rtti.c (create_pseudo_type_info): Likewise. * tree.c (build_min_nt, build_min): Likewise. From-SVN: r66919
2003-05-08builtins.c (readonly_data_expr): New function.Kaveh R. Ghazi1-4/+24
gcc: * builtins.c (readonly_data_expr): New function. (expand_builtin_memmove): Optimize any rodata source, not just strings. testsuite gcc.c-torture/execute/string-opt-19.c: Add general rodata tests. (bcopy): Call memmove. From-SVN: r66597
2003-05-06real.c (real_powi): New function to calculate the value of a real raised to ↵Roger Sayle1-3/+23
an integer power, i.e. * real.c (real_powi): New function to calculate the value of a real raised to an integer power, i.e. pow(x,n) for int n. (real_sqrt): Convert to using the faster do_add, do_multiply and do_divide API for consistency with the rest of real.c. * real.h (real_powi): Prototype here. * builtins.c (fold_builtin): Avoid local variable mode when evaluating sqrt at compile time. Attempt to evaluate pow at compile-time, by checking for an integral exponent. * gcc.dg/builtins-14.c: New test case. From-SVN: r66515
2003-05-05builtins.c (expand_builtin_stpcpy): Only expand when the length of the ↵Kaveh R. Ghazi1-3/+7
source string can be evaluated at compile-time. * builtins.c (expand_builtin_stpcpy): Only expand when the length of the source string can be evaluated at compile-time. From-SVN: r66503
2003-05-05builtins.c (expand_builtin_mempcpy): New function.Jakub Jelinek1-2/+60
* builtins.c (expand_builtin_mempcpy): New function. (expand_builtin_stpcpy): Optimize stpcpy whose return value is ignored into strcpy no matter what arguments it has. (expand_builtin) <case BUILT_IN_MEMPCPY>: Call expand_builtin_mempcpy. * gcc.c-torture/execute/string-opt-18.c (main): Add 3 new tests. From-SVN: r66498
2003-05-04builtins.c (expand_builtin_constant_p, [...]): Update prototypes.Kaveh R. Ghazi1-50/+32
* builtins.c (expand_builtin_constant_p, expand_builtin_strlen, expand_builtin_frame_address): Update prototypes. (expand_builtin_constant_p, expand_builtin_strlen, expand_builtin_strcpy, expand_builtin_memset, expand_builtin_bzero, expand_builtin_args_info, expand_builtin_frame_address): Pass in just the argument(s) needed, not the entire expression `exp'. (expand_builtin): Update all calls to these functions. From-SVN: r66448
2003-05-03builtins.c (expand_builtin): Remove.Richard Henderson1-2/+2
* builtins.c (expand_builtin) <BUILT_IN_DWARF_FP_REGNUM>: Remove. <BUILT_IN_DWARF_SP_COLUMN>: New. * builtins.def (BUILT_IN_DWARF_FP_REGNUM): Remove. (BUILT_IN_DWARF_SP_COLUMN): New. * dwarf2out.c (expand_builtin_dwarf_fp_regnum): Remove. (expand_builtin_dwarf_sp_column): New. * except.h: Update to match. * unwind-dw2.c (execute_stack_op): Correct stack push typo. (execute_cfa_program): Record location expression address before extracting length. (uw_update_context_1): Install old CFA into stack pointer column. (uw_init_context_1): Set cfa_reg to stack pointer column. From-SVN: r66447
2003-05-03emit-rtl.c (last_call_insn, [...]): New functions.Olivier Hainque1-23/+4
* emit-rtl.c (last_call_insn, add_function_usage_to): New functions. * rtl.h (last_call_insn, add_function_usage_to): New prototypes. * builtins.c (expand_builtin_apply): Use the new emit-rtl functions. * calls.c (emit_call_1): Likewise. (expand_call): For calls initializing constant memory, replace emission of standalone mem /u clobber with function usage entry. * expr.c (emit_block_move_via_libcall): Likewise. * cse.c (count_reg_usage, case EXPR_LIST): New case. * flow.c (propagate_one_insn): Pass entire operand of CALL_INSN_FUNCTION_USAGE to mark_used_regs. * integrate.c (try_constants): For CALL_INSNs, substitute constants within the FUNCTION_USAGE also. * loop.c (prescan_loop): Note clobbers of const mem mentioned in FUNCTION_USAGE lists. * reload1.c (replace_pseudos_in): Renamed. (reload): Use it for clobbers surviving until the end of the reload. From-SVN: r66429
2003-05-03builtins.c (expand_builtin_stpcpy): Copy `arglist' before modifying it.Kaveh R. Ghazi1-2/+4
* builtins.c (expand_builtin_stpcpy): Copy `arglist' before modifying it. From-SVN: r66409
2003-04-28builtins.def (BUILT_IN_BCOPY, [...]): New.Jakub Jelinek1-0/+95
* builtins.def (BUILT_IN_BCOPY, BUILT_IN_MEMMOVE): New. * builtin-types.def (BT_FN_VOID_CONST_PTR_PTR_SIZE): New. * builtins.c (expand_builtin_memmove, expand_builtin_bcopy): New functions. (expand_builtin): Handle BUILT_IN_BCOPY and BUILT_IN_MEMMOVE. * gcc.c-torture/execute/string-opt-19.c: New test. From-SVN: r66169
2003-04-23re PR rtl-optimization/10339 ([sparc,ppc,ppc64] Invalid optimization: ↵Roger Sayle1-69/+159
replacing strncmp by memcmp) PR optimization/10339 * builtins.c (expand_builtin_strcmp): Try to emit cmpstrsi insn directly instead of unsafely transforming call into a memcmp. (expand_builtin_strncmp): Likewise. From-SVN: r65985
2003-04-20builtins.c (expand_builtin): Don't expand a pure or const built-in function ↵Roger Sayle1-0/+30
if... * builtins.c (expand_builtin): Don't expand a pure or const built-in function if the result will be ignored and none of its arguments are volatile. From-SVN: r65843
2003-04-14builtins.c (expand_builtin_strlen): Evaluate the lengths of string literals ↵Roger Sayle1-5/+9
at compile-time. * builtins.c (expand_builtin_strlen): Evaluate the lengths of string literals at compile-time. From-SVN: r65585
2003-04-14Fix formatting in last commit.Kaveh Ghazi1-3/+3
From-SVN: r65559
2003-04-13builtins.c (expand_builtin_memcpy): Add `endp' argument, use it.Kaveh R. Ghazi1-9/+69
gcc: * builtins.c (expand_builtin_memcpy): Add `endp' argument, use it. (expand_builtin_stpcpy): New. (expand_builtin): Add BUILT_IN_MEMPCPY & BUILT_IN_STPCPY. * builtins.def: Add mempcpy & stpcpy support. * doc/extend.texi (mempcpy, stpcpy): Document new builtins. testsuite: * gcc.c-torture/execute/string-opt-18.c: New test. From-SVN: r65551
2003-04-13tree.c (build_constructor): New function.Zack Weinberg1-19/+0
* tree.c (build_constructor): New function. * tree.h: Prototype it. * c-typeck.c (build_c_cast, pop_init_level) * profile.c (build_function_info_value, build_gcov_info_value) (create_profiler): Use build_constructor. * builtins.c (expand_builtin_args_info): Remove #if 0 blocks. * objc/objc-act.c (build_constructor): Rename objc_build_constructor. Use build_constructor. (build_objc_string_object, objc_add_static_instance) (init_def_list, init_objc_symtab, init_module_descriptor) (generate_static_references, build_selector_translation_table) (build_descriptor_table_initializer, generate_descriptor_table) (build_protocol_initializer, build_ivar_list_initializer) (generate_ivars_list, build_dispatch_table_initializer) (generate_dispatch_table, generate_protocol_list) (build_category_initializer, build_shared_structure_initializer): Update to match. ada: * gigi.h, utils2.c (build_constructor): Rename gnat_build_constructor. Use build_constructor. * decl.c (gnat_to_gnu_entity) * trans.c (tree_transform, pos_to_constructor, extract_values) * ada/utils.c (build_template, convert_to_fat_pointer, convert) (unchecked_convert) * ada/utils2.c (build_binary_op, build_call_raise, build_allocator) (fill_vms_descriptor): Update to match. cp: * class.c (initialize_array) * decl.c (reshape_init) * decl2.c (build_expr_from_tree) * init.c (build_zero_init) * pt.c (tsubst_copy, tsubst_copy_and_build) * rtti.c (tinfo_base_init, generic_initializer, ptr_initializer) (ptm_initializer, class_initializer, get_pseudo_ti_init) * semantics.c (finish_compound_literal) * typeck.c (build_ptrmemfunc1) * typeck2.c (store_init_value, process_init_constructor) (build_functional_cast): Use build_constructor. f: * com.c (ffecom_build_complex_constant_, ffecom_expr_) (ffecom_init_zero_, ffecom_transform_namelist_, ffecom_vardesc_) (ffecom_vardesc_array_, ffecom_vardesc_dims_, ffecom_2) * ste.c (ffeste_io_ialist_, ffeste_io_cilist_, ffeste_io_cllist_) (ffeste_io_icilist_, ffeste_io_inlist_, ffeste_io_olist_): Use build_constructor. java: * class.c (make_field_value, make_method_value, get_dispatch_table) (make_class_data, emit_offset_symbol_table) * constants.c (build_constants_constructor) * java-tree.h (START_RECORD_CONSTRUCTOR) * parse.y (maybe_build_array_element_wfl): Use build_constructor. From-SVN: r65539
2003-04-08builtins.c (fold_builtin): Constant fold expressions as x*0.5 instead of x/2.0.Roger Sayle1-8/+83
* builtins.c (fold_builtin): Constant fold expressions as x*0.5 instead of x/2.0. Optimize sqrt(pow(x,y)) as pow(x,y*0.5), log(pow(x,y)) as y*log(x), pow(exp(x),y) as exp(x*y), pow(sqrt(x),y) as pow(x,y*0.5) and pow(pow(x,y),z) as pow(x,y*z). Delete function scope "fcode" variable to avoid shadowing. * gcc.dg/builtins-9.c: New test case. * gcc.dg/builtins-10.c: New test case. From-SVN: r65386
2003-03-31emit-rtl.c (dconstm2, dconsthalf): New real constants.Roger Sayle1-7/+95
* emit-rtl.c (dconstm2, dconsthalf): New real constants. (init_emit_once): Initialize dconstm2 and dconsthalf here. * real.h (dconstm2, dconsthalf): Add prototypes here. * real.c (real_sqrt): Use dconsthalf rather than local copy. * builtins.c (fold_builtin): When optimizing sqrt(exp(x)) as exp(x/2.0) remember to fold the division if possible. Fold sin(0.0) as 0.0, cos(0.0) as 1.0, pow(x,1.0) as x, pow(x,-1.0) as 1.0/x, pow(x,2.0) as x*x, pow(x,-2.0) as 1.0/(x*x) and pow(x,0.5) as sqrt(x). * gcc.dg/builtins-3.c: Add new tests for sin and cos. * gcc.dg/builtins-7.c: New test case. * gcc.dg/builtins-8.c: New test case. From-SVN: r65088
2003-03-24builtins.c (expand_builtin_fputs): When optimizing for size, don't transform ↵Arpad Beszedes1-1/+5
fputs into fwrite. gcc: * builtins.c (expand_builtin_fputs): When optimizing for size, don't transform fputs into fwrite. testsuite: * gcc.c-torture/execute/stdio-opt-1.c: Adjust test for change to builtin fputs. From-SVN: r64771
2003-03-18builtins.c (expand_builtin_unop): New target_mode operand; use it to convert ↵Richard Henderson1-9/+17
the result to the correct mode. * builtins.c (expand_builtin_unop): New target_mode operand; use it to convert the result to the correct mode. (expand_builtin): Update all callers. From-SVN: r64545
2003-02-26builtins.c (purge_builtin_constant_p): Handle subreg of constant_p_rtx too.Alexandre Oliva1-2/+5
* builtins.c (purge_builtin_constant_p): Handle subreg of constant_p_rtx too. From-SVN: r63490
2003-02-22fold-const.c (omit_one_operand): No longer static.Roger Sayle1-14/+53
* fold-const.c (omit_one_operand): No longer static. * tree.h (omit_one_operand): Prototype here. (div_and_round_double): Keep fold-const.c prototypes together. * builtins.c (builtin_mathfn_code): Handle binary built-in funtions, such as "pow" and "atan2". (fold_builtin): Optimize both pow(x,0.0) and pow(1.0,y) to 1.0. Simplify optimizations using "type" the builtin's return type. * gcc.dg/builtins-5.c: New test case. From-SVN: r63273
2003-02-22i386.c (builtin_description): Add __builtin_ia32_paddq and __builtin_ia32_psubq.Jan Hubicka1-1/+1
* i386.c (builtin_description): Add __builtin_ia32_paddq and __builtin_ia32_psubq. Fix __builtin_ia32_paddq128 and __builtin_ia32_psubq128. * i386.h (IX86_BUILTIN_PADDQ, IX86_BUILTIN_PSUBQ): New. * i386.md (addv*, mmx_ior*, mmx_xoe*, mmx_and*): Add missing '%'. (mmx_adddi3, mmx_subdi3): New. * mmintrin.h (_mm_add_si64, _mm_sub_si64): New. * xmmintrin.h (_mm_movepi64_pi64): New. (_mm_add_epi64, _mm_sub_epi64): fix. (_mm_mul_pu16): Rename to... (_mm_mul_su32): ... this one. * builtins.c (expand_builtin_expect): Do not predict flag_guess_branch_prob is not set. * c-semantics.c (expand_stmt): Likewise. * predict.c (predict_insn): Likewise. * stmt.c (expand_continue_loop): Likewise. * toplev.c (rest_of_compilation): Do not call note_prediction_to_br_prob and note_prediction_to_br_prob when not optimizing. From-SVN: r63263
2003-02-21re PR rtl-optimization/8613 (-O2 optimization generates wrong code)Glen Nakamura1-0/+3
PR optimization/8613 * builtins.c (expand_builtin): Emit postincrements before expanding builtin functions. From-SVN: r63207
2003-02-11* builtins.c: Fix failures caused by commit of the wrong patch.Roger Sayle1-3/+5
From-SVN: r62727
2003-02-11optabs.h (enum optab_index): Add new OTI_pow and OTI_atan2.Roger Sayle1-26/+149
* optabs.h (enum optab_index): Add new OTI_pow and OTI_atan2. (pow_optab, atan2_optab): Define corresponding macros. * optabs.c (init_optabs): Initialize pow_optab and atan2_optab. * genopinit.c (optabs): Implement pow_optab and atan2_optab using pow?f3 and atan2?f3 patterns. * builtins.c (expand_errno_check): New function to update errno if necessary, split out from expand_builtin_mathfn. (expand_builtin_mathfn): Use expand_errno_check. (expand_builtin_mathfn_2): New function to handle expanding binary math functions, reusing the code in expand_errno_check. (expand_builtin): Handle the pow and atan2 math built-ins, BUILT_IN_{POW,POWF,POWL,ATAN2,ATAN2F,ATAN2L} via the new function expand_builtin_mathfn_2. * doc/md.texi: Document new pow?f3 and atan2?f3 patterns. From-SVN: r62708
2003-02-07builtin-types.def (BT_FN_FLOAT_FLOAT_FLOAT): New built-in type.Roger Sayle1-0/+24
* builtin-types.def (BT_FN_FLOAT_FLOAT_FLOAT): New built-in type. (BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE): Likewise. (BT_FN_DOUBLE_DOUBLE_DOUBLE): Likewise. * builtins.def: Define pow, powf, powl, atan2, atan2f and atan2l builtin functions (and their __builtin_* variants). * builtins.c (mathfn_built_in): Handle missing log{,f,l} cases. (expand_builtin): Don't expand log{,f,l}, pow{,f,l} or atan2{,f,l} when not optimizing. * doc/extend.texi: Document new pow and atan2 builtins, and their float and long double variants. Realphabetize builtins. * testsuite/gcc.dg/builtins-4.c: New test case. From-SVN: r62551
2003-02-01[multiple changes]Richard Henderson1-6/+42
2003-02-01 Richard Henderson <rth@redhat.com> * optabs.c (expand_unop): Use word_mode for outmode of bit scaners. * libgcc2.c (__ffsdi2, __clzsi2, __clzdi2, __ctzsi2, __ctzdi2, __popcountsi2, __popcountdi2, __paritysi2 __paritydi2): Change return type to Wtype. * libgcc-std.ver (GCC_3.4): Fix inheritance. * config/i386/i386.md (ffssi2): Use nonimmediate_operand for expander input constraint. 2003-02-01 Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> * optabs.h (optab_index): Add OTI_clz, OTI_ctz, OTI_popcount and OTI_parity. (clz_optab, ctz_optab, popcount_optab, parity_optab): New. * optabs.c (widen_clz, expand_parity): New. (expand_unop): Handle clz and parity. Hardcode SImode as outmode for libcalls to clz, ctz, popcount, and parity. (init_optabs): Init clz_optab, ctz_optab, popcount_optab and parity_optab, and set up libfunc handlers. * libgcc2.c (__clzsi2, __clzdi2, __ctzsi2, __ctzdi2, __popcountsi2, __popcountdi2, __paritysi2 __paritydi2, __popcount_tab): New. * libgcc2.h: Declare them. * libgcc-std.ver (GCC_3.4): Add new functions from libgcc2.c. * genopinit.c (optabs): Add clz_optab, ctz_optab, popcount_optab and parity_optab. * builtin-types.def (BT_FN_INT_LONG, BT_FN_INT_LONGLONG): New. * builtins.def (BUILT_IN_CLZ, BUILT_IN_CTZ, BUILT_IN_POPCOUNT, BUILT_IN_PARITY, BUILT_IN_FFSL, BUILT_IN_CLZL, BUILT_IN_CTZL, BUILT_IN_POPCOUNTL, BUILT_IN_PARITYL, BUILT_IN_FFSLL, BUILT_IN_CLZLL, BUILT_IN_CTZLL, BUILT_IN_POPCOUNTLL, BUILT_IN_PARITYLL): New. * builtins.c (expand_builtin_unop): Rename from expand_builtin_ffs and add optab argument. (expand_builtin): Expand BUILT_IN_{FFS,CLZ,POPCOUNT,PARITY}*. * tree.def (CLZ_EXPR, CTZ_EXPR, POPCOUNT_EXPR, PARITY_EXPR): New. * expr.c (expand_expr): Handle them. * fold-const.c (tree_expr_nonnegative_p): Likewise. * rtl.def (CLZ, CTZ, POPCOUNT, PARITY): New. * reload1.c (eliminate_regs): Handle them. (elimination_effects): Likewise. * function.c (instantiate_virtual_regs_1): Likewise * genattrtab.c (check_attr_value): Likewise. * simplify-rtx.c (simplify_unary_operation): Likewise. * c-common.c (c_common_truthvalue_conversion): Handle POPCOUNT_EXPR. * combine.c (combine_simplify_rtx): Handle POPCOUNT and PARITY. (nonzero_bits): Handle CLZ, CTZ, POPCOUNT and PARITY. * config/alpha/alpha.md (clzdi2, ctzdi2, popcountdi2): New. * config/arm/arm.c (arm_init_builtins): Rename __builtin_clz to __builtin_arm_clz. * Makefile.in (LIB2FUNCS_1, LIB2FUNCS_2): Move... * mklibgcc.in (lib2funcs): ...here and merge. Add new members. * doc/extend.texi (Other Builtins): Add new builtins. * doc/md.texi (Standard Names): Add new patterns. From-SVN: r62252
2003-01-25builtins.c (purge_builtin_constant_p): Scan insn stream sequentially rather ↵Roger Sayle1-19/+13
than by basic block. * builtins.c (purge_builtin_constant_p): Scan insn stream sequentially rather than by basic block. * function.c (purge_addressof): Simplify test with INSN_P. From-SVN: r61789
2003-01-25function.h (struct function): New field calls_constant_p.Roger Sayle1-0/+2
* function.h (struct function): New field calls_constant_p. (current_function_calls_constant_p): New macro for above. * function.c (prepare_function_start): Initialize calls_eh_return and calls_constant_p. * builtins.c (expand_builtin_constant_p): Set calls_constant_p. * toplev.c (rest_of_compilation): Only call purge_builtin_constant_p when the current_function_calls_constant_p. * integrate.c (expand_inline_function): Set calls_constant_p if the function being inlined has calls_constant_p set. From-SVN: r61786
2003-01-25builtins.c (fold_trunc_transparent_mathfn): New function.Jan Hubicka1-0/+48
* builtins.c (fold_trunc_transparent_mathfn): New function. (fold_builtin): Use it. * convert.c (convert_to_real): Re-enable code to convert math functions; add support for floor familly functions. From-SVN: r61764
2003-01-25* builtins.c (fold_trunc_transparent_mathfn): Undo accidental commit.Jan Hubicka1-1/+0
From-SVN: r61761
2003-01-24builtins.c (DEF_BUILTIN): Accept 10 arguments.Jan Hubicka1-14/+183
* builtins.c (DEF_BUILTIN): Accept 10 arguments. (implicit_built_in_decls): New global array. (mathfn_built_in): New global function. (fold_trunc_transparent_mathfn): New static function (expand_builtin_strstr, expand_bultin_strchr, expand_builtin_strpbrk, expand_builtin_strcpy, expand_builtin_strncpy, expand_bultin_strcmp, expand_bultin_strncat, expand_builtin_fputs): Use implicint_built_in_decls. (fold_builtin): Fold floor/trunc/round/ceil/nearbyint. * builtins.def: Fix comments. (DEF_GCC_BUILTIN, DEF_FALLBACK_BUILTIN, DEF_EXT_FALLBACK_BUILTIN, DEF_LIB_BUILTIN, DEF_LIB_ALWAYS_BUILTIN, DEF_EXT_LIB_BUILTIN, DEF_C99_BULTIN, DEF_FRONT_END_LIB_BUILTIN, DEF_EXT_FRONT_END_LIB_BUILTIN): Pass implicit as needed. (DEF_C99_C90RES_BULTIN): New. (*f, *l builtins): Update. * c-common.c (DEF_BUILTIN): Initialize implicit array. (c_expand_builtin_printf, c_expand_builtin_fprintf): Update. * convert.c (strip_float_extensions): New global function. * tree.h (DEF_BUILTIN): Accept 10 arguments. (implicit_built_in_decls, mathfn_built_in, strip_float_extension): Declare. * java/builtins.c (define_builtin): Handle implicit. (DEF_BUILTIN): Update. * tm.texi (TARGET_C99_FUNCTIONS): Document. * defaults.h (TARGET_C99_FUNCTIONS): Default to 0. * config/linux.h (TARGET_C99_FUNCTIONS): Default to 1 when using glibc2. From-SVN: r61738
2003-01-23re PR rtl-optimization/8423 (CSE1 not propagating __builtin_constant_p enough)Roger Sayle1-2/+31
PR optimization/8423 * cse.c (fold_rtx): Only eliminate a CONSTANT_P_RTX to 1 when its argument is constant, or 0 if !flag_gcse. * simplify-rtx.c (simplify_rtx): Convert CONSTANT_P_RTX to 1 if it's argument is constant. * gcse.c (want_to_gcse_p): Ignore CONSTANT_P_RTX nodes. (hash_scan_set): Don't record CONSTANT_P_RTX expressions. (do_local_cprop): Don't propagate CONSTANT_P_RTX constants. * builtins.c (purge_builtin_constant_p): New function to force instantiation of any remaining CONSTANT_P_RTX nodes. * rtl.h (purge_builtin_constant_p): Prototype here. * toplev.c (rest_of_compilation): Invoke purge_builtin_constant_p pass after GCSE and before loop. (flag_gcse): No longer static. * flags.h (flag_gcse): Prototype here. From-SVN: r61642
2003-01-15real.c (real_sqrt): Return a bool result indicating whether a floating point ↵Roger Sayle1-6/+4
exception or trap... * real.c (real_sqrt): Return a bool result indicating whether a floating point exception or trap should be raised. * real.h (real_sqrt): Update function prototype. * builtins.c (fold_builtin): Only fold non-trapping square roots unless we're ignoring errno and trapping math. From-SVN: r61337
2002-12-16Merge basic-improvements-branch to trunkZack Weinberg1-3/+185
From-SVN: r60174
2002-12-01re PR c++/8332 (strlen/template interaction causes ICE)Mark Mitchell1-2/+7
PR c++/8332 PR c++/8493 * decl.c (cxx_init_decl_processing): Use size_type_node, not c_size_type_node. * decl2.c (coerce_new_type): Likewise. * except.c (do_allocate_exception): Likewise. * builtin-types.def (BT_SIZE): Use size_type_node. * builtins.c (fold_builtin): Make the builtin strlen returns a size_t, not a sizetype. * c-common.c (c_sizeof_or_alignof_type): Use size_type_node, not c_size_type_node. (c_alignof_expr): Likewise. (c_common_nodes_and_builtins): Likewise. * c-common.h (CTI_C_SIZE_TYPE): Remove. (c_size_type_node): Likewise. * c-format.c (T_ST): Use size_type_node, not c_size_type_node. * tree.h (TI_SIZE_TYPE): New enumeral. (size_type_node): Likewise. PR c++/8332 PR c++/8493 * g++.dg/template/strlen1.C: New test. From-SVN: r59689
2002-11-17* builtins.c: Fix formatting.Kazu Hirata1-38/+41
From-SVN: r59194
2002-09-16builtin-types.def (BT_FN_FLOAT_CONST_STRING): New.Richard Henderson1-0/+33
gcc/ * builtin-types.def (BT_FN_FLOAT_CONST_STRING): New. (BT_FN_DOUBLE_CONST_STRING, BT_FN_LONG_DOUBLE_CONST_STRING): New. * builtins.def (__builtin_nan, __builtin_nanf, __builtin_nanl): New. (__builtin_nans, __builtin_nansf, __builtin_nansl): New. * builtins.c (fold_builtin_nan): New. (fold_builtin): Call it. * real.c (real_nan): Parse a non-empty string. (round_for_format): Fix NaN significand truncation. * real.h (real_nan): Return bool. * doc/extend.texi: Document new builtins. libstdc++/ * include/std/std_limits.h (__glibcpp_f32_QNaN_bytes, __glibcpp_f32_has_QNaN, __glibcpp_f32_SNaN_bytes, __glibcpp_f32_has_SNaN, __glibcpp_f64_QNaN_bytes, __glibcpp_f64_has_QNaN, __glibcpp_f64_SNaN_bytes, __glibcpp_f64_has_SNaN, __glibcpp_f80_QNaN_bytes, __glibcpp_f80_has_QNaN, __glibcpp_f80_SNaN_bytes, __glibcpp_f80_has_SNaN, __glibcpp_f96_QNaN_bytes, __glibcpp_f96_has_QNaN, __glibcpp_f96_SNaN_bytes, __glibcpp_f96_has_SNaN, __glibcpp_f128_QNaN_bytes, __glibcpp_f128_has_QNaN, __glibcpp_f128_SNaN_bytes, __glibcpp_f128_has_SNaN, __glibcpp_float_QNaN_bytes, __glibcpp_float_has_QNaN, __glibcpp_float_SNaN_bytes, __glibcpp_float_has_SNaN, __glibcpp_double_QNaN_bytes, __glibcpp_double_has_QNaN, __glibcpp_double_SNaN_bytes, __glibcpp_double_has_SNaN, __glibcpp_long_double_QNaN_bytes, __glibcpp_long_double_has_QNaN, __glibcpp_long_double_SNaN_bytes, __glibcpp_long_double_has_SNaN): Remove. (__glibcpp_f128_is_iec559): True if IEEE. (__glibcpp_float_QNaN, __glibcpp_float_SNaN): Remove. (__glibcpp_double_QNaN, __glibcpp_double_SNaN): Remove. (__glibcpp_long_double_QNaN, __glibcpp_long_double_SNaN): Remove. (std::numeric_limits<float>::has_quiet_NaN): Use __builtin_nanf. (std::numeric_limits<float>::has_signaling_NaN): Mirror has_quiet_NaN. (std::numeric_limits<float>::quiet_NaN): Use __builtin_nanf. (std::numeric_limits<float>::signaling_NaN): Use __builtin_nansf. (std::numeric_limits<double>): Similarly. (std::numeric_limits<long double>): Similarly. * src/limits.cc (__glibcpp_float_QNaN, __glibcpp_float_SNaN): Remove. (__glibcpp_double_QNaN, __glibcpp_double_SNaN): Remove. (__glibcpp_long_double_QNaN, __glibcpp_long_double_SNaN): Remove. * testsuite/18_support/numeric_limits.cc (test_infinity): New. (test_denorm_min, test_qnan, test_is_iec559): New. From-SVN: r57221