Commit Graph

1274 Commits

Author SHA1 Message Date
Eric Botcazou
4db183a2d5 re PR tree-optimization/44683 (Optimization bug with copysign builtin)
* fold-const.c (invert_tree_comparison): Always invert EQ_EXPR/NE_EXPR.

	PR tree-optimization/44683
	* tree-ssa-dom.c (record_edge_info): Record simple equivalences only if
	we can be sure that there are no signed zeros involved.

From-SVN: r180340
2011-10-23 15:57:09 +00:00
Kai Tietz
bb35fdd04a branch-cost1.c: New test.
* gcc.target/i386/branch-cost1.c: New test.
        * gcc.target/i386/branch-cost2.c: New test.
        * gcc.target/i386/branch-cost3.c: New test.
        * gcc.target/i386/branch-cost4.c: New test.

        * fold-const.c (simple_operand_p_2): Handle integral
        casts from boolean-operands.

From-SVN: r180295
2011-10-21 13:50:42 +02:00
Kai Tietz
6e796a8374 fold-const.c (simple_operand_p_2): New function.
* fold-const.c (simple_operand_p_2): New function.
	(fold_truthop): Rename to
	(fold_truth_andor_1): function name.
	Additionally remove branching creation for logical and/or.
	(fold_truth_andor): Handle branching creation for logical and/or here.

From-SVN: r180109
2011-10-17 22:18:31 +02:00
Richard Guenther
4d8b88e8f2 re PR middle-end/50195 (Linking time error with -fast-math -O0)
2011-10-10  Richard Guenther  <rguenther@suse.de>

	PR middle-end/50195
	* fold-const.c (fold_binary_loc): Canonicalize x*x to pow (x, 2)
	only when optimizing.

	* gcc.dg/builtins-47.c: Optimize.

From-SVN: r179752
2011-10-10 14:25:34 +00:00
Richard Henderson
dca804668a re PR other/49752 (Non-existing struct tree_type' in fold_checksum_tree in fold-const.c, can't build with --enable-checking=fold')
PR 49752
        * fold-const.c (fold_checksum_tree): Remove out-of-date assert.

From-SVN: r179663
2011-10-07 08:35:49 -07:00
Richard Guenther
69c2fbf1ec fold-const.c (fold_ternary_loc): Also fold non-constant vector CONSTRUCTORs.
2011-10-06  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_ternary_loc): Also fold non-constant
	vector CONSTRUCTORs.  Make more efficient.
	* tree-ssa-dom.c (cprop_operand): Don't handle virtual operands.
	(cprop_into_stmt): Don't propagate into virtual operands.
	(optimize_stmt): Really dump original statement.

From-SVN: r179597
2011-10-06 10:34:18 +00:00
Jakub Jelinek
f548a3173e fold-const.c (fold_unary_loc): Don't optimize POINTER_PLUS_EXPR casted to TYPE_RESTRICT pointer by casting the...
* fold-const.c (fold_unary_loc): Don't optimize
	POINTER_PLUS_EXPR casted to TYPE_RESTRICT pointer by
	casting the inner pointer if it isn't TYPE_RESTRICT.
	* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Don't through
	casts from non-TYPE_RESTRICT pointer to TYPE_RESTRICT pointer.

	* gcc.dg/tree-ssa/restrict-4.c: New test.

From-SVN: r179500
2011-10-04 14:34:06 +02:00
Jakub Jelinek
0ccb5dbf93 re PR tree-optimization/46309 (optimization a==3||a==1)
PR tree-optimization/46309
	* fold-const.c (make_range, merge_ranges): Remove prototypes.
	(make_range_step): New function.
	(make_range): Use it.
	* tree.h (make_range_step): New prototypes.
	* Makefile.in (tree-ssa-reassoc.o): Depend on $(DIAGNOSTIC_CORE_H).
	* tree-ssa-reassoc.c: Include diagnostic-core.h.
	(struct range_entry): New type.
	(init_range_entry, range_entry_cmp, update_range_test,
	optimize_range_tests): New functions.
	(reassociate_bb): Call optimize_range_tests.

	* gcc.dg/pr46309.c: New test.

