aboutsummaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
AgeCommit message (Collapse)AuthorFilesLines
2008-08-12defaults.h (TARGET_FLOAT_FORMAT): Remove.Ulrich Weigand1-3/+2
ChangeLog: * defaults.h (TARGET_FLOAT_FORMAT): Remove. (UNKNOWN_FLOAT_FORMAT, IEEE_FLOAT_FORMAT, VAX_FLOAT_FORMAT): Remove. * config/alpha/alpha.h (TARGET_FLOAT_FORMAT): Remove. * config/iq2000/iq2000.h (TARGET_FLOAT_FORMAT): Remove. * config/pdp11/pdp11.h (TARGET_FLOAT_FORMAT): Remove. * config/score/score.h (TARGET_FLOAT_FORMAT): Remove. * config/vax/vax.h (TARGET_FLOAT_FORMAT): Remove. * doc/tm.texi (Storage Layout): Remove documentation for TARGET_FLOAT_FORMAT. * simplify-rtx.c (simplify_binary_operation_1): Replace TARGET_FLOAT_FORMAT check by appropriate HONOR_... checks. java/ChangeLog: * typeck.c (convert): Do not check for TARGET_FLOAT_FORMAT. From-SVN: r139017
2008-08-12real.h (struct real_format): New member has_sign_dependent_rounding.Ulrich Weigand1-2/+1
* real.h (struct real_format): New member has_sign_dependent_rounding. * real.c (ieee_single_format, mips_single_format, motorola_single_format, spu_single_format, ieee_double_format, mips_double_format, motorola_double_format, ieee_extended_motorola_format, ieee_extended_intel_96_format, ieee_extended_intel_128_format, ieee_extended_intel_96_round_53_format, ibm_extended_format, mips_extended_format, ieee_quad_format, mips_quad_format, vax_f_format, vax_d_format, vax_g_format): Initialize it. * config/pdp11/pdp11.c (pdp11_f_format, pdp11_d_format): Likewise. * defaults.h (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING): Remove. * config/spu/spu.h (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGN_DEPENDENT_ROUNDING): Remove. (ROUND_TOWARDS_ZERO): Likewise. * real.h (REAL_MODE_FORMAT): Protect MODE against macro expansion. (FLOAT_MODE_FORMAT): New macro. (REAL_MODE_FORMAT_COMPOSITE_P): Remove, replace by ... (MODE_COMPOSITE_P): ... this new macro. (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING): New macros. * machmode.h (GET_MODE_INNER): Cast result to enum machine_mode. * flags.h: Include "real.h". * fold-const.c (const_binop): Use MODE_COMPOSITE_P instead of REAL_MODE_FORMAT_COMPOSITE_P. * simplify-rtx.c (simplify_const_binary_operation): Likewise. * doc/tm.texi (Storage Layout): Remove documentation of MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING. Update documentation of ROUND_TOWARDS_ZERO and LARGEST_EXPONENT_IS_NORMAL to clarify they only apply to libgcc2.a. From-SVN: r139016
2008-06-09re PR middle-end/36447 (simplify_subreg ICE with right shift more than ↵Andy Hutchinson1-0/+1
length type AVR) PR middle-end/36447 * simplify-rtx.c (simplify_subreg): Add check for shift count greater than size. From-SVN: r136602
2008-05-08re PR target/36090 (ppc64 cacoshl miscompilation)Paolo Bonzini1-0/+18
2008-05-08 Paolo Bonzini <bonzini@gnu.org> PR target/36090 * simplify-rtx.c (simplify_plus_minus): Create CONST of similar RTX_CONST_OBJ before CONST_INT. From-SVN: r135086
2008-03-06simplify-rtx.c (simplify_subreg): Remove useless shifts from ↵Paolo Bonzini1-0/+16
word-extractions out of a multi-word object. 2008-03-06 Paolo Bonzini <bonzini@gnu.org> * simplify-rtx.c (simplify_subreg): Remove useless shifts from word-extractions out of a multi-word object. From-SVN: r132971
2008-02-28simplify-rtx.c (simplify_unary_operation_1): Extend the handling of ↵Richard Sandiford1-5/+20
SUBREG_PROMOTED_VAR_P to cope with cases where the... gcc/ * simplify-rtx.c (simplify_unary_operation_1): Extend the handling of SUBREG_PROMOTED_VAR_P to cope with cases where the extended value is smaller than the original promoted value. (simplify_subreg): If OP is a SUBREG, try to preserve its SUBREG_PROMOTED_VAR_P information. From-SVN: r132755
2008-02-23re PR tree-optimization/33512 (Simple bitwise simplification missed)Andrew Pinski1-0/+13
2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com> PR rtl-opt/33512 * simplify-rtx.c (simplify_binary_operation_1): Add simplification of (and X (ior (not X) Y) and (and (ior (not X) Y) X). 2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com> PR rtl-opt/33512 * gcc.dg/and-1.c: New test. From-SVN: r132575
2008-01-25re PR target/34856 (ICE with some constant vectors)Uros Bizjak1-1/+6
PR target/34856 * simplifx-rtx.c (simplify_const_binary_operation) [VEC_CONCAT]: Consider only CONST_INT, CONST_DOUBLE and CONST_FIXED as constant vector elements. testsuite/ChangeLog: PR target/34856 * gcc.dg/pr34856.c: Use pointer mode for "pin". From-SVN: r131821
2007-12-18re PR rtl-optimization/34490 (r128833 causes miscompilation of glibc ↵Jakub Jelinek1-7/+9
clock_gettime.c) PR rtl-optimization/34490 * simplify-rtx.c (simplify_const_relational_operation): If !sign, don't reduce mmin/mmax using num_sign_bit_copies. * gcc.c-torture/execute/20071216-1.c: New test. From-SVN: r131023
2007-10-07simplify-rtx.c (simplify_binary_operation_1): Canonicalize truncated shift ↵Richard Sandiford1-2/+9
counts. gcc/ * simplify-rtx.c (simplify_binary_operation_1): Canonicalize truncated shift counts. From-SVN: r129072
2007-10-01simplify-rtx.c (comparison_result, [...]): Rename CR_* constants to CMP_*.Paolo Bonzini1-56/+54
2007-10-01 Paolo Bonzini <bonzini@gnu.org> * simplify-rtx.c (comparison_result, simplify_relational_operation_1): Rename CR_* constants to CMP_*. Fix spacing. From-SVN: r128906
2007-09-27simplify-rtx.c (comparison_result): New.Paolo Bonzini1-161/+266
2007-09-04 Paolo Bonzini <bonzini@gnu.org> * simplify-rtx.c (comparison_result): New. (simplify_const_relational_operation): Use it instead of the five "equal|op[01]ltu?" variables; consequently remove redundant "else"s. Improve bounds-checking optimizations; remove subsumed POPCOUNT optimizations. Extract nonzero_address_p optimizations into a separate "if" together with optimizations where op1 is const0_rtx. Optimize comparing an IOR with zero. Simplify op0 RELOP op0 for floating-point arguments too when appropriate. Hoist test for ABS outside the final switch statement. * cse.c (fold_rtx): Don't look for an IOR equivalent of folded_arg0 if we found a constant equivalent. Remove transformations done in simplify-rtx.c for "op0 RELOP op0". From-SVN: r128833
2007-09-10simplify-rtx.c (simplify_relational_operation_1): For recent ↵Hans-Peter Nilsson1-1/+3
canonicalization, don't recurse if op1 equals both PLUS arguments. * simplify-rtx.c (simplify_relational_operation_1): For recent canonicalization, don't recurse if op1 equals both PLUS arguments. From-SVN: r128323
2007-09-09re PR target/30315 (optimize unsigned-add overflow test on x86 to use cpu ↵Rask Ingemann Lambertsen1-0/+6
flags from addl) PR target/30315 * config/i386/i386.h (CANONICALIZE_COMPARISON): Delete. * simplify-rtx.c (simplify_relational_operation_1): Add the canonicalization from i386.h. * doc/md.texi (Canonicalization of Instructions): Document it. From-SVN: r128305
2007-09-04Add new fp flags: -fassociative-math and -freciprocal-mathRevital Eres1-4/+4
Co-Authored-By: R. Clint Whaley <whaley@cs.utsa.edu> Co-Authored-By: Richard Guenther <rguenther@suse.de> From-SVN: r128075
2007-08-30c-lex.c (interpret_fixed): Declare.Chao-ying Fu1-2/+56
* c-lex.c (interpret_fixed): Declare. (interpret_float): Process _Fract and _Accum. (interpret_fixed): New function. * final.c (output_addr_const): Process CONST_FIXED. * simplify-rtx.c (simplify_const_unary_operation): Handle US_NEG. (simplify_binary_operation_1): Handle US_ASHIFT, SS_MULT, US_MULT, SS_DIV, US_DIV. (simplify_const_binary_operation): Handle SS_MULT, US_MULT, SS_DIV, US_DIV, US_ASHIFT. (simplify_immed_subreg): Support CONST_FIXED. Process MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM. (simplify_subreg): Support CONST_FIXED. From-SVN: r127941
2007-08-29simplify-rtx.c (simplify_binary_operation_1): Change CONST_VECTOR_ELT to ↵Uros Bizjak1-1/+1
XVECEXP in elem calculation. * simplify-rtx.c (simplify_binary_operation_1) [VEC_SELECT]: Change CONST_VECTOR_ELT to XVECEXP in elem calculation. From-SVN: r127902
2007-08-28re PR target/32661 (__builtin_ia32_vec_ext suboptimal for pointer/ref args)Uros Bizjak1-0/+79
PR target/32661 * simplify-rtx.c (simplify_binary_operation_1) [VEC_SELECT]: Simplify nested VEC_SELECT (with optional VEC_CONCAT operator as operand) when top VEC_SELECT extracts scalar element. * config/i386/sse.md (*vec_extract_v4si_mem): New. (*vec_extract_v4sf_mem): Ditto. testsuite/ChangeLog: PR target/32661 * gcc.target/i386/pr32661.c: New test. From-SVN: r127857
2007-08-28re PR rtl-optimization/33148 (ICE in trunc_int_for_mode, at explow.c:56 ↵Jakub Jelinek1-1/+2
during combine) PR rtl-optimization/33148 * simplify-rtx.c (simplify_unary_operation_1): Only optimize (neg (lt X 0)) if X has scalar int mode. * gcc.c-torture/compile/20070827-1.c: New test. From-SVN: r127855
2007-08-25c-common.c (vector_types_convertible_p, [...]): Constify.Kaveh R. Ghazi1-3/+3
* c-common.c (vector_types_convertible_p, decl_with_nonnull_addr_p, c_promoting_integer_type_p, self_promoting_args_p): Constify. * c-common.h (has_c_linkage, decl_with_nonnull_addr_p, c_promoting_integer_type_p, self_promoting_args_p, anon_aggr_type_p, vector_types_convertible_p): Likewise. * c-decl.c (anon_aggr_type_p): Likewise. * * c-dump.c (dump_stmt): Likewise. * c-objc-common.c (has_c_linkage): Likewise. * c-tree.h (same_translation_unit_p): Likewise. * c-typeck.c (null_pointer_constant_p, tagged_types_tu_compatible_p, function_types_compatible_p, type_lists_compatible_p, lvalue_or_else, lvalue_p, comptypes_internal, struct tagged_tu_seen_cache, same_translation_unit_p, alloc_tagged_tu_seen_cache, c_size_in_bytes): Likewise. * ggc-common.c (compare_ptr_data, hash_descriptor, eq_descriptor, hash_ptr, eq_ptr): Likewise. * langhooks-def.h (lhd_decl_ok_for_sibcall, LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Likewise. * langhooks.c (lhd_decl_ok_for_sibcall): Likewise. * langhooks.h (ok_for_sibcall, omp_privatize_by_reference): Likewise. * optabs.c (optab_for_tree_code): Likewise. * optabs.h (optab_for_tree_code): Likewise. * rtl.h (simplify_rtx): Likewise. * simplify-rtx.c (simplify_rtx): Likewise. * tree-dump.c (queue, queue_and_dump_index, queue_and_dump_type, dump_flag, dump_node): Likewise. * tree-dump.h (struct dump_info, dump_stmt, queue_and_dump_index, queue_and_dump_type, dump_flag): Likewise. * tree-flow.h (vect_can_force_dr_alignment_p): Likewise. * tree-pass.h (dump_node): Likewise. * tree-vectorizer.c (vect_can_force_dr_alignment_p, supportable_narrowing_operation): Likewise. * tree-vectorizer.h (vect_can_force_dr_alignment_p, supportable_narrowing_operation): Likewise. * tree-vrp.c (needs_overflow_infinity, supports_overflow_infinity, is_negative_overflow_infinity, is_positive_overflow_infinity, is_overflow_infinity, vrp_val_is_max, vrp_val_is_min, nonnull_arg_p, get_value_range, vrp_operand_equal_p, update_value_range, add_equivalence, ssa_name_nonnegative_p, ssa_name_nonzero_p, fp_predicate): Likewise. * tree.c (auto_var_in_fn_p, empty_body_p): Likewise. * tree.h (empty_body_p, auto_var_in_fn_p, ssa_name_nonzero_p, ssa_name_nonnegative_p): Likewise. cp: * call.c (sufficient_parms_p): Constify. * class.c (same_signature_p): Likewise. * cp-gimplify.c (is_invisiref_parm, cxx_omp_privatize_by_reference): Likewise. * cp-objcp-common.c (has_c_linkage): Likewise. * cp-tree.h (NON_THUNK_FUNCTION_CHECK, THUNK_FUNCTION_CHECK, sufficient_parms_p, same_signature_p, copy_fn_p, move_fn_p, grok_ctor_properties, nothrow_libfn_p, skip_artificial_parms_for, num_artificial_parms_for, comp_template_parms, template_parameter_pack_p, any_dependent_template_arguments_p, any_type_dependent_arguments_p, any_value_dependent_elements_p, repo_export_class_p, cxx_omp_privatize_by_reference, pod_type_p, zero_init_p, member_p, cp_lvalue_kind, builtin_valid_in_constant_expr_p, decl_anon_ns_mem_p, varargs_function_p, is_dummy_object, special_function_kind, string_conv_p, type_unknown_p, comp_except_specs, compparms, comp_cv_qualification, is_bitfield_expr_with_lowered_type, unlowered_expr_type, ptr_reasonably_similar, cp_type_readonly, cp_has_mutable_p, at_least_as_qualified_p, invalid_nonstatic_memfn_p, lvalue_or_else, lvalue_p): Likewise. * decl.c (copy_fn_p, move_fn_p, grok_ctor_properties): Likewise. * except.c (nothrow_libfn_p): Likewise. * method.c (skip_artificial_parms_for, num_artificial_parms_for): Likewise. * pt.c (comp_template_parms, template_parameter_pack_p, any_type_dependent_arguments_p, any_value_dependent_elements_p, any_dependent_template_arguments_p): Likewise. * repo.c (repo_export_class_p): Likewise. * semantics.c (anon_aggr_type_p): Likewise. * tree.c (lvalue_p_1, real_lvalue_p, lvalue_p, builtin_valid_in_constant_expr_p, decl_anon_ns_mem_p, varargs_function_p, member_p, is_dummy_object, pod_type_p, zero_init_p, special_function_p): Likewise. * typeck.c (comp_array_types, type_unknown_p, comp_except_specs, comp_array_types, at_least_as_qualified_p, comp_cv_qualification, compparms, invalid_nonstatic_memfn_p, is_bitfield_expr_with_lowered_type, unlowered_expr_type, string_conv_p, ptr_reasonably_similar, cp_type_readonly, cp_has_mutable_p, lvalue_or_else): Likewise. fortran: * trans-openmp.c (gfc_omp_privatize_by_reference): Constify. * trans.h (gfc_omp_privatize_by_reference): Likewise. java: * lang.c (java_decl_ok_for_sibcall): Likewise. From-SVN: r127799
2007-08-22fixed -ffinite-math-only A-A missing optimisationChristian Bruel1-6/+2
Co-Authored-By: Richard Guenther <rguenther@suse.de> From-SVN: r127705
2007-08-09simplify-rtx.c (simplify_binary_operation_1): Removed erroneous break that ↵Simon Baldwin1-2/+0
was preventing simplify_associative_operation()... * simplify-rtx.c (simplify_binary_operation_1): Removed erroneous break that was preventing simplify_associative_operation() for xor. From-SVN: r127319
2007-07-26Change copyright header to refer to version 3 of the GNU General Public ↵Nick Clifton1-4/+3
License and to point readers at the COPYING3 file and the FSF's license web page. From-SVN: r126948
2007-07-25cfglayout.c (insn_scope, insn_line): Constify.Kaveh R. Ghazi1-6/+6
* cfglayout.c (insn_scope, insn_line): Constify. * emit-rtl.c (const_int_htab_hash, const_int_htab_eq, const_double_htab_hash, const_double_htab_eq, mem_attrs_htab_hash): Likewise. * loop-iv.c (biv_eq): Likewise. * print-rtl.c (print_rtx, print_decl_name, print_mem_expr, print_inline_rtx, debug_rtx, debug_rtx_list, debug_rtx_range, debug_rtx_find, print_rtl, print_rtl_single, print_simple_rtl): Likewise. * rtl-error.c (location_for_asm, diagnostic_for_asm, error_for_asm, warning_for_asm, _fatal_insn, _fatal_insn_not_found): Likewise. * rtl.c (rtx_size, shared_const_p, shallow_copy_rtx_stat, rtx_equal_p, rtl_check_failed_bounds, rtl_check_failed_type1, rtl_check_failed_type2, rtl_check_failed_code1, rtl_check_failed_code2, rtl_check_failed_code_mode, rtvec_check_failed_bounds, rtl_check_failed_flag): Likewise. * rtl.h (rtl_check_failed_bounds, rtl_check_failed_type1, rtl_check_failed_type2, rtl_check_failed_code1, rtl_check_failed_code2, rtl_check_failed_code_mode, rtvec_check_failed_bounds, rtl_check_failed_flag, LABEL_KIND, SET_LABEL_KIND, rhs_regno, subreg_lsb, subreg_regno, subreg_nregs, shared_const_p, rtx_size, shallow_copy_rtx_stat, rtx_equal_p, get_pool_mode, insn_line, insn_file, simplify_replace_rtx, mode_signbit_p, rtx_addr_can_trap_p, nonzero_address_p, rtx_unstable_p, get_integer_term, get_related_value, offset_within_block_p, reg_mentioned_p, count_occurrences, reg_referenced_p, reg_used_between_p, no_labels_between_p, single_set_2, multiple_sets, set_noop_p, refers_to_regno_p, reg_overlap_mentioned_p, dead_or_set_p, dead_or_set_regno_p, find_reg_note, find_regno_note, find_reg_equal_equiv_note, find_constant_src, find_reg_fusage, find_regno_fusage, pure_call_p, remove_note, side_effects_p, volatile_refs_p, volatile_insn_p, may_trap_p, may_trap_after_code_motion_p, may_trap_or_fault_p, inequality_comparisons_p, tablejump_p, computed_jump_p, auto_inc_p, in_expr_list_p, remove_node_from_expr_list, loc_mentioned_in_p, label_is_jump_target_p, reversed_comparison_code_parts, debug_rtx, debug_rtx_list, debug_rtx_range, debug_rtx_find, print_mem_expr, print_rtl, print_simple_rtl, print_rtl_single, print_inline_rtx): Likewise. * rtlanal.c (covers_regno_p, covers_regno_no_parallel_p, computed_jump_p_1, nonzero_bits1, rtx_unstable_p, rtx_addr_can_trap_p_1, rtx_addr_can_trap_p, nonzero_address_p, get_integer_term, get_related_value, offset_within_block_p, count_occurrences, reg_mentioned_p, no_labels_between_p, reg_used_between_p, reg_referenced_p, single_set_2, multiple_sets, set_noop_p, refers_to_regno_p, reg_overlap_mentioned_p, dead_or_set_p, covers_regno_no_parallel_p, covers_regno_p, dead_or_set_regno_p, find_reg_note, find_regno_note, find_reg_equal_equiv_note, find_constant_src, find_reg_fusage, find_regno_fusage, pure_call_p, remove_note, in_expr_list_p, remove_node_from_expr_list, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p_1, may_trap_p, may_trap_after_code_motion_p, may_trap_or_fault_p, inequality_comparisons_p, tablejump_p, computed_jump_p_1, computed_jump_p, auto_inc_p, loc_mentioned_in_p, subreg_lsb, subreg_regno, subreg_nregs, label_is_jump_target_p): Likewise. * simplify-rtx.c (neg_const_int, plus_minus_operand_p, mode_signbit_p, simplify_replace_rtx, plus_minus_operand_p): Likewise. * toplev.h (_fatal_insn_not_found, _fatal_insn, error_for_asm, warning_for_asm): Likewise. * tree.h (print_rtl): Likewise. * varasm.c (get_pool_mode): Likewise. From-SVN: r126922
2007-07-23PR middle-end/PR28690Peter Bergner1-19/+13
PR middle-end/PR28690 * optabs.c (expand_binop): (emit_cmp_and_jump_insns): Allow EQ compares. * rtlanal.c (commutative_operand_precedence): Prefer both REG_POINTER and MEM_POINTER operands over REG and MEM operands. (swap_commutative_operands_p): Change return value to bool. * rtl.h: Update the corresponding prototype. * tree-ssa-address.c (gen_addr_rtx): Use simplify_gen_binary instead of gen_rtx_PLUS. * simplify-rtx.c (simplify_plus_minus_op_data_cmp): Change return value to bool. Change function arguments to rtx's and update code to match. (simplify_plus_minus): Update the simplify_plus_minus_op_data_cmp calls to match the new declaration. * simplify-rtx.c (simplify_associative_operation): Don't reorder simplify_binary_operation arguments. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r126852
2007-06-17re PR rtl-optimization/32366 (Segfault in significand_size with ↵Uros Bizjak1-4/+6
-ftree-vectorize) PR rtl-optimization/32366 * simplify-rtx.c (simplify_unary_operation_1) [FLOAT_TRUNCATE, FLOAT_EXTEND]: Prevent non-scalar modes from entering significand_size. testsuite/ChangeLog: PR rtl-optimization/32366 * testsuite/gcc.dg/vect/pr32366.c: New test. From-SVN: r125777
2007-06-12fold-const.c (fold_binary): Guard (X-X) -> 0 transformation with !HONOR_NANS ↵Kaveh R. Ghazi1-2/+6
and !HONOR_INFINITIES. * fold-const.c (fold_binary): Guard (X-X) -> 0 transformation with !HONOR_NANS and !HONOR_INFINITIES. * simplify-rtx.c (simplify_binary_operation_1): Likewise. From-SVN: r125652
2007-04-11re PR middle-end/31530 (Incorrect folding of multiplication and sign change ↵Richard Guenther1-3/+6
when followed by an addition) 2007-04-11 Richard Guenther <rguenther@suse.de> PR middle-end/31530 * simplify-rtx.c (simplify_binary_operation_1): Do not simplify a * -b + c as c - a * b if we honor sign dependent rounding. From-SVN: r123715
2007-03-21rtl.h (constant_pool_reference_p): Delete.Richard Sandiford1-8/+0
gcc/ * rtl.h (constant_pool_reference_p): Delete. (find_constant_src): Declare. * rtlanal.c (find_constant_src): New function. * simplify-rtx.c (constant_pool_reference_p): Delete. * config/i386/i386.md: Use find_constant_src instead of constant_pool_reference_p/avoid_constant_pool_reference pairs. From-SVN: r123106
2007-02-19re PR rtl-optimization/28173 (misses constant folding)Roger Sayle1-0/+39
PR rtl-optimization/28173 * simplify-rtx.c (simplify_binary_operation_1) <IOR>: Optimize (X & C1) | C2 as C2 when (C1 & C2) == C1 and X has no side-effects. Optimize (X & C1) | C2 as X | C2 when (C1 | C2) == ~0. Canonicalize (X & C1) | C2 as (X & (C1 & ~C2)) | C2. <AND>: Canonicalize (X | C1) & C2 as (X & C2) | (C1 & C2). * gcc.target/i386/andor-1.c: New test case. From-SVN: r122116
2007-02-13common.opt: Add Wstrict-overflow and Wstrict-overflow=.Ian Lance Taylor1-2/+18
./: * common.opt: Add Wstrict-overflow and Wstrict-overflow=. * flags.h (warn_strict_overflow): Declare. (enum warn_strict_overflow_code): Define. (issue_strict_overflow_warning): New static inline function. * opts.c (warn_strict_overflow): New variable. (common_handle_option): Handle OPT_Wstrict_overflow and OPT_Wstrict_overflow_. * c-opts.c (c_common_handle_option): Set warn_strict_overflow for OPT_Wall. * fold-const.c: Include intl.h. (fold_deferring_overflow_warnings): New static variable. (fold_deferred_overflow_warning): New static variable. (fold_deferred_overflow_code): New static variable. (fold_defer_overflow_warnings): New function. (fold_undefer_overflow_warnings): New function. (fold_undefer_and_ignore_overflow_warnings): New function. (fold_deferring_overflow_warnings_p): New function. (fold_overflow_warning): New static function. (make_range): Add strict_overflow_p parameter. Change all callers. (extract_muldiv, extract_muldiv_1): Likewise. (fold_unary) [ABS_EXPR]: Check ABS_EXPR before calling tree_expr_nonnegative_p. (fold_negate_expr): Call fold_overflow_warning. (fold_range_test): Likewise. (fold_comparison): Likewise. (fold_binary): Likewise. Call tree_expr_nonnegative_warnv_p instead of tree_expr_nonnegative_p. (tree_expr_nonnegative_warnv_p): Rename from tree_expr_nonnegative_p, add strict_overflow_p parameter. (tree_expr_nonnegative_p): New function. (tree_expr_nonzero_warnv_p): Rename from tree_expr_nonzero_p, add strict_overflow_p parameter. (tree_expr_nonzero_p): New function. * passes.c (verify_interpass_invariants): New static function. (execute_one_pass): Call it. * tree-ssa-loop-niter.c (expand_simple_operations): Ignore fold warnings. (number_of_iterations_exit, loop_niter_by_eval): Likewise. (estimate_numbers_of_iterations): Likewise. (scev_probably_wraps_p): Likewise. * tree-ssa-ccp.c: Include "toplev.h". (evaluate_stmt): Defer fold overflow warnings until we know we are going to optimize. (struct fold_stmt_r_data): Add stmt field. (fold_stmt_r): Defer fold overflow warnings until we know we optimized. (fold_stmt): Initialize stmt field of fold_stmt_r_data. (fold_stmt_inplace): Likewise. * tree-cfgcleanup.c: Include "toplev.h" rather than "errors.h". (cleanup_control_expr_graph): Defer fold overflow warnings until we know we are going to optimize. * tree-cfg.c (fold_cond_expr_cond): Likewise. * tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise. * tree-vrp.c (vrp_expr_computes_nonnegative): Call tree_expr_nonnegative_warnv_p instead of tree_expr_nonnegative_p. * tree-ssa-loop-manip.c (create_iv): Likewise. * c-typeck.c (build_conditional_expr): Likewise. (build_binary_op): Likewise. * tree-vrp.c (vrp_expr_computes_nonzero): Call tree_expr_nonzero_warnv_p instead of tree_expr_nonzero_p. (extract_range_from_unary_expr): Likewise. * simplify-rtx.c (simplify_const_relational_operation): Warn when assuming that signed overflow does not occur. * c-common.c (pointer_int_sum): Ignore fold overflow warnings. * tree.h (tree_expr_nonnegative_warnv_p): Declare. (fold_defer_overflow_warnings): Declare. (fold_undefer_overflow_warnings): Declare. (fold_undefer_and_ignore_overflow_warnings): Declare. (fold_deferring_overflow_warnings_p): Declare. (tree_expr_nonzero_warnv_p): Declare. * doc/invoke.texi (Option Summary): Add -Wstrict-overflow to list of warning options. (Warning Options): Document -Wstrict-overflow. * Makefile.in (tree-ssa-threadedge.o): Depend on toplev.h. (tree-ssa-ccp.o): Likewise. (tree-cfgcleanup.o): Change errors.h dependency to toplev.h. (fold-const.o): Depend on intl.h. testsuite/: * gcc.dg/Wstrict-overflow-1.c: New test. * gcc.dg/Wstrict-overflow-2.c: New test. * gcc.dg/Wstrict-overflow-3.c: New test. * gcc.dg/Wstrict-overflow-4.c: New test. * gcc.dg/Wstrict-overflow-5.c: New test. * gcc.dg/Wstrict-overflow-6.c: New test. * gcc.dg/Wstrict-overflow-7.c: New test. * gcc.dg/Wstrict-overflow-8.c: New test. * gcc.dg/Wstrict-overflow-9.c: New test. * gcc.dg/Wstrict-overflow-10.c: New test. From-SVN: r121895
2007-02-12simplify-rtx.c (simplify_relational_operation_1): Correct typo.Roger Sayle1-1/+1
* simplify-rtx.c (simplify_relational_operation_1): Correct typo. Co-Authored-By: Matt Thomas <matt@3am-software.com> From-SVN: r121839
2007-02-12simplify-rtx.c (simplify_relational_operation_1): Optimize comparisons of ↵Roger Sayle1-0/+29
POPCOUNT against zero. * simplify-rtx.c (simplify_relational_operation_1): Optimize comparisons of POPCOUNT against zero. (simplify_const_relational_operation): Likewise. * gcc.target/ia64/builtin-popcount-1.c: New test case. * gcc.target/ia64/builtin-popcount-2.c: Likewise. From-SVN: r121838
2007-02-08simplify-rtx.c (simplify_unary_operation_1): We can strip zero_extend, bswap ↵Roger Sayle1-5/+84
and rotates from POCOUNT's argument. * simplify-rtx.c (simplify_unary_operation_1) <POPCOUNT>: We can strip zero_extend, bswap and rotates from POCOUNT's argument. <PARITY>: Likewise, we can strip not, bswap, sign_extend, zero_extend and rotates from PARITY's argument. <BSWAP>: A byte-swap followed by a byte-swap is an identity. (simplify_const_unary_operation) <BSWAP>: Evaluate the byte-swap of an integer constant at compile-time. * gcc.target/i386/builtin-bswap-2.c: New test case. From-SVN: r121716
2007-02-03simplify-rtx.c (simplify_relational_operation_1): Implement some ↵Roger Sayle1-19/+59
canonicalization transformations that attempt to simplify... * simplify-rtx.c (simplify_relational_operation_1): Implement some canonicalization transformations that attempt to simplify integer constant comparisons to become comparisons against zero. From-SVN: r121544
2007-01-28common.opt: Add fstrict-overflow.Ian Lance Taylor1-3/+6
./: * common.opt: Add fstrict-overflow. * opts.c (decode_options): Set flag_strict_overflow if -O2. * flags.h (TYPE_OVERFLOW_WRAPS): Define. (TYPE_OVERFLOW_UNDEFINED): Define. (TYPE_OVERFLOW_TRAPS): Define. This replaces TYPE_TRAP_SIGNED. Replace all uses. * tree.h (TYPE_TRAP_SIGNED): Don't define. * fold-const.c (negate_expr_p): Use TYPE_OVERFLOW_UNDEFINED. (fold_negate_expr): Likewise. (make_range): Likewise. (extract_muldiv_1): Likewise. (maybe_canonicalize_comparison): Likewise. (fold_comparison): Likewise. (fold_binary): Likewise. (tree_expr_nonnegative_p): Likewise. (tree_expr_nonzero_p): Likewise. * tree-vrp.c (compare_values): Likewise. (extract_range_from_binary_expr): Likewise. (extract_range_from_unary_expr): Likewise. * tree-ssa-loop-niter.c (infer_loop_bounds_from_signedness): Likewise. (nowrap_type_p): Likewise. * tree-scalar-evolution.c (simple_iv): Likewise. * fold-const.c (negate_expr_p): Use TYPE_OVERFLOW_WRAPS. (build_range_check): Likewise. (extract_muldiv_1): Likewise. (fold_comparison): Likewise. * tree-vrp.c (vrp_int_const_binop): Likewise. (extract_range_from_unary_expr): Likewise. * convert.c (convert_to_integer): Likewise. * fold-const.c (fold_negate_expr): Use TYPE_OVERFLOW_TRAPS. (fold_comparison): Likewise. (fold_binary): Likewise. * optabs.c (optab_for_tree_code): Likewise. * tree-vectorizer.c (vect_is_simple_reduction): Likewise. * simplify-rtx.c (simplify_const_relational_operation): Check flag_strict_overflow and flag_trapv. (simplify_const_relational_operation): Likewise. * doc/invoke.texi (Option Summary): Mention -fstrict-overflow. (Optimize Options): Add -fstrict-overflow to -O2 list. Document -fstrict-overflow. testsuite/: * gcc.dg/strict-overflow-1.c: New test. * gcc.dg/no-strict-overflow-1.c: New test. * gcc.dg/strict-overflow-2.c: New test. * gcc.dg/no-strict-overflow-2.c: New test. * gcc.dg/strict-overflow-3.c: New test. * gcc.dg/no-strict-overflow-3.c: New test. * gcc.dg/strict-overflow-4.c: New test. * gcc.dg/no-strict-overflow-4.c: New test. * gcc.dg/fold-mod-1.c: Add -fstrict-overflow option. * gcc.dg/pr15784-1.c: Likewise. * gcc.dg/pr20922-1.c: Likewise. * gcc.dg/pr20922-3.c: Likewise. * gcc.dg/pr20922-4.c: Likewise. * gcc.dg/pr20922-6.c: Likewise. * gcc.dg/compare-4.c: Likewise. * gcc.dg/torture/pr26898-1.c: Likewise. * gcc.dg/tree-ssa/divide-1.c: Likewise. * gcc.dg/tree-ssa/divide-2.c: Likewise. * gcc.dg/tree-ssa/divide-3.c: Likewise. * gcc.dg/tree-ssa/divide-4.c: Likewise. * gcc.dg/tree-ssa/pr14490-1.c: Likewise. * gcc.dg/tree-ssa/pr14490-3.c: Likewise. * gcc.dg/tree-ssa/pr21082.c: Likewise. * gcc.dg/tree-ssa/pr26899.c: Likewise. * g++.dg/tree-ssa/pr21082.C: Likewise. From-SVN: r121254
2006-12-21simplify-rtx.c (simplify_subreg): Use the correct mode when determining ↵Roger Sayle1-5/+14
whether a SUBREG of a CONCAT refers to... * simplify-rtx.c (simplify_subreg): Use the correct mode when determining whether a SUBREG of a CONCAT refers to the first or second component. From-SVN: r120101
2006-11-30simplify-rtx.c (simplify_rtx): Use simplify_subreg rather than ↵Richard Sandiford1-3/+3
simplify_gen_subreg. gcc/ * simplify-rtx.c (simplify_rtx): Use simplify_subreg rather than simplify_gen_subreg. From-SVN: r119380
2006-11-09simplify-rtx.c (avoid_constant_pool_reference): Avoid calling ↵Andreas Krebbel1-0/+3
simplify_subreg with BLKmode outer mode. 2006-11-09 Andreas Krebbel <krebbel1@de.ibm.com> * simplify-rtx.c (avoid_constant_pool_reference): Avoid calling simplify_subreg with BLKmode outer mode. 2006-11-09 Andreas Krebbel <krebbel1@de.ibm.com> * gcc.dg/20061109-1.c: New testcase. From-SVN: r118622
2006-11-01extend.texi (__builtin_bswap32): Document.Eric Christopher1-1/+3
2006-09-07 Eric Christopher <echristo@apple.com> Falk Hueffner <falk@debian.org> * doc/extend.texi (__builtin_bswap32): Document. (__builtin_bswap64): Ditto. * doc/libgcc.texi (bswapsi2): Document. (bswapdi2): Ditto. * doc/rtl.texi (bswap): Document. * optabs.c (expand_unop): Don't widen a bswap. (init_optabs): Init bswap. Set libfuncs explicitly for bswapsi2 and bswapdi2. * optabs.h (OTI_bswap): New. (bswap_optab): Ditto. * genopinit.c (optabs): Handle bswap_optab. * tree.h (tree_index): Add TI_UINT32_TYPE and TI_UINT64_TYPE. (uint32_type_node): New. (uint64_type_node): Ditto. * tree.c (build_common_tree_nodes_2): Initialize uint32_type_node and uint64_type_node. * builtins.c (expand_builtin_bswap): New. (expand_builtin): Call. (fold_builtin_bswap): New. (fold_builtin_1): Call. * fold-const.c (tree_expr_nonnegative_p): Return true for bswap. * builtin-types.def (BT_UINT32): New. (BT_UINT64): Ditto. (BT_FN_UINT32_UINT32): Ditto. (BT_FN_UINT64_UINT64): Ditto. * builtins.def (BUILT_IN_BSWAP32): New. (BUILT_IN_BSWAP64): Ditto. * rtl.def (BSWAP): New. * genattrtab.c (check_attr_value): New. * libgcc2.c (__bswapSI2): New. (__bswapDI2): Ditto. * libgcc2.h (__bswapSI2): Declare. (__bswapDI2): Ditto. * mklibgcc.in (lib2funcs): Add _bswapsi2 and _bswapdi2. * simplify-rtx.c (simplify_const_unary_operation): Return 0 for BSWAP. * libgcc-std.ver (__bwapsi2): Add. (__bswapdi2): Ditto. * reload1.c (eliminate_regs_1): Add bswap. (elimination_effects): Ditto. * config/i386/i386.h (x86_bswap): New. (TARGET_BSWAP): Use. * config/i386/i386.c (x86_bswap): Set. Co-Authored-By: Falk Hueffner <falk@debian.org> From-SVN: r118361
2006-10-21re PR middle-end/28796 (__builtin_nan() and __builtin_unordered() inconsistent)Richard Guenther1-2/+2
2006-10-21 Richard Guenther <rguenther@suse.de> PR middle-end/28796 * simplify-rtx.c (simplify_const_relational_operation): Do not constant-fold ORDERED and UNORDERED for flag_unsafe_math_optimizations but only we do not need to honor NaNs for the given mode. From-SVN: r117928
2006-09-05re PR rtl-optimization/26847 (Missed optimization in simplify_plus_minus)Paolo Bonzini1-47/+46
2006-09-05 Paolo Bonzini <bonzini@gnu.org> PR rtl-optimization/26847 * simplify-rtx.c (struct simplify_plus_minus_op_data): Remove ix. (simplify_plus_minus_op_data_cmp): For REGs, break ties on the regno. (simplify_plus_minus): Count n_constants while filling ops. Replace qsort with insertion sort. Before going through the array to simplify pairs, sort it. Delay early exit until after the first sort, exiting only if no swaps occurred. Simplify pairs in reversed order, without special-casing the first iteration. Pack ops after simplifying pairs. From-SVN: r116701
2006-08-11re PR middle-end/28651 (signed compare incorrectly false for ↵Richard Guenther1-9/+8
(int)(U+4)<(int)U where U is unsigned INT_MAX (for optimized x86)) 2006-08-11 Richard Guenther <rguenther@suse.de> PR middle-end/28651 * simplify-rtx.c (simplify_const_relational_operation): Simplify A CMP B to A - B CMP 0 only for EQ and NE comparison codes. * gcc.c-torture/execute/pr28651.c: New testcase. From-SVN: r116079
2006-05-30simplify-rtx.c (simplify_binary_operation_1): Cast width to HOST_WIDE_INT to ↵Roger Sayle1-1/+1
avoid comparison warnings on some targets. * simplify-rtx.c (simplify_binary_operation_1) <LSHIFTRT>: Cast width to HOST_WIDE_INT to avoid comparison warnings on some targets. From-SVN: r114248
2006-05-30simplify-rtx.c (simplify_binary_operation): Unfactor the shift and rotate cases.Roger Sayle1-2/+26
* simplify-rtx.c (simplify_binary_operation): Unfactor the shift and rotate cases. <LSHIFTRT>: Optimize (lshiftrt (clz X) C) as (eq X 0) where C is log2(GET_MODE_BITSIZE(X)) on targets with the appropriate semantics. * gcc.target/ppc-eq0-1.c: New test case. * gcc.target/ppc-negeq0-1.c: New test case. From-SVN: r114239
2006-05-29re PR tree-optimization/24964 (Does not optimise abs(x)**2 to x**2)Roger Sayle1-7/+29
PR tree-optimization/24964 * simplify-rtx.c (simplify_binary_operation_1): Add function comment. <MULT>: Minor clean-up. Don't convert x*-1.0 into -x if we honor signaling NaNs. Optimize -x*-x as x*x for all float modes, and abs(x)*abs(x) as x*x for scalar floating point modes. * gcc.target/i386/387-10.c: New test case. From-SVN: r114206
2006-05-23simplify-rtx.c (simplify_subreg): Adjust REG_OFFSET for big-endian ↵Alexandre Oliva1-1/+16
paradoxical subregs. * simplify-rtx.c (simplify_subreg): Adjust REG_OFFSET for big-endian paradoxical subregs. * var-tracking.c (struct micro_operation_def): Document that, for modify micro operations, insn is the subsequent instruction. (var_reg_delete_and_set, var_mem_delete_and_set): Split into... (var_reg_set, var_mem_set): ... new functions. (add_stores): Record subsequent insn. (compute_bb_dataflow): Use new functions for MO_USE. (emit_notes_in_bb): Use new functions for MO_USE. Emit use notes after the insn, and modify notes before the insn known to be the subsequent one. (vt_initialize): Invert sorting of MO_CLOBBERs and MO_SETs. From-SVN: r114013
2006-05-21re PR rtl-optimization/27671 (optimization error on pentium4-Linux with %, ↵Kazu Hirata1-6/+9
regression from gcc-4.1.0) gcc/ PR rtl-optimization/27671 * simplify-rtx.c (simplify_relational_operation_1): Fix simplifications of (eq/ne (xor x y) y) and (eq/ne (xor x y) x). gcc/testsuite/ PR rtl-optimization/27671 * gcc.c-torture/execute/pr27671-1.c: New. * gcc.dg/pr27671-2.c: Likewise. From-SVN: r113955
2006-04-24rtl.def (SS_ASHIFT, SS_NEG): New codes.Bernd Schmidt1-0/+3
* rtl.def (SS_ASHIFT, SS_NEG): New codes. * doc/rtl.texi: Document them. * simplify-rtx.c (simplify_unary_operation, simplify_binary_operation_1): Don't abort when we see them. From-SVN: r113227
2006-04-03simplify-rtx.c (simplify_unary_operation_1): When trying to remove TRUNCATE ↵Adam Nemet1-1/+2
check if all bits outside the new mode are... * simplify-rtx.c (simplify_unary_operation_1) <TRUNCATE>: When trying to remove TRUNCATE check if all bits outside the new mode are identical to the sign bit. From-SVN: r112643