aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
AgeCommit message (Collapse)AuthorFilesLines
2004-06-15fold-const.c (swap_tree_comparison): No longer static.Jeff Law1-5/+11
* fold-const.c (swap_tree_comparison): No longer static. (tree_swap_operands_p): Similarly. Return true if both operands are SSA_NAMEs and the first operand has a higher version number than the second operand. * tree.h (swap_tree_comparison): Prototype. (tree_swap_operands_p): Prototype. * tree-ssa-operands.c (get_expr_operands): For commutative operators and relational comparisons, canonicalize the order of the operands. * gcc.dg/tree-ssa/20040615-1.c: New test. * gcc.dg/tree-ssa/20030824-1.c: Update expected output to be less sensitive to operand ordering. * gcc.dg/tree-ssa/20030824-2.c: Likewise. From-SVN: r83224
2004-06-15c-common.c (lang_gimplify_stmt): Remove next_p argument.Richard Henderson1-1/+1
* c-common.c (lang_gimplify_stmt): Remove next_p argument. (if_elt, if_stack, if_stack_space, c_expand_start_cond, c_finish_then, c_expand_end_cond, c_expand_start_else, c_finish_else, c_begin_if_stmt, c_begin_while_stmt, c_finish_while_stmt_cond): Move to c-typeck.c. (finish_fname_decls, fname_decl): Use statement_lists. (c_expand_expr_stmt): Don't set last_expr_type. (c_type_hash): Fix indentation. (c_safe_from_p): Don't follow TREE_CHAIN. (c_tree_chain_matters_p): Remove. * c-common.def (SCOPE_STMT): Remove. (CLEANUP_STMT): Redefine to contain its own body. * c-common.h (struct stmt_tree_s): Remove x_last_stmt, x_last_expr_type, x_last_expr_filename, x_scope_stmt_stack. Add x_cur_stmt_list. (last_tree, last_expr_type, last_expr_filename, RECHAIN_STMTS): Remove. (cur_stmt_list): New. (STATEMENT_LIST_STMT_EXPR): New. (SCOPE_BEGIN_P, SCOPE_END_P, SCOPE_STMT_BLOCK, SCOPE_NULLIFIED_P, SCOPE_NO_CLEANUPS_P, SCOPE_PARTIAL_P, NEW_FOR_SCOPE_P): Remove. (CLEANUP_BODY): New. (CLEANUP_DECL): Move to operand 2. (c_common_stmt_codes): Remove SCOPE_STMT. (COMPOUND_STMT_NO_SCOPE, COMPOUND_STMT_BODY_BLOCK): Remove. * c-decl.c (c_scope_stmt_stack, current_scope_stmt_stack): Remove. (c_push_function_context, c_pop_function_context): Don't save it. (finish_decl): Set TREE_USED on the decl for a cleanup. Use push_cleanup. (store_parm_decls): Use statement lists. (finish_function): Remove compstmt rule workaround. Use statement lists. Call finish_fname_decls after finalizing the body. (c_begin_compound_stmt): Move to c-typeck.c. * c-dump.c (c_dump_tree): Remove SCOPE_STMT. * c-gimplify.c (gimplify_cleanup_stmt, gimplify_cleanup_stmts): New. (c_genericize): Invoke them. (c_gimplify_stmt): Don't look through TREE_CHAIN. Kill SCOPE_STMT. (c_build_bind_expr): Export. (gimplify_block, gimplify_cleanup): Remove. (gimplify_condition): Use gimplify_stmt. (gimplify_for_stmt): Remove FOR_INIT_STMT chaining hack. (gimplify_if_stmt): Remove recursion hack. (c_gimplify_expr): Remove STMT_EXPR handling. (stmt_expr_last_stmt, gimplify_stmt_expr): Remove. (is_last_stmt_of_scope): Remove. * c-lang.c (LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P): Remove. * c-mudflap.c (mflang_flush_calls): Use c_begin_compound_stmt, c_end_compound_stmt. * c-objc-common.c (build_cdtor): Likewise. * c-parse.in (primary): Use c_finish_stmt_expr. (push_scope, pop_scope): Remove. (c99_block_start, compstmt_start): Use c_begin_compound_stmt. (c99_block_end, compstmt): Use c_end_compound_stmt. (c99_block_lineno_labeled_stmt): Likewise. (compstmt_primary_start): Use c_begin_stmt_expr. (simple_if, select_or_iter_stmt): Update calls to stmt builders. (do_stmt_start): Fill in body directly. (lineno_stmt): Avoid setting lineno on constants. * c-pretty-print.c (pp_c_statement): Handle STATEMENT_LIST. Remove SCOPE_STMT. * c-semantics.c (begin_stmt_tree): Remove. (push_stmt_list, re_push_stmt_list, pop_stmt_list): New. (add_stmt): Use statement lists. (add_scope_stmt, finish_stmt_tree): Remove. (push_cleanup): New. * c-tree.h: Move some decls from c-common.h. * c-typeck.c (c_tree_expr_nonnegative_p): Simplify for statement lists. (do_case, c_finish_case): Likewise. (c_finish_then): Take body for then as argument. (c_finish_else): Similarly. (c_begin_for_stmt, c_finish_for_stmt_init, c_finish_for_stmt_cond, c_finish_for_stmt_incr, c_finish_for_stmt): New. (c_begin_stmt_expr, c_finish_stmt_expr): New. (c_begin_compound_stmt): Do scope management. (c_end_compound_stmt): New. * fold-const.c (tree_expr_nonnegative_p): Fix BIND_EXPR. * gimplify.c (voidify_wrapper_expr): Accept temporary argument. Look through exception handling constructs. (gimplify_bind_expr): Accept temporary argument. (gimplify_target_expr): Special case BIND_EXPR bodies. (gimplify_expr): Handle fallback == fb_none like a statement. * langhooks-def.h (LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P): Kill. * langhooks.c (lhd_tree_inlining_tree_chain_matters_p): Remove. * langhooks.h (tree_chain_matters_p): Remove. * stub-objc.c (objc_clear_super_receiver): New. * tree-gimple.h (voidify_wrapper_expr): Update decl. (append_to_statement_list, append_to_statement_list_force): Move to tree-iterator.h. * tree-inline.c (expand_call_inline): Update call. (clone_body): Use statement lists. (walk_tree): Don't check tree_chain_matters_p. (copy_tree_r): Likewise. * tree-iterator.c (alloc_stmt_list): Clear lang bits. (tsi_link_before, tsi_link_after): Set TREE_SIDE_EFFECTS properly. * tree-iterator.h (append_to_statement_list, append_to_statement_list_force): Moved from tree-gimple.h. * tree-pretty-print.c (dump_generic_node): Clean up TARGET_EXPR dump. * objc/objc-act.c (build_module_descriptor): Use c_begin_compound_stmt. (objc_enter_block): Likewise. (objc_exit_block): Use c_end_compound_stmt. (objc_build_try_enter_fragment): Add #error and comment for rewriting for OBJCPLUS. (objc_build_extract_fragment, objc_build_try_epilogue, objc_build_catch_stmt, objc_build_finally_prologue, objc_build_finally_epilogue): Update for C statement builders. * objc/objc-lang.c (LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P): Remove. cp/ * call.c (initialize_reference): Don't build CLEANUP_STMT here. * cp-gimplify.c (cp_gimplify_stmt): Remove next_p argument. (genericize_try_block): Use gimplify_stmt. (genericize_catch_block, genericize_eh_spec_block): Likewise. (cp_gimplify_init_expr): Remove STMT_EXPR special case. (gimplify_must_not_throw_expr): Update voidify_wrapper_expr call. * cp-lang.c (LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P): Remove. (cp_tree_chain_matters_p): Remove. * cp-tree.h (COMPOUND_STMT_TRY_BLOCK): New. (COMPOUND_STMT_BODY_BLOCK): New. (STATEMENT_LIST_NO_SCOPE, STATEMENT_LIST_TRY_BLOCK): New. (EXPR_STMT_STMT_EXPR_RESULT): New. (building_stmt_tree): Check cur_stmt_list. (tf_stmt_expr_cmpd, tf_stmt_expr_body): Remove. (BCS_NO_SCOPE, BCS_TRY_BLOCK, BCS_FN_BODY): New. * decl.c (poplevel): Use pop_stmt_list for minding cleanups. (cp_finish_decl): Use push_cleanup. (start_function, finish_function): Use statement lists. (finish_stmt): Do nothing. * except.c (begin_eh_spec_block): Use statement lists. (check_handlers_1, check_handlers): Likewise. * init.c (construct_virtual_base): Don't add extra compound stmts. (build_vec_init): Likewise. * name-lookup.c (maybe_push_cleanup_level): Use statement lists. * name-lookup.h (struct cp_binding_level): Add statement_list. * parser.c (cp_parser_statement): Take the STMT_EXPR node, not a bool. (cp_parser_labeled_statement, cp_parser_expression_statement, cp_parser_statement_seq_opt): Likewise. (cp_parser_compound_statement): Likewise. Take bool for try block. (cp_parser_selection_statement): Tidy if processing. (cp_parser_already_scoped_statement): Rewrite to do what it says. * pt.c (tsubst_copy): Move STMT_EXPR to tsubst_expr. (tsubst_expr): Rewrite STMT_EXPR processing. Handle STATEMENT_LIST. Mind COMPOUND_STMT_TRY_BLOCK, EXPR_STMT_STMT_EXPR_RESULT. * semantics.c (do_poplevel, do_pushlevel): Use statement lists. (finish_cond): New, rewritten from FINISH_COND. (simplify_loop_decl_cond): New. (finish_expr_stmt): Avoid nested EXPR_STMTs. (begin_if_stmt, finish_if_stmt_cond, finish_then_clause, begin_else_clause, finish_else_clause, finish_if_stmt, begin_while_stmt, finish_while_stmt_cond, finish_while_stmt, begin_do_stmt, finish_do_body, begin_for_stmt, finish_for_init_stmt, finish_for_cond, finish_for_stmt, begin_switch_stmt, finish_switch_cond, finish_switch_stmt, begin_try_block, finish_try_block, finish_cleanup_try_block, finish_function_try_block, finish_handler_sequence, finish_function_handler_sequence, begin_handler, finish_handler_parms, finish_handler, begin_stmt_expr, finish_stmt_expr_expr, finish_stmt_expr): Rewrite using statement lists. (begin_compound_stmt): Replace has_no_scope argument with flags. Update all callers. Use statement lists. (finish_compound_stmt): Likewise. (finish_decl_cleanup, finish_eh_cleanup): Use push_cleanup. (current_scope_stmt_stack): Remove. (simplify_aggr_init_expr): Don't muck with TREE_CHAIN. * typeck2.c (split_nonconstant_init_1, split_nonconstant_init): Rewrite with statement lists. testsuite/ * g++.dg/ext/stmtexpr1.C: XFAIL. * gcc.dg/20030612-1.c: XFAIL. From-SVN: r83221
2004-06-15fold-const.c (operand_equal_p): Update comment.Paolo Bonzini1-4/+4
2004-06-15 Paolo Bonzini <bonzini@gnu.org> * fold-const.c (operand_equal_p): Update comment. From-SVN: r83173
2004-06-13fold-const.c (fold_checksum_tree <case 't'>): Only look at TREE_VALUES if ↵Andrew Pinski1-3/+8
the EXPR is an ENUMERAL_TYPE. 2004-06-13 Andrew Pinski <pinskia@physics.uc.edu> * fold-const.c (fold_checksum_tree <case 't'>): Only look at TREE_VALUES if the EXPR is an ENUMERAL_TYPE. Only look at TYPE_MIN_VALUE and TYPE_MAX_VALUE if EXPR is an INTEGERAL_TYPE or a scalar float type. From-SVN: r83068
2004-06-12fold-const.c (omit_two_operands): New function.Roger Sayle1-0/+23
* fold-const.c (omit_two_operands): New function. * tree.h (omit_two_operands): Prototype here. * builtins.c (fold_builtin_unordered_cmp): New function to lower C99 unordered comparison builtins to the appropriate tree nodes. (fold_builtin_1): Use fold_builtin_unordered_cmp to lower BUILT_IN_ISGREATER, BUILT_IN_ISGREATEREQUAL, BUILT_IN_ISLESS, BUILT_IN_ISLESSEQUAL and BUILT_IN_ISLESSGREATER. Manually lower BUILT_IN_ISUNORDERED comparisons to an UNORDERED_EXPR tree node. (simplify_builtin_memcmp, simplify_builtin_strncmp, simplify_builtin_strncat, simplify_builtin_strspn): Use the new omit_two_operands function to build the required COMPOUND_EXPRs. From-SVN: r83040
2004-06-10fold-const.c (fold_inf_compare): Avoid creating non-gimple code when we are ↵Jeff Law1-0/+6
in gimple form. * fold-const.c (fold_inf_compare): Avoid creating non-gimple code when we are in gimple form. * gcc.c-torture/compile/20040610-1.c: New test. From-SVN: r82958
2004-06-10fold-const.c (fold_abs_const): Make extern.Roger Sayle1-2/+1
* fold-const.c (fold_abs_const): Make extern. * tree.h (fold_abs_const): Prototype here. * builtins.c (fold_builtin_fabs): New function to transform fabs, fabsf and fabsl builtins into ABS_EXPR tree nodes. (fold_builtin_abs): New function to transform abs, labs, llabs and imaxabs builtins into ABS_EXPR tree nodes. (expand_builtin): Fall back to a function call for abs, labs, llabs and imaxabs builtins that survive constant folding. (fold_builtin_1): Call fold_builtin_fabs for FABS, FABSF and FABSL, and fold_builtin_abs for ABS, LABS, LLABS and IMAXABS. From-SVN: r82916
2004-06-10fold-const.c (fold_not_const): New function.Roger Sayle1-24/+33
* fold-const.c (fold_not_const): New function. (fold) <ABS_EXPR>: Don't bother testing wins. (fold) <BIT_NOT_EXPR>: Call fold_not_const. (nondestructive_fold_unary_to_constant) <BIT_NOT_EXPR>: Likewise. From-SVN: r82868
2004-06-09Gimplify VA_ARG_EXPR into simpler forms.Jason Merrill1-0/+69
* target.h: Add gimplify_va_arg_expr hook. * target-def.h: Add TARGET_GIMPLIFY_VA_ARG_EXPR. * fold-const.c (build_fold_addr_expr) (build_fold_addr_expr_with_type): Move from gimplify.c. * tree.h: Declare them. * gimplify.c (gimplify_and_add): New fn. (build_addr_expr, build_addr_expr_with_type): Move to fold-const.c. (gimplify_array_ref_to_plus, gimplify_modify_expr) (gimplify_expr): Use build_fold_*. (copy_if_shared_r): Only mark VA_ARG_EXPR volatile if we don't know how to gimplify it. * builtins.c (std_gimplify_va_arg_expr): New fn. (dummy_object): New static fn. (gimplify_va_arg_expr): New fn. (stabilize_va_list): Use build_fold_*. * tree-gimple.h: Declare new fns. * config/i386/i386.c (TARGET_GIMPLIFY_VA_ARG_EXPR): Define. (ix86_gimplify_va_arg): New fn. * config/i386/ia64.c (TARGET_GIMPLIFY_VA_ARG_EXPR): Define. (ia64_gimplify_va_arg): New fn. * config/i386/rs6000.c (rs6000_gimplify_va_arg): New fn. (TARGET_GIMPLIFY_VA_ARG_EXPR): Define. * config/i386/sparc.c (sparc_gimplify_va_arg): New fn. * alias.c (get_varargs_alias_set): Just return 0 for now. * c-objc-common.c (c_tree_printer): Improve handling of %T. From-SVN: r82838
2004-06-08fold-const.c (fold_convert): Treat OFFSET_TYPE like POINTER_TYPE and ↵Andrew Pinski1-2/+4
INTEGER_TYPE. 2004-06-08 Andrew Pinski <pinskia@physics.uc.edu> * fold-const.c (fold_convert): Treat OFFSET_TYPE like POINTER_TYPE and INTEGER_TYPE. From-SVN: r82792
2004-06-07real.c (real_copysign): New function to implement libm's copysign.Roger Sayle1-4/+9
* real.c (real_copysign): New function to implement libm's copysign. * real.h (real_copysign): Prototype here. * fold-const.c (tree_expr_nonnegative_p): The result of sqrt, sqrtf and sqrtl can be negative, as sqrt(-0.0) = -0.0. Correct whitespace. * builtins.c (fold_builtin_isascii, fold_builtin_toascii, fold_builtin_isdigit): Add function prototypes. (fold_builtin_copysign): New function to fold copysign, copysignf and copysignl. Optimize copysign(x,x) as x. Evaluate copysign of constant arguments at compile-time using real_copysign. Fold copysign(X,Y) as fabs(X) if Y is always non-negative. (fold_builtin_1): Correct minor whitespace/style issues. Call fold_builtin_copysign for BUILT_IN_COPYSIGN{,F,L}. * gcc.dg/builtins-41.c: New test case. * gcc.dg/builtins-42.c: New test case. From-SVN: r82721
2004-05-31re PR c++/15069 (a bit test on a variable of enum type is miscompiled)Roger Sayle1-5/+5
PR middle-end/15069 * fold-const.c (fold_single_bit_test): Only perform "(X & C) != 0" into "X < 0" (where C is the signbit) if X's type is a full mode. * g++.dg/opt/fold3.C: New test case. From-SVN: r82490
2004-05-30fold-const.c (combine_comparisons, [...]): Use constant_boolean_node where ↵Roger Sayle1-98/+44
appropriate. * fold-const.c (combine_comparisons, optimize_bit_field_compare, range_binop, fold_truthop, fold_binary_op_with_conditional_arg, fold_mathfn_compare, fold_inf_compare, fold, fold_relational_hi_lo, nondestructive_fold_binary_to_constant): Use constant_boolean_node where appropriate. Don't bother using fold_convert on the second argument to omit_one_operand. From-SVN: r82468
2004-05-30fold-const.c (fold): Make sure the type is of BOOLEAN_TYPE.Andrew Pinski1-0/+4
2004-05-30 Andrew Pinski <pinskia@physics.uc.edu> * fold-const.c (fold) [case TRUTH_NOT_EXPR]: Make sure the type is of BOOLEAN_TYPE. From-SVN: r82456
2004-05-30c-common.c, [...]: Fix comment typos.Kazu Hirata1-2/+2
* c-common.c, calls.c, cfgcleanup.c, cgraph.c, cgraphunit.c, ddg.c, ddg.h, df.c, df.h, except.c, expr.c, flags.h, fold-const.c, gcc.c, gimplify.c, haifa-sched.c, modulo-sched.c, tree-inline.c, tree-into-ssa.c, tree-nested.c, tree-nrv.c, tree-ssa-ccp.c, tree-ssa-dom.c, tree-ssa-live.c, tree-ssa-loop.c, tree-ssa-pre.c, tree-tailcall.c, tree.h: Fix comment typos. Follow spelling conventions. From-SVN: r82439
2004-05-28re PR rtl-optimization/15649 (ICE with __builtin_isgreater and -ffast-math)Paolo Bonzini1-74/+206
gcc/ChangeLog: 2004-05-27 Paolo Bonzini <bonzini@gnu.org> Roger Sayle <roger@eyesopen.com> PR rtl-optimization/15649 Add LTGT_EXPR and improve pretty-printing of unordered comparisons. * c-common.c (c_common_truthvalue_conversion): Handle LTGT_EXPR. * c-typeck.c (build_binary_op): Likewise. * dojump.c (do_jump): Likewise. * expr.c (expand_expr_real_1, do_store_flag): Likewise. * predict.c (tree_predict_by_opcode): Likewise. * real.c (real_compare): Likewise. * tree-cfg.c (verify_expr): Likewise. * tree-inline.c (estimate_num_insns_1): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. Handle ORDERED_EXPR, UNORDERED_EXPR. (op_symbol): Print unordered comparisons differently than ordered ones. * tree.def (LTGT_EXPR): New '<' tree code. * doc/c-tree.texi (Expressions): Document floating-point comparison nodes. Fold comparisons between floating point values. * fold-const.c (enum comparison_code): New, from #define'd constants. Define compcodes for unordered comparisons and for invalid transformations. (invert_tree_comparison): Add "honor_nans" parameter. (fold_truthop): Revamp to work on floating-point types too. (comparison_to_compcode): Support unordered comparisons. Use new enum comparison_code. (compcode_to_comparison): Likewise. (combine_compcodes): New function. (invert_truthvalue): Let invert_tree_comparison decide whether it is valid to fold the comparison. Fold ORDERED and UNORDERED even if flag_unsafe_math_optimizations is off, and the remaining even if flag_unsafe_math_optimizations is off but we are under -fno-trapping-math. (fold_relational_const): Integer modes do not honor NaNs. gcc/testsuite/ChangeLog: 2004-05-27 Paolo Bonzini <bonzini@gnu.org> * gcc.c-torture/compare-fp-1.c, gcc.c-torture/compare-fp-2.c, gcc.c-torture/compare-fp-3.c, gcc.c-torture/compare-fp-4.c, gcc.c-torture/compare-fp-3.x, gcc.c-torture/compare-fp-4.x, gcc.c-torture/pr15649-1.c: New. Co-Authored-By: Roger Sayle <roger@eyesopen.com> From-SVN: r82365
2004-05-24fold-const.c (non_lvalue): Explicitly list the tree codes that need to be ↵Roger Sayle1-7/+41
wrapped by NON_LVALUE_EXPR... * fold-const.c (non_lvalue): Explicitly list the tree codes that need to be wrapped by NON_LVALUE_EXPR, instead of those that don't. From-SVN: r82195
2004-05-22fold-const.c (fold_read_from_constant_string): Convert result to requested type.Ulrich Weigand1-2/+3
* fold-const.c (fold_read_from_constant_string): Convert result to requested type. From-SVN: r82120
2004-05-21fold-const.c (fold, [...]): Use fold_convert instead of convert.Roger Sayle1-11/+11
* fold-const.c (fold, fold_relational_hi_lo, nondestructive_fold_binary_to_constant, fold_read_from_constant_string): Use fold_convert instead of convert. * builtins.c (simplify_builtin, simplify_builtin_strstr, simplify_builtin_strchr, simplify_builtin_strrchr, simplify_builtin_strpbrk): Use fold_convert instead of convert. From-SVN: r82102
2004-05-21tree.c (array_type_nelts, [...]): Replace build with build2.Roger Sayle1-533/+550
* tree.c (array_type_nelts, save_expr, substitute_in_expr, get_unwidened, get_narrower): Replace build with build2. * fold-const.c (negate_expr, associate_trees, size_binop, fold_convert, eval_subst, omit_one_operand, invert_truthvalue, pedantic_omit_one_operand, distribute_bit_expr, make_bit_field_ref, optimize_bit_field_compare, decode_field_reference, range_binop, make_range, build_range_check, fold_range_test, fold_truthop, optimize_minmax_comparison, extract_muldiv_1, fold_binary_op_with_conditional_arg, fold_mathfn_compare, fold_inf_compare, fold_single_bit_test, fold, fold_relational_hi_lo, nondestructive_fold_binary_to_constant): Likewise replace build with either build2 or build3. From-SVN: r82083
2004-05-20re PR middle-end/3074 (Statement with no effect not flagged with -Wall)Roger Sayle1-171/+14
PR middle-end/3074 * fold-const.c (strip_compound_expr): Delete function. (count_cond): Delete function. (fold_binary_op_with_conditional_arg): Only perform transformations "a + (b?c:d) -> b ? a+c : a+d" and "(b?c:d) + a -> b ? c+a : d+a" when a is constant. This greatly simplifies this routine. * tree.c (saved_expr_p): Delete function. * tree.h (saved_expr_p): Delete function prototype. * gcc.dg/pr3074-1.c: New test case. * gcc.dg/sequence-pt-1.c: Remove an XFAIL. From-SVN: r82071
2004-05-19fold-const.c: Remove non-printable character 160.Paolo Bonzini1-1/+1
2004-05-19 Paolo Bonzini <bonzini@gnu.org> * fold-const.c: Remove non-printable character 160. From-SVN: r82024
2004-05-15c-gimplify.c (c_genericize): Replace calls via (*lang_hooks.foo) with ↵Steven Bosscher1-3/+3
lang_hooks.foo. * c-gimplify.c (c_genericize): Replace calls via (*lang_hooks.foo) with lang_hooks.foo. * c-parse.in <expr_no_commas>: Likewise. <if_prefix>: Likewise. <select_or_iter_stmt>: Likewise. * expr.c (expand_var, expand_expr_real_1): Likewise. * expr.h (expand_expr): Make it a static inline function. Move prototype for expand_expr_real up before this. * fold-const.c (fold_relational_hi_lo, fold_relational_const): Likewise. * gimplify.c (gimple_boolify, gimplify_addr_expr, gimplify_asm_expr, gimplify_expr): Likewise. * tree-cfg.c (dump_tree_cfg, dump_cfg_stats, tree_cfg2vcg, dump_function_to_file): Likewise. * tree-dfa.c (dump_immediate_uses, dump_dfa_stats): Likewise. * tree-inline.c (remap_block, save_body, walk_tree): Likewise. * tree-into-ssa.c (dump_tree_ssa): Likewise. * tree-mudflap.c (mf_varname_tree, mf_file_function_line_tree): Likewise. * tree-optimize.c (execute_one_pass): Likewise. * tree-pretty-print.c (dump_generic_bb_buff): Likewise. * tree-ssa-alias.c (dump_alias_stats, dump_alias_info): Likewise. objc/ * objc-act.c (objc_build_try_enter_fragment, objc_build_try_epilogue, objc_build_catch_stmt, objc_build_finally_prologue): Replace calls via (*lang_hooks.foo) with lang_hooks.foo (). From-SVN: r81907
2004-05-13Merge tree-ssa-20020619-branch into mainline.Diego Novillo1-61/+716
From-SVN: r81764
2004-05-08fold-const.c (fold_div_compare): New function to optimize X/C1 op C2 where ↵Roger Sayle1-0/+165
op is a comparison operator and C1... * fold-const.c (fold_div_compare): New function to optimize X/C1 op C2 where op is a comparison operator and C1 and C2 are integer constants into a range check. (fold): Call fold_div_compare. * gcc.c-torture/execute/divcmp-1.c: New test case. * gcc.c-torture/execute/divcmp-2.c: New test case. * gcc.c-torture/execute/divcmp-3.c: New test case. From-SVN: r81645
2004-05-02fold-const.c (fold_convert_const, fold): Add missing FIX_ROUND_EXPR case.Kaveh R. Ghazi1-0/+5
* fold-const.c (fold_convert_const, fold): Add missing FIX_ROUND_EXPR case. From-SVN: r81410
2004-04-30bb-reorder.c, [...]: Fix comment typos.Kazu Hirata1-1/+1
* bb-reorder.c, c-opts.c, cfglayout.c, cgraph.c, cgraphunit.c, cppfiles.c, fold-const.c, ggc-zone.c, loop-doloop.c, optabs.c, reg-stack.c, varasm.c, config/alpha/ev4.md, config/alpha/ev5.md, config/alpha/ev6.md, config/arm/arm.c, config/c4x/c4x.c, config/c4x/c4x.md, config/cris/cris.c, config/cris/cris.h, config/fr30/fr30.h, config/frv/frv.c, config/frv/frv.h, config/frv/frv.md, config/h8300/h8300.c, config/i386/i386.c, config/i386/i386.md, config/i386/winnt.c, config/ia64/itanium2.md, config/ip2k/ip2k.c, config/mips/mips.c, config/mips/mips.h, config/mips/sr71k.md, config/pa/pa.c, config/s390/s390.c, config/sh/sh.c: Fix comment typos. From-SVN: r81345
2004-04-29builtins.c, [...]: Fix comment typos.Kazu Hirata1-1/+1
* builtins.c, cgraph.c, cgraphunit.c, final.c, fold-const.c: Fix comment typos. From-SVN: r81291
2004-04-26fold-const.c (fold): Prefer fold_convert (negate_expr (...)) to fold (build1 ↵Roger Sayle1-5/+17
(NEGATE_EXPR, ...)). * fold-const.c (fold): Prefer fold_convert (negate_expr (...)) to fold (build1 (NEGATE_EXPR, ...)). Optimize X / -1 as -X and X % -1 as 0. From-SVN: r81177
2004-04-20fold-const.c (fold_convert): Make function extern/public.Roger Sayle1-2/+1
* fold-const.c (fold_convert): Make function extern/public. * tree.h (fold_convert): Prototype here. * builtins.c (expand_builtin_strstr, expand_builtin_strchr, expand_builtin_strrchr, expand_builtin_strpbrk, expand_builtin_mempcpy, expand_builtin_bcopy, expand_builtin_bzero, expand_builtin_memcmp, expand_builtin_strcmp, expand_builtin_strncmp, stabilize_va_list, expand_builtin_sprintf, fold_trunc_transparent_mathfn, fold_builtin_logarithm, fold_builtin_exponent, fold_builtin_mempcpy, fold_builtin_strcpy, fold_builtin_strcmp, fold_builtin_strncmp, fold_builtin_signbit, fold_builtin_isdigit, fold_builtin): Prefer fold_convert to "convert" or "fold (build1 (NOP_EXPR, ...))". From-SVN: r80878
2004-04-14builtins.c (fold_builtin_cabs, [...]): Use `mathfn_built_in' to determine ↵Kaveh R. Ghazi1-49/+4
the new builtin. * builtins.c (fold_builtin_cabs, fold_builtin): Use `mathfn_built_in' to determine the new builtin. * fold-const.c (fold): Likewise. From-SVN: r80680
2004-04-11fold-const.c (fold_binary_op_with_conditional_arg): Tweak calling convention ↵Roger Sayle1-28/+37
to allow a NULL_TREE to be returned. * fold-const.c (fold_binary_op_with_conditional_arg): Tweak calling convention to allow a NULL_TREE to be returned. Factor sanity checks from callers, return NULL_TREE when appropriate. (fold): Handle COMPOUND_EXPR operands of binary expressions before COND_EXPR operands. Use reorder_operands_p(a,b) to check whether a op (b,c) can be rewritten as (b, a op c). Simplify calls to fold_binary_op_with_conditional_arg. From-SVN: r80609
2004-04-03fold-const.c (fold): Guard (-A)+B -> B-A transformation with reorder_operands_p.Roger Sayle1-2/+3
* fold-const.c (fold) <PLUS_EXPR>: Guard (-A)+B -> B-A transformation with reorder_operands_p. From-SVN: r80381
2004-04-01* fold-const.c (folda): Preserve types of comparisons.Waldek Hebisch1-7/+7
From-SVN: r80327
2004-04-01re PR c++/14755 (miscompilation in bitfielded signed integers)Jakub Jelinek1-22/+8
PR c++/14755 * fold-const.c (fold) <EQ_EXPR>: Properly compute newconst in "bitfld++ == const" to "++bitfld == const + incr" transformations. * gcc.c-torture/execute/20040331-1.c: New test. * gcc.dg/20040331-1.c: New test. From-SVN: r80294
2004-04-01expr.c (get_inner_reference): Use DECL_UNSIGNED, not TREE_UNSIGNED.Richard Kenner1-1/+1
* expr.c (get_inner_reference): Use DECL_UNSIGNED, not TREE_UNSIGNED. * stor-layout.c (layout_decl): Likewise. * tree.c (get_narrower): Likewise and also use BIT_FIELD_REF_UNSIGNED. * fold-const.c (make_bit_field_ref): Use BIT_FIELD_REF_UNSIGNED. * print-tree.c (print_node): Handle various used of unsigned_flag. * tree.def (BIT_FIELD_REF): Update comment. * tree.h (TREE_UNSIGNED): Deleted. (DECL_UNSIGNED, BIT_FIELD_REF_UNSIGNED): New macros. * cp/class.c (VTT_TOP_LEVEL_P): Use unsigned_flag directly. * f/com.c (ffe_truthvalue_conversion, case COMPONENT_REF): Use DECL_UNSIGNED and integer_onep. From-SVN: r80293
2004-03-31builtins.c, [...]: Change most occurrences of TREE_UNSIGNED to TYPE_UNSIGNED.Richard Kenner1-55/+59
* builtins.c, c-aux-info.c, c-common.c, c-cppbuiltin.c, c-decl.c: Change most occurrences of TREE_UNSIGNED to TYPE_UNSIGNED. * c-format.c, c-opts.c, c-pretty-print.c, c-typeck.c: Likewise. * calls.c, convert.c, dbxout.c, dojump.c, dwarf2out.c: Likewise. * expmed.c, expr.c, fold-const.c, function.c, integrate.c: Likewise. * optabs.c, sdbout.c, stmt.c, stor-layout.c, tree-dump.c: Likewise. * tree.c, config/iq2000/iq2000.c, config/m32r/m32r.c: Likewise. * config/mips/mips.c, config/rs6000/rs6000.c: Likewise. * config/s390/s390.c, config/sparc/sparc.c, objc/objc-act.c: Likewise. * stor-layout.c (layout_type, case COMPLEX_TYPE): Test for REAL_TYPE, not INTEGER_TYPE. (layout_type, case VECTOR_TYPE): Simplify code. * tree.c (build_vector_type_for_mode): Remove dup unsigned setting. * tree.h: Update comments. (STRIP_NOPS): Use TYPE_UNSIGNED. (TYPE_UNSIGNED): New macro. (TYPE_TRAP_SIGNED): Remove now redundant check. (SAVE_EXPR_NOPLACEHOLDER): Don't use TREE_UNSIGNED. * cp/call.c (joust): Use TYPE_UNSIGNED, not TREE_UNSIGNED. * cp/class.c (check_bitfield_decl): Likewise. * cp/cvt.c (type_promotes_to): Likewise. * cp/decl.c (finish_enum): Likewise. * cp/mangle.c (write_builtin_type): Likewise. * cp/semantics.c (finish_switch_cond, finish_unary_op_expr): Likewise. * cp/typeck.c (type_after_usual_arithmetic_conversions): Likewise. (build_binary_op): Likewise. * f/com.c (ffecom_arrayref_): Use TYPE_UNSIGNED, not TREE_UNSIGNED. (ffecom_expr_): Likewise. * java/jcf-write.c (generate_bytecode_insns): Use TYPE_UNSIGNED. * treelang/treetree.c (tree_lang_signed_or_unsigned_type): Use TYPE_UNSIGNED, not TREE_UNSIGNED. * ada/decl.c (gnat_to_gnu_entity, make_type_from_size): Use TYPE_UNSIGNED, not TREE_UNSIGNED. * ada/trans.c (tree_transform, convert_with_check): Likewise. * ada/utils.c (gnat_signed_or_unsigned_type): Likewise. (build_vms_descriptor, unchecked_convert): Likewise. * ada/utils2.c (nonbinary_modular_operation): Likewise. From-SVN: r80287
2004-03-30Reassociate multiply expression with an adjacent non-multiply expression.Fariborz Jahanian1-0/+30
Reviewed by Roger Sayle. From-SVN: r80093
2004-03-26fold-const.c (tree_expr_nonnegative_p): Handle BIT_XOR_EXPR like BIT_IOR_EXPR...Roger Sayle1-0/+1
* fold-const.c (tree_expr_nonnegative_p): Handle BIT_XOR_EXPR like BIT_IOR_EXPR; A^B is nonnegative when A and B are nonnegative. * gcc.dg/compare8.c: Add an additional test for XOR. From-SVN: r79979
2004-03-25builtins.c (fold_builtin): Add new builtin optimizations for sqrt and/or cbrt.Kaveh R. Ghazi1-7/+8
* builtins.c (fold_builtin): Add new builtin optimizations for sqrt and/or cbrt. * fold-const.c (fold): Likewise. testsuite: * gcc.dg/torture/builtin-explog-1.c: Add new cases. * gcc.dg/torture/builtin-math-1.c: Likewise. * builtin-power-1.c: New test. From-SVN: r79959
2004-03-23fold-const.c (tree_expr_nonnegative_p): A&B is nonnegative when A is ↵Roger Sayle1-0/+11
nonnegative or B is nonnegative. * fold-const.c (tree_expr_nonnegative_p): A&B is nonnegative when A is nonnegative or B is nonnegative. Similarly A|B is nonnegative when both A and B are nonnegative. (tree_expr_nonzero_p): A|B is nonzero when A is nonzero or B is nonzero. From-SVN: r79870
2004-03-23fold-const.c (fold): Remove cases for INTEGER_CST...Kazu Hirata1-8/+0
* fold-const.c (fold): Remove cases for INTEGER_CST, REAL_CST, VECTOR_CST, STRING_CST, COMPLEX_CST, and CONSTRUCTOR. From-SVN: r79862
2004-03-23re PR rtl-optimization/14669 (Wrong code with -O for enum values expression ↵Roger Sayle1-0/+3
E4 <= t && t <= E6) 2004-03-23 Kazu Hirata <kazu@cs.umass.edu> PR optimization/14669 * fold-const.c (fold): Only unwiden integer comparisons for equality or inequality operators, or when the signedness is the same. * g++.dg/opt/fold2.C: New test case. From-SVN: r79859
2004-03-21alias.c (get_alias_set): Remove handling of PLACEHOLDER_EXPR.Richard Kenner1-11/+0
* alias.c (get_alias_set): Remove handling of PLACEHOLDER_EXPR. * emit-rtl.c (component_ref_for_mem_expr): Likewise. (set_mem_attributes_minus_bitpos): Call SUBSTITUTE_PLACEHOLDER_IN_EXPR. * explow.c (expr_size): Likewise. * expr.h (placeholder_list, find_placeholder): Deleted. * expr.c (store_constructor): Likewise. (get_inner_reference): Likewise. Also don't call find_placeholder. (placeholder_list, find_placeholder): Deleted. (is_aligning_offset): Don't handle WITH_RECORD_EXPR, PLACEHOLDER_EXPR. (expand_expr_real, cases PLACEHOLDER_EXPR, WITH_RECORD_EXPR): Likewise. (highest_pow2_factor, case WITH_RECORD_EXPR): Remove. * dojump.c (do_jump, case WITH_RECORD_EXPR): Likewise. * dwarf2out.c (loc_descriptor_from_tree, case WITH_RECORD_EXPR): Likewise. * fold-const.c (invert_truthvalue, case WITH_RECORD_EXPR): Likewise. (extract_muldiv, case WITH_RECORD_EXPR): Likewise. * tree.c (expr_align, case WITH_RECORD_EXPR): Likewise. (contains_placeholder_p): Don't handle WITH_RECORD_EXPR. Clean up by using first_rtl_op. (substitute_in_expr): Use SUBSTITUTE_IN_EXPR for recursive call. (substitute_placeholder_in_expr): New function. * tree.def (WITH_RECORD_EXPR): Deleted. * tree.h (SUBSTITUTE_IN_EXPR, SUBSTITUTE_PLACEHOLDER_IN_EXPR): New. (substitute_placeholder_in_expr): New. * ada/decl.c (gnat_to_gnu_entity): Use SUBSTITUTE_PLACEHOLDER_IN_EXPR. * ada/trans.c (tree_transform, emit_index_check): Likewise. * ada/utils.c (build_template): Likewise. (max_size, convert): Remove handling of WITH_RECORD_EXPR. (maybe_unconstrained_array, unchecked_convert): Likewise. * ada/utils2.c (gnat_truthvalue_conversion, build_binary_op): Likewise. (build_unary_op): Likewise. (compare_arrays, build_allocator): Use SUBSTITUTE_PLACEHOLDER_IN_EXPR. (fill_vms_descriptor): Likewise. (build_call_alloc_dealloc): Likewise. ALIGN is unsigned. * ada/gigi.h (build_call_alloc_dealloc): Alignment is unsigned. From-SVN: r79789
2004-03-20* fold-const.c (fold): Replace "expr" with "t".Kazu Hirata1-5/+5
From-SVN: r79761
2004-03-20fold-const.c (fold): Replace "final_type" with "type".Kazu Hirata1-15/+14
* fold-const.c (fold): Replace "final_type" with "type". Remove variable "final_type". From-SVN: r79754
2004-03-20fold-const.c (fold): Constify "type".Kazu Hirata1-13/+13
* fold-const.c (fold): Constify "type". Replace "TREE_TYPE (t)" with "type". From-SVN: r79753
2004-03-20fold-const.c (fold): Replace "t" with "tem" where it is used as a temporary ↵Kazu Hirata1-51/+49
variable. * fold-const.c (fold): Replace "t" with "tem" where it is used as a temporary variable. Remove "orig_t" and all of its uses. From-SVN: r79746
2004-03-20fold-const.c (fold): Remove variable "invert".Kazu Hirata1-87/+195
* fold-const.c (fold): Remove variable "invert". Move the handling of relational expressions that can be folded to a constant ... (fold_relational_const): ... here. (tree_expr_nonzero_p): New. From-SVN: r79745
2004-03-19fold-const.c (fold): Move the handling of constants ...Kazu Hirata1-36/+57
* fold-const.c (fold) <ABS_EXPR>: Move the handling of constants ... (fold_abs_const): ... here. From-SVN: r79709