From-SVN: r179388
2011-09-30 17:00:12 +02:00
Richard Guenther
206c3e102a re PR middle-end/50460 (__builtin___strcpy_chk/__builtin_object_size don't work)
2011-09-28  Richard Guenther  <rguenther@suse.de>

	PR middle-end/50460
	* fold-const.c (try_move_mult_to_index): Handle &a.array the
	same as &a.array[0].

From-SVN: r179313
2011-09-28 13:47:12 +00:00
Richard Guenther
5b970a1aaf revert: fold-const.c (extract_muldiv_1): Remove bogus TYPE_IS_SIZETYPE special-casing.
2011-09-05  Richard Guenther  <rguenther@suse.de>

        Revert
        2011-08-31  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (extract_muldiv_1): Remove bogus TYPE_IS_SIZETYPE
	special-casing.

From-SVN: r178523
2011-09-05 07:32:37 +00:00
Richard Guenther
32950a5d85 fold-const.c (extract_muldiv_1): Remove bogus TYPE_IS_SIZETYPE special-casing.
2011-08-31  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (extract_muldiv_1): Remove bogus TYPE_IS_SIZETYPE
	special-casing.

From-SVN: r178377
2011-08-31 11:39:20 +00:00
Artjoms Sinkarovs
544d960a12 20011-08-29 Artjoms Sinkarovs <artyom.shinkaroff@gmail.com>
Richard Guenther  <rguenther@suse.de>

	* tree.h (constant_boolean_node): Adjust prototype.
	* fold-const.c (fold_convert_loc): Move aggregate conversion
	leeway down.
	(constant_boolean_node): Make value parameter boolean, add
	vector type handling.
	(fold_unary_loc): Use constant_boolean_node.
	(fold_binary_loc): Preserve types properly when folding
	COMPLEX_EXPR <__real x, __imag x>.
	* gimplify.c (gimplify_expr): Handle vector comparison.
	* tree.def (EQ_EXPR, ...): Document behavior on vector typed
	comparison.
	* tree-cfg.c (verify_gimple_comparison): Verify vector typed
	comparisons.

From-SVN: r178209
2011-08-29 11:55:45 +00:00
Richard Guenther
e66132e141 fold-const.c (fold_comparison): Fold &a < &a + 4 even with -fno-strict-overflow.
2011-08-24  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_comparison): Fold &a < &a + 4 even
	with -fno-strict-overflow.

From-SVN: r178036
2011-08-24 12:51:45 +00:00
Paolo Carlini
4c9cf7af89 re PR tree-optimization/49963 (ICE: in abs_hwi, at hwint.c:108)
2011-08-18  Paolo Carlini  <paolo.carlini@oracle.com>
	    Joseph Myers  <joseph@codesourcery.com>

	PR tree-optimization/49963
	* hwint.c (absu_hwi): Define.
	* hwint.h (absu_hwi): Declare.
	* fold-const.c (fold_plusminus_mult_expr): Use absu_hwi instead
	of abs_hwi.
	* tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise.
	* tree-ssa-loop-prefetch.c (prune_ref_by_group_reuse): Likewise.

Co-Authored-By: Joseph Myers <joseph@codesourcery.com>

From-SVN: r177848
2011-08-18 11:30:42 +00:00
Richard Guenther
0d82a1c872 tree.h (convert_to_ptrofftype_loc): New function.
2011-08-17  Richard Guenther  <rguenther@suse.de>

	* tree.h (convert_to_ptrofftype_loc): New function.
	(convert_to_ptrofftype): Define.
	* builtins.c (expand_builtin_bzero): Use size_type_node.
	(fold_builtin_bzero): Likewise.
	(std_gimplify_va_arg_expr): Build the BIT_AND_EXPR on the pointer.
	* c-typeck.c (build_unary_op): Use convert_to_ptrofftype_loc.
	* cgraphunit.c (thunk_adjust): Use fold_build_pointer_plus_loc.
	(cgraph_redirect_edge_call_stmt_to_callee): Use size_int.
	* expr.c (expand_expr_addr_expr_1): Use fold_build_pointer_plus.
	* fold-const.c (build_range_check): Negate using the original
	type.
	(fold_unary_loc): Use fold_build_pointer_plus_loc.
	* gimple-fold.c (gimple_adjust_this_by_delta): Use
	convert_to_ptrofftype.
	* gimplify.c (gimplify_self_mod_expr): Likewise.
	* graphite-clast-to-gimple.c (clast_to_gcc_expression): Likewise.
	(graphite_create_new_loop_guard): Likewise.
	* graphite-sese-to-poly.c (my_long_long): Remove.
	(scop_ivs_can_be_represented): Adjust.
	* tree-cfg.c (verify_gimple_assign_unary): Use ptrofftype_p.
	* tree-chrec.c (chrec_fold_plus_1): Use fold_build_pointer_plus.
	* tree-loop-distribution.c (build_size_arg_loc): Use
	size_type_node.
	(generate_memset_zero): Simplify.
	* tree-mudflap.c: Use fold_convert, not convert.
	* tree-predcom.c (suitable_reference_p): Expand DR_OFFSET in
	its own type.
	(determine_offset): Likewise for DR_STEP.
	(valid_initializer_p): Likewise.
	* tree-profile.c (prepare_instrumented_value): Convert the pointer
	to an integer type of same size.
	* tree-scalar-evolution.c (interpret_rhs_expr): Do not refer
	to sizetype without need.
	* tree-ssa-address.c (tree_mem_ref_addr): Likewise.
	* tree-ssa-loop-ivopts.c (find_bivs): Use convert_to_ptrofftype.
	* tree-ssa-loop-manip.c (create_iv): Likewise.
	(determine_exit_conditions): Adjust comment.
	* tree-ssa-pre.c (create_expression_by_pieces): Use
	convert_to_ptrofftype.
	* tree-ssa-structalias.c (get_constraint_for_1): Likewise.
	* varasm.c (array_size_for_constructor): Compute using double_ints.

From-SVN: r177828
2011-08-17 12:00:35 +00:00
Richard Guenther
d510820a47 re PR tree-optimization/50082 (-Wstrict-overflow mishandles typedef)
2011-08-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/50082
	* fold-const.c (maybe_canonicalize_comparison_1): Properly
	convert the modified operand to the other operand type.
	(fold_comparison): Call maybe_canonicalize_comparison_1 with
	useless conversions stripped from comparison operands.

From-SVN: r177762
2011-08-15 15:01:33 +00:00
Uros Bizjak
6c32ee7449 builtins.def (BUILT_IN_ICEIL{,F,L}, [...]): New builtin definitions.
* builtins.def (BUILT_IN_ICEIL{,F,L}, BUILT_IN_IFLOOR{,F,L}
	BUILT_IN_IRINT{,F,L}, BUILT_IN_IROUND{,F,L}: New builtin definitions.
	* convert.c (convert_to_integer): Convert to BUILT_IN_ICEIL,
	BUILT_IN_IFLOOR, BUILT_IN_IRINT or BUILT_INT_IROUND when converting
	to integer_type_node.
	* fold-const.c (tree_call_nonnegative_warnv_p): Handle BUILT_IN_ICEIL,
	BUILT_IN_IFLOOR, BUILT_IN_IRINT and BUILT_INT_IROUND.
	* builtins.c (expand_builtin_in): Ditto.
	(mathfn_built_in_1): Ditto.
	(expand_builtin_int_roundingfn): Handle BUILT_IN_ICEIL and
	BUILT_IN_IFLOOR.
	(expand_builtin_int_roundingfn_2): Handle BUILT_IN_IRINT and
	BUILT_IN_IROUND.
	(fold_fixed_mathfn): Canonicalize BUILT_IN_ICEIL, BUILTIN_IN_IFLOOR
	BUILT_IN_IRINT and BUILT_IN_IROUND to BUILT_IN_LCEIL,
	BUILTIN_IN_LFLOOR, BUILT_IN_LRINT and BUILT_IN_LROUND on ILP32 targets.

testsuite/ChangeLog:

	* gcc.dg/builtins-67.c: New test.
	* gcc.target/i386/conversion.c: Ditto.

From-SVN: r177694
2011-08-12 14:32:41 +02:00
Richard Guenther
a130fb2441 re PR middle-end/49958 (fold performs invalid association)
2011-08-03  Richard Guenther  <rguenther@suse.de>

	PR middle-end/49958
	* fold-const.c (fold_binary_loc): Only associate
	(+ (+ (* a b) c) (* d e)) as (+ (+ (* a b) (* d e)) c) if
	overflow wraps.

        * gcc.dg/torture/pr49958.c: New testcase.

From-SVN: r177270
2011-08-03 13:33:28 +00:00
Paolo Carlini
9f8139900d re PR bootstrap/49914 (call to abs(long long) in gcc/fold-const.c)
2011-08-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR bootstrap/49914
	* fold-const.c (fold_plusminus_mult_expr): Use abs_hwi instead
	of abs.
	* tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise.
	* tree-ssa-loop-prefetch.c (prune_ref_by_group_reuse): Likewise.

From-SVN: r177212
2011-08-02 20:26:57 +00:00
Aldy Hernandez
1169e45d27 params.h (ALLOW_STORE_DATA_RACES): New.
* params.h (ALLOW_STORE_DATA_RACES): New.
	* params.def (PARAM_ALLOW_STORE_DATA_RACES): New.
	* Makefile.in (expr.o): Depend on PARAMS_H.
	* machmode.h (get_best_mode): Add argument.
	* fold-const.c (optimize_bit_field_compare): Add argument to
	get_best_mode.
	(fold_truthop): Same.
	* ifcvt.c (noce_emit_move_insn): Add argument to store_bit_field.
	* expr.c (emit_group_store): Same.
	(copy_blkmode_from_reg): Same.
	(write_complex_part): Same.
	(optimize_bitfield_assignment_op): Add argument.
	Add argument to get_best_mode.
	(get_bit_range): New.
	(expand_assignment): Calculate maxbits and pass it down
	accordingly.
	(store_field): New argument.
	(expand_expr_real_2): New argument to store_field.
	Include params.h.
	* expr.h (store_bit_field): New argument.
	* stor-layout.c (get_best_mode): Restrict mode expansion by taking
	into account maxbits.
	* calls.c (store_unaligned_arguments_into_pseudos): New argument
	to store_bit_field.
	* expmed.c (store_bit_field_1): New argument.  Use it.
	(store_bit_field): Same.
	(store_fixed_bit_field): Same.
	(store_split_bit_field): Same.
	(extract_bit_field_1): Pass new argument to get_best_mode.
	(extract_bit_field): Same.
	* stmt.c (store_bit_field): Pass new argument to store_bit_field.
	* doc/invoke.texi: Document parameter allow-store-data-races.

From-SVN: r176824
2011-07-27 13:22:09 +00:00
Kai Tietz
7f3ff78299 ChangeLog gcc/
2011-07-21  Kai Tietz  <ktietz@redhat.com>

	* fold-const.c (fold_unary_loc): Preserve indirect
	comparison cast to none-boolean type.
	* tree-ssa.c (useless_type_conversion_p): Preserve cast
	from/to boolean-type.
	* gimplify.c (gimple_boolify): Handle boolification
	of comparisons.
	(gimplify_expr): Boolifiy non aggregate-typed
	comparisons.
	* tree-cfg.c (verify_gimple_comparison): Check result
	type of comparison expression.
	* tree-ssa-forwprop.c (forward_propagate_comparison):
	Adjust test of condition result and disallow type-cast
	sinking into comparison.

ChangeLog gcc/testsuite

2011-07-21  Kai Tietz  <ktietz@redhat.com>

	* gcc.dg/tree-ssa/pr30978.c: adjusted.
	* gcc.dg/tree-ssa/ssa-fre-6.c: Likewise.
	* gcc.dg/binop-xor1.c: Set to fail.
	* gcc.dg/binop-xor3.c: Set to fail.

From-SVN: r176563
2011-07-21 14:11:28 +02:00
Richard Guenther
5d49b6a7b2 tree.h (fold_build_pointer_plus_loc): New helper function.
2011-07-19  Richard Guenther  <rguenther@suse.de>

	* tree.h (fold_build_pointer_plus_loc): New helper function.
	(fold_build_pointer_plus_hwi_loc): Likewise.
	(fold_build_pointer_plus): Define.
	(fold_build_pointer_plus_hwi): Likewise.

	* builtins.c (std_gimplify_va_arg_expr): Use fold_build_pointer_plus.
	(fold_builtin_memory_op): Likewise.
	(fold_builtin_stpcpy): Likewise.
	(fold_builtin_memchr): Likewise.
	(fold_builtin_strstr): Likewise.
	(fold_builtin_strchr): Likewise.
	(fold_builtin_strrchr): Likewise.
	(fold_builtin_strpbrk): Likewise.
	(fold_builtin_strcat): Likewise.
	(expand_builtin_memory_chk): Likewise.
	(fold_builtin_memory_chk): Likewise.
	* c-typeck.c (build_unary_op): Likewise.
	* cgraphunit.c (thunk_adjust): Likewise.
	* fold-const.c (build_range_check): Likewise.
	(fold_binary_loc): Likewise.
	* omp-low.c (extract_omp_for_data): Likewise.
	(expand_omp_for_generic): Likewise.
	(expand_omp_for_static_nochunk): Likewise.
	(expand_omp_for_static_chunk): Likewise.
	* tree-affine.c (add_elt_to_tree): Likewise.
	* tree-data-ref.c (split_constant_offset_1): Likewise.
	* tree-loop-distribution.c (generate_memset_zero): Likewise.
	* tree-mudflap.c (mf_xform_derefs_1): Likewise.
	* tree-predcom.c (ref_at_iteration): Likewise.
	* tree-ssa-address.c (tree_mem_ref_addr): Likewise.
	(add_to_parts): Likewise.
	(create_mem_ref): Likewise.
	* tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Likewise.
	* tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne): Likewise.
	(number_of_iterations_le): Likewise.
	* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Likewise.
	* tree-vect-data-refs.c (vect_analyze_data_refs): Likewise.
	(vect_create_addr_base_for_vector_ref): Likewise.
	* tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer): Likewise.
	(vect_create_cond_for_alias_checks): Likewise.
	* tree-vrp.c (extract_range_from_assert): Likewise.

	* config/alpha/alpha.c (alpha_va_start): Likewise.
	(alpha_gimplify_va_arg_1): Likewise.
	* config/i386/i386.c (ix86_va_start): Likewise.
	(ix86_gimplify_va_arg): Likewise.
	* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
	* config/mep/mep.c (mep_expand_va_start): Likewise.
	(mep_gimplify_va_arg_expr): Likewise.
	* config/mips/mips.c (mips_va_start): Likewise.
	(mips_gimplify_va_arg_expr): Likewise.
	* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
	* config/rs6000/rs6000.c (rs6000_va_start): Likewise.
	(rs6000_gimplify_va_arg): Likewise.
	* config/s390/s390.c (s390_va_start): Likewise.
	(s390_gimplify_va_arg): Likewise.
	* config/sh/sh.c (sh_va_start): Likewise.
	(sh_gimplify_va_arg_expr): Likewise.
	* config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.
	* config/spu/spu.c (spu_va_start): Likewise.
	(spu_gimplify_va_arg_expr): Likewise.
	* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_start):
	Likewise.
	(xstormy16_gimplify_va_arg_expr): Likewise.
	* config/xtensa/xtensa.c (xtensa_va_start): Likewise.
	(xtensa_gimplify_va_arg_expr): Likewise.

	c-family/
	* c-common.c (pointer_int_sum): Use fold_build_pointer_plus.
	* c-omp.c (c_finish_omp_for): Likewise.

	cp/
	* call.c (build_special_member_call): Use fold_build_pointer_plus.
	* class.c (build_base_path): Likewise.
	(convert_to_base_statically): Likewise.
	(dfs_accumulate_vtbl_inits): Likewise.
	* cp-gimplify.c (cxx_omp_clause_apply_fn): Likewise.
	* except.c (expand_start_catch_block): Likewise.
	* init.c (expand_virtual_init): Likewise.
	(build_new_1): Likewise.
	(build_vec_delete_1): Likewise.
	(build_vec_delete): Likewise.
	* rtti.c (build_headof): Likewise.
	(tinfo_base_init): Likewise.
	* typeck.c (get_member_function_from_ptrfunc): Likewise.
	(cp_build_addr_expr_1): Likewise.
	* typeck2.c (build_m_component_ref): Likewise.

	fortran/
	* trans-expr.c (fill_with_spaces): Use fold_build_pointer_plus.
	(gfc_trans_string_copy): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_repeat): Likewise.
	* trans-types.c (gfc_get_array_descr_info): Likewise.
	* trans.c (gfc_build_array_ref): Likewise.

	java/
	* builtins.c (static): Use fold_build_pointer_plus.
	* class.c (make_class_data): Likewise.
	(build_symbol_entry): Likewise.
	* except.c (build_exception_object_ref): Likewise.
	* expr.c (build_java_arrayaccess): Likewise.
	(build_field_ref): Likewise.
	(build_known_method_ref): Likewise.
	(build_invokevirtual): Likewise.

	objc/
	* objc-next-runtime-abi-02.c (objc_v2_build_ivar_ref):
	Use fold_build_pointer_plus.
	(objc2_build_ehtype_initializer): Likewise.

From-SVN: r176461
2011-07-19 14:01:59 +00:00
Richard Guenther
fbf3fee2b9 fold-const.c (fold_binary_loc): Convert the !bool_var result...
2011-07-14  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_binary_loc): Convert the !bool_var result,
	not bool_var when folding bool_var != 1 or bool_var == 0.

From-SVN: r176272
2011-07-14 12:42:17 +00:00
Richard Guenther
b862187a34 fold-const.c (fold_binary_loc): Remove index +p PTR -> PTR +p index folding.
2011-07-08  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_binary_loc): Remove index +p PTR -> PTR +p index
	folding.

From-SVN: r176044
2011-07-08 14:08:17 +00:00
Kai Tietz
e8e8c74b49 fold-const.c (fold_truth_andor): Factored out truth_andor label from fold_binary as function.
2011-07-08  Kai Tietz  <ktietz@redhat.com>

        * fold-const.c (fold_truth_andor): Factored out truth_andor
        label from fold_binary as function.
        (fold_binary_loc): Replace truth_andor lable
        by function fold_truth_andor.

From-SVN: r176043
2011-07-08 15:22:52 +02:00
Richard Guenther
bbc210abb5 fold-const.c (fold_unary_loc): Do not strip sign-changes for NEGATE_EXPR.
2011-07-07  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_unary_loc): Do not strip sign-changes
	for NEGATE_EXPR.

	* gcc.dg/ftrapv-3.c: New testcase.

From-SVN: r175976
2011-07-07 14:21:21 +00:00
Richard Sandiford
73f6eabc3a re PR middle-end/49545 (New C++ test failures)
gcc/
	PR tree-optimization/49545
	* builtins.c (get_object_alignment_1): Update function comment.
	Do not use DECL_ALIGN for functions, but test
	TARGET_PTRMEMFUNC_VBIT_LOCATION instead.
	* fold-const.c (get_pointer_modulus_and_residue): Don't check
	for functions here.
	* tree-ssa-ccp.c (get_value_from_alignment): Likewise.

gcc/testsuite/
	* gcc.dg/torture/pr49169.c: Restrict to ARM and MIPS targets.

From-SVN: r175627
2011-06-29 09:42:42 +00:00
Richard Sandiford
afc3f22f90 re PR rtl-optimization/49169 (ARM: optimisations strip the Thumb/ARM mode bit off function pointers)
gcc/
2011-07-24  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/49169
	* fold-const.c (get_pointer_modulus_and_residue): Don't rely on
	the alignment of function decls.

gcc/testsuite/
2011-07-24  Michael Hope  <michael.hope@linaro.org>
	    Richard Sandiford  <richard.sandiford@linaro.org>

	PR tree-optimization/49169
	* gcc.dg/torture/pr49169.c: New test.

From-SVN: r175427
2011-06-27 09:33:06 +00:00
Kai Tietz
a95015b6cd ChangeLog gcc/
2011-06-20  Kai Tietz  <ktietz@redhat.com>

	* fold-const.c (fold_binary_loc): Add missing
	folding for truth-not operations in combination
	with binary and.

ChangeLog gcc/testsuite/

2011-06-20  Kai Tietz  <ktietz@redhat.com>

	* gcc.dg/binop-notand1.c: New test.
	* gcc.dg/binop-notand2.c: New test.
	* gcc.dg/binop-notand3.c: New test.
	* gcc.dg/binop-notand4.c: New test.
	* gcc.dg/binop-notand5.c: New test.
	* gcc.dg/binop-notand6.c: New test.

From-SVN: r175206
2011-06-20 13:49:27 +02:00
Richard Guenther
1243089639 gimple.c (canonicalize_cond_expr_cond): (bool)x is not the same as x != 0.
2011-06-16  Richard Guenther  <rguenther@suse.de>

	* gimple.c (canonicalize_cond_expr_cond): (bool)x is not
	the same as x != 0.
	* fold-const.c (fold_binary_loc): Do not fold X & 1 != 0 to
	(bool) X & 1.
	* ipa-prop.c (ipa_analyze_indirect_call_uses): Also allow
	equality compares against zero for the lower bit.

From-SVN: r175096
2011-06-16 08:41:50 +00:00
Richard Guenther
7871eee372 re PR tree-optimization/49361 (Huge 470.lbm regression)
2011-06-10  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/49361
	* fold-const.c (fold_binary_loc): Only fold x * x to pow (x, 2.0)
	when not already in gimple form.

From-SVN: r174903
2011-06-10 12:19:30 +00:00
Richard Guenther
c2299dfe53 re PR middle-end/49189 (infinite recursion in constant folder)
2011-05-27  Richard Guenther  <rguenther@suse.de>

	PR middle-end/49189
	* fold-const.c (fold_unary_loc): Do not re-fold folding conversions
	of comparisons.

	* gnat.dg/bit_packed_array5.adb: New testcase.
	* gnat.dg/bit_packed_array5.ads: Likewise.

From-SVN: r174330
2011-05-27 13:13:28 +00:00
Richard Biener
f8f972fc7e re PR middle-end/49177 (FAIL: gcc.dg/vect/fast-math-ifcvt-1.c)
2011-05-27  Richard Guenther  <rguenther@suse.de>

	PR middle-end/49177
	* fold-const.c (fold_unary_loc): Fold (T)(A CMP B) to
	A CMP B ? (T) true : (T) false for non-integral types T again.

From-SVN: r174326
2011-05-27 10:32:14 +00:00
Richard Guenther
1f498652b2 fold-const.c (fold_unary_loc): Remove bogus code.
2011-05-26  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_unary_loc): Remove bogus code.

From-SVN: r174290
2011-05-26 13:54:23 +00:00
Tom de Vries
5fb43dd835 re PR middle-end/48689 (ICE in fold-const.c:13798 with fold checking)
2011-05-22  Tom de Vries  <tom@codesourcery.com>

	PR middle-end/48689
	* fold-const.c (fold_checksum_tree): Guard TREE_CHAIN use with
	CODE_CONTAINS_STRUCT (TS_COMMON).

From-SVN: r174035
2011-05-22 19:00:33 +00:00
Eric Botcazou
e4c0337862 fold-const.c (fold_range_test): Pass LOC to build_range_check.
* fold-const.c (fold_range_test): Pass LOC to build_range_check.
	(fold_ternary_loc): Use expr_location_or.

From-SVN: r173588
2011-05-09 18:36:31 +00:00
Eric Botcazou
c99c002630 langhooks.h (lang_hooks_for_types): Change global_bindings_p's return type to bool and adjust comment.
2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>

	* langhooks.h (lang_hooks_for_types): Change global_bindings_p's return
	type to bool and adjust comment.
	* fold-const.c (fold_range_test): Adjust call to global_bindings_p.
	(fold_mathfn_compare): Remove calls to global_bindings_p.
	(fold_inf_compare): Likewise.
	* stor-layout.c (variable_size): Adjust call to global_bindings_p.
	* c-tree.h (global_bindings_p): Adjust prototype.
	* c-decl.c (global_bindings_p): Return bool and simplify.
ada/
	* gcc-interface/gigi.h (global_bindings_p): Adjust prototype.
	* gcc-interface/utils.c (global_bindings_p): Return bool and simplify.
cp/
	* name-lookup.h (global_bindings_p): Adjust prototype.
	* name-lookup.c (global_bindings_p): Return bool.
fortran/
	* f95-lang.c (global_bindings_p): Return bool and simplify.
go/
	* go-lang.c (global_bindings_p): Return bool and simplify.
java/
	* java-tree.h (global_bindings_p): Adjust prototype.
	* decl.c (global_bindings_p): Return bool.
lto/
	* lto-lang.c (global_bindings_p): Return bool.

From-SVN: r173535
2011-05-07 19:58:29 +00:00
Richard Guenther
d35936ab70 tree.h (int_const_binop): Remove notrunc argument.
2011-05-04  Richard Guenther  <rguenther@suse.de>

	* tree.h (int_const_binop): Remove notrunc argument.
	* fold-const.c (int_const_binop): Remove notrunc argument.  Always
	create integer constants that are properly truncated.
	(extract_muldiv_1): Expand one notrunc int_const_binop caller.
	(const_binop): Remove zero notrunc argument to int_const_binop.
	(size_binop_loc): Likewise.
	(fold_div_compare): Likewise.
	(maybe_canonicalize_comparison_1): Likewise.
	(fold_comparison): Likewise.
	(fold_binary_loc): Likewise.
	(multiple_of_p): Likewise.
	* expr.c (store_constructor): Likewise.
	* gimple-fold.c (maybe_fold_offset_to_array_ref): Likewise.
	(maybe_fold_stmt_addition): Likewise.
	* ipa-prop.c (ipa_modify_call_arguments): Likewise.
	* stor-layout.c (layout_type): Likewise.
	* tree-data-ref.c (tree_fold_divides_p): Likewise.
	* tree-sra.c (build_ref_for_offset): Likewise.
	(build_user_friendly_ref_for_offset): Likewise.
	* tree-ssa-address.c (maybe_fold_tmr): Likewise.
	* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Likewise.
	* tree-ssa-loop-niter.c (inverse): Likewise.
	* tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise.
	* tree-ssa.c (maybe_rewrite_mem_ref_base): Likewise.
	* tree-switch-conversion.c (check_range): Likewise.
	(build_constructors): Likewise.
	* tree-vect-generic.c (expand_vector_piecewise): Likewise.
	* tree-vrp.c (set_and_canonicalize_value_range): Likewise.
	(extract_range_from_assert): Likewise.
	(vrp_int_const_binop): Likewise.
	(extract_range_from_binary_expr): Likewise.
	(extract_range_from_unary_expr): Likewise.
	(check_array_ref): Likewise.
	(find_case_label_range): Likewise.
	(simplify_div_or_mod_using_ranges): Likewise.
	* tree-cfg.c (group_case_labels_stmt): Use double-ints for
	comparing case labels for merging.


	ada/
	* gcc-interface/trans.c (gnat_to_gnu): Remove zero notrunc argument to
	int_const_binop.
	(pos_to_constructor): Likewise.

	fortran/
	* trans-types.c (gfc_get_array_type_bounds): Remove zero notrunc
	argument to int_const_binop.

From-SVN: r173356
2011-05-04 09:04:53 +00:00
Richard Guenther
9f616812d9 tree-inline.c (remap_eh_region_tree_nr): Use integer_type_node for the remapped region number.
2011-04-29  Richard Guenther  <rguenther@suse.de>

	* tree-inline.c (remap_eh_region_tree_nr): Use integer_type_node
	for the remapped region number.
	* predict.c (build_predict_expr): Use integer_type_node for the
	predict kind.
	* fold-const.c (fold_binary_loc): Use integer_type_node for
	the shift amount.  Use a proper type for the PLUS_EXPR operand.

From-SVN: r173156
2011-04-29 13:11:18 +00:00
Richard Guenther
ad0e2567d6 re PR tree-optimization/48694 (possible memory hog bug)
2011-04-26  Richard Guenther  <rguenther@suse.de>

	PR middle-end/48694
	* tree.h (OEP_CONSTANT_ADDRESS_OF): New operand_equal_flag.
	* fold-const.c (operand_equal_p): For TREE_CONSTANT ADDR_EXPRs
	compare the operands with OEP_CONSTANT_ADDRESS_OF.  Treat
	trees with TREE_SIDE_EFFECTS equal when OEP_CONSTANT_ADDRESS_OF
	is set.

	* gcc.dg/torture/pr48694-1.c: New testcase.
	* gcc.dg/torture/pr48694-2.c: Likewise.

From-SVN: r172954
2011-04-26 09:21:44 +00:00
Jakub Jelinek
16997bc011 re PR c/48685 (ICE in gimplify_expr, at gimplify.c:7034)
PR c/48685
	* fold-const.c (fold_convert_loc): Add NOP_EXPR when casting
	to VOID_TYPE even around MODIFY_EXPR.

	* gcc.dg/pr48685.c: New test.

From-SVN: r172895
2011-04-23 12:18:03 +02:00
Kai Tietz
583722ee58 ChangeLog gcc/
2011-04-20  Kai Tietz  <ktietz@redhat.com>

	* fold-const.c (fold_binary_loc): Add handling for
	(X & ~Y) | (~X & Y) and (X && !Y) | (!X && Y) optimization
	to (X ^ Y).

ChangeLog gcc/testsuite

2011-04-20  Kai Tietz  <ktietz@redhat.com>

	* gcc.dg/binio-xor1.c: New test.
	* gcc.dg/binio-xor2.c: New test.
	* gcc.dg/binio-xor3.c: New test.
	* gcc.dg/binio-xor4.c: New test.
	* gcc.dg/binio-xor5.c: New test.

From-SVN: r172776
2011-04-20 18:16:28 +02:00
Richard Guenther
daade2060c tree.h (get_object_alignment_1): Declare.
2011-04-14  Richard Guenther  <rguenther@suse.de>

	* tree.h (get_object_alignment_1): Declare.
	* builtins.c (get_object_alignment_1): Split out worker from ...
	(get_object_alignment): ... here.
	* fold-const.c (get_pointer_modulus_and_residue): Use
	get_object_alignment_1.

	* gcc.dg/fold-bitand-4.c: Move ...
	* c-c++-common/fold-bitand-4.c: ... here.  Adjust slightly.

From-SVN: r172424
2011-04-14 12:07:57 +00:00
Jakub Jelinek
8a87e7abcb re PR c/48305 (ice at -O0: verify_gimple failed)
PR c/48305
	* fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: Make sure
	arg10/arg11 in (X ^ Y) == (Z ^ W) are always fold converted to
	matching arg00/arg01 types.

	* gcc.c-torture/compile/pr48305.c: New test.

From-SVN: r171723
2011-03-30 14:36:18 +02:00
Nathan Froyd
6c4e299723 fold-const.c (expr_location_or): New function.
* fold-const.c (expr_location_or): New function.
	(fold_truth_not_expr): Call it.

From-SVN: r171468
2011-03-25 16:53:14 +00:00
Eric Botcazou
fe784e0dd8 fold-const.c (fold_ternary_loc): Preserve the location (if any) of the argument in calls to fold_truth_not_expr.
* fold-const.c (fold_ternary_loc): Preserve the location (if any) of
	the argument in calls to fold_truth_not_expr.

From-SVN: r171403
2011-03-24 16:15:22 +00:00
Richard Guenther
0b0081eca4 re PR tree-optimization/48149 (Piecewise complex pass-through not optimized)
2011-03-16  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/48149
	* fold-const.c (fold_binary_loc): Fold
	COMPLEX_EXPR <REALPART_EXPR <x>, IMAGPART_EXPR <x>>.

	* gcc.dg/fold-complex-1.c: New testcase.

From-SVN: r171048
2011-03-16 15:55:48 +00:00
Jakub Jelinek
29f10e7178 re PR middle-end/48136 (verify_gimple failed at -O0)
PR middle-end/48136
	* fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: Make sure
	arg0/arg1 or their arguments are always fold converted to matching
	types.

	* gcc.c-torture/compile/pr48136.c: New test.

From-SVN: r171041
2011-03-16 11:24:44 +01:00
Richard Guenther
17dea42fc4 re PR tree-optimization/48031 (gcc.c-torture/compile/pr42956.c ICEs gcc on m68k-linux, ivopts related?)
2011-03-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/48031
	* fold-const.c (fold_indirect_ref_1): Do not create new variable-sized
	or variable-indexed array accesses when in gimple form.

From-SVN: r170983
2011-03-15 09:49:33 +00:00
Jakub Jelinek
2e64f8b8f6 re PR middle-end/38878 (gcc.dg/tree-ssa/foldaddr-1.c XFAILed)
PR middle-end/38878
	* fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: Add
	STRIP_NOPS on arg0 and arg1.  When optimizing X +- C == X
	and C - X == X also strip nops from +/-/p+ operand.
	When optimizing -X == C, fold C to arg0's type.

	* gcc.dg/tree-ssa/foldaddr-1.c: Remove xfail.

From-SVN: r170957
2011-03-14 21:12:16 +01:00