summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
Commit message (Collapse)AuthorAgeFilesLines
* re PR middle-end/30172 (Operations with partly constant complex values not ↵Richard Guenther2006-12-141-0/+57
| | | | | | | | | | | | | | | folded) 2006-12-14 Richard Guenther <rguenther@suse.de> PR middle-end/30172 * fold-const.c (fold_binary): Fold __complex__ ( x, 0 ) + __complex__ ( 0, y ) to __complex__ ( x, y ). Fold __complex__ (x, y) * +-I to __complex__ (-+y, +-x). * gcc.dg/pr30172-1.c: New testcase. From-SVN: r119859
* re PR middle-end/30198 (__real / __imag cexpi (x) can be folded to cos (x) / ↵Richard Guenther2006-12-141-0/+26
| | | | | | | | | | | | | | sin (x)) 2006-12-14 Richard Guenther <rguenther@suse.de> PR tree-optimization/30198 * fold-const.c (fold_unary): Fold REALPART_EXPR of cexpi to cos. Fold IMAGPART_EXPR of cexpi to sin. * gcc.dg/builtins-60.c: New testcase. From-SVN: r119858
* re PR middle-end/28436 (accessing an element via a "pointer" on a vector ↵Andrew Pinski2006-12-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | does not cause vec_extract to be used) 2006-12-12 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/28436 * tree.h (DECL_COMPLEX_GIMPLE_REG_P): Rename to ... (DECL_GIMPLE_REG_P): This. * fold-const.c (fold_indirect_ref_1): Fold *(foo *)&vectorfoo into using BIT_FIELD_REF. * omp-low.c (omp_copy_decl_2): Use the renamed DECL_GIMPLE_REG_P. * tree-gimple.c (is_gimple_reg): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. * expr.c (get_inner_reference): Set the mode for BIT_FIELD_REF with vector types. * tree-flow-inline.h (var_can_have_subvars): Use the renamed DECL_GIMPLE_REG_P. * gimplify.c (internal_get_tmp_var): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. (gimplify_bind_expr): Likewise. (gimplify_function_tree): Likewise. * expmed.c: Include target.h. (extract_bit_field): For vector mode, try find a better mode first. If that fails use gen_lowpart (for vectors only). * tree-dfa.c (make_rename_temp): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. * tree-ssa-pre.c (create_expressions_by_pieces): Likewise. (insert_into_preds_of_block): Likewise. (insert_fake_stores): Create gimple register store_tmps for vector types. * tree-sra.c (sra_elt): New field, is_vector_lhs. (sra_walk_expr <case BIT_FIELD_REF>): For vector types that are the left hand side, set the element's is_vector_lhs to true. (instantiate_element): For vector types which were on the left hand size, set DECL_GIMPLE_REG_P to false. * tree-nested.c (create_tmp_var_for): Use the renamed DECL_GIMPLE_REG_P. * tree-inline.c (declare_return_variable): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. (copy_decl_to_var): Use the renamed DECL_GIMPLE_REG_P. (copy_result_decl_to_var): Likewise. * tree-vect-transform.c (vect_get_new_vect_var): For vector types, create a gimple register variable. (vect_permute_store_chain): Set DECL_GIMPLE_REG_P to true for the vect_inter_* temp variables. * Makefile.in (expmed.o): Update dependencies. 2006-12-12 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/28436 * gcc.c-torture/compile/vector-1.c: New test. * gcc.c-torture/compile/vector-2.c: New test. * gcc.c-torture/compile/vector-3.c: New test. From-SVN: r119801
* re PR middle-end/30147 (ICE in fold_convert with -O2)Richard Guenther2006-12-121-1/+3
| | | | | | | | | | | | 2006-12-12 Richard Guenther <rguenther@suse.de> PR middle-end/30147 * fold-const.c (fold_read_from_constant_string): Only fold read from constant string if the result type is integer. * gfortran.fortran-torture/compile/pr30147.f90: New testcase. From-SVN: r119776
* Merge gimple-tuples-branch into mainline.Aldy Hernandez2006-12-051-13/+25
| | | | From-SVN: r119546
* builtins.c, [...]: Fix comment typos.Kazu Hirata2006-12-021-2/+2
| | | | | | | | | | | | | | | | | * builtins.c, cfgloop.h, cgraph.h, config/arm/arm.c, config/i386/i386.c, config/i386/i386.h, config/mips/mips.h, config/rs6000/cell.md, config/rs6000/rs6000.c, config/sh/sh.c, config/sh/sh4-300.md, config/spu/spu-builtins.def, config/spu/spu-c.c, config/spu/spu-modes.def, config/spu/spu.c, config/spu/spu.md, config/spu/spu_internals.h, config/spu/vmx2spu.h, fold-const.c, fwprop.c, predict.c, tree-data-ref.h, tree-flow.h, tree-ssa-loop-manip.c, tree-ssa-loop-niter.c, tree-ssa-pre.c, tree-vect-analyze.c, tree-vect-transform.c, tree-vectorizer.c, tree-vrp.c: Fix comment typos. Follow spelling conventions. From-SVN: r119442
* fold-const.c (fold_binary): Use the precision of the type instead of the ↵Eric Botcazou2006-12-011-14/+19
| | | | | | | | | | | size of its mode to compute the... * fold-const.c (fold_binary) <LT_EXPR>: Use the precision of the type instead of the size of its mode to compute the highest and lowest possible values. Still check the size of the mode before flipping the signedness of the comparison. From-SVN: r119422
* re PR tree-optimization/29921 (internal compiler error: in ↵Zdenek Dvorak2006-11-221-2/+13
| | | | | | | | | | | | set_lattice_value, at tree-ssa-ccp.c:437) PR tree-optimization/29921 * fold-const.c (operand_equal_p): Without HONOR_SIGNED_ZEROS, consider signed and unsigned zero equal. * gcc.dg/pr29921.c: New test. From-SVN: r119102
* fold-const.c (fold_strip_sign_ops): Handle copysign.Kaveh R. Ghazi2006-11-181-7/+22
| | | | | | | | | * fold-const.c (fold_strip_sign_ops): Handle copysign. testsuite: * gcc.dg/builtins-20.c: Add cases for copysign. From-SVN: r118975
* re PR tree-optimization/29788 (ICE in var_ann, at tree-flow-inline.h:130)Andrew Pinski2006-11-151-0/+3
| | | | | | | | | | | | | | | | 2006-11-15 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/29788 * fold-const.c (fold_indirect_ref_1): Fold *&CONST_DECL down to what is the const decl is a place holder for. 2006-11-15 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/29788 * gfortran.fortran-torture/compile/inline_1.f90: New testcase. From-SVN: r118861
* fold-const.c (fold_strip_sign_ops): Handle COMPOUND_EXPR and COND_EXPR.Kaveh R. Ghazi2006-11-141-0/+16
| | | | | | | | | | * fold-const.c (fold_strip_sign_ops): Handle COMPOUND_EXPR and COND_EXPR. testsuite: * gcc.dg/builtins-20.c: Add more cases. From-SVN: r118802
* fold-const.c (optimize_bit_field_compare): Recursively call fold when ↵Roger Sayle2006-11-131-9/+13
| | | | | | | | | simplifying non-constant comparisons between bit-fields. * fold-const.c (optimize_bit_field_compare): Recursively call fold when simplifying non-constant comparisons between bit-fields. From-SVN: r118783
* fold-const.c (negate_expr_p): Correct/refine condition for transformations.Roger Sayle2006-11-131-4/+8
| | | | | | | | | * fold-const.c (negate_expr_p) <PLUS_EXPR, MINUS_EXPR>: Correct/refine condition for transformations. Use !HONOR_SIGN_DEPENDENT_ROUNDING && !HONOR_SIGNED_ZEROS instead of flag_unsafe_math_optimizations. (fold_negate_expr) <PLUS_EXPR, MINUS_EXPR>: Likewise. From-SVN: r118744
* builtins.c (fold_builtin_cosh): New.Kaveh R. Ghazi2006-11-121-1/+11
| | | | | | | | | | | | | * builtins.c (fold_builtin_cosh): New. (fold_builtin_1): Use it. * fold-const.c (negate_mathfn_p): Add llround, lround, round, trunc to the list of "odd" functions. Also add llrint, lrint, rint and nearbyint when flag_rounding_math is false. testsuite: * gcc.dg/torture/builtin-symmetric-1.c: Add more cases. From-SVN: r118733
* re PR tree-optimization/13827 ((a & b) != (c & b) should be transformed to ↵Roger Sayle2006-11-121-0/+43
| | | | | | | | | | | | ((a^c) & b) !=0) PR tree-optimization/13827 * fold-const.c (fold_binary) <EQ_EXPR, NE_EXPR>: Fold (X&C) op (Y&C) as ((X^Y)&C) op 0. * gcc.dg/fold-eqand-1.c: New test case. From-SVN: r118727
* fold-const.c (int_binop_types_match_p): New function.Roger Sayle2006-11-121-26/+63
| | | | | | | | | | | | | | | | | | * fold-const.c (int_binop_types_match_p): New function. (size_binop): Relax constraint that both arguments must both have exactly the same sizetype type. Instead use int_binop_types_match_p. (size_diffop): Likewise. (make_range): Use build_int_cst instead of fold_convert. (fold_cond_expr_with_comparison): Use build_int_cst to construct integer constants of the correct type. (fold_div_compare): Likewise. (fold_single_bit_test): Likewise. (fold_binary): Likewise. * stor-layout.c (layout_type) <VECTOR_TYPE>: Ensure that TYPE_SIZE has type bitsizetype and TYPE_SIZE_UNIT has type sizetype. From-SVN: r118718
* tree.def (FIX_CEIL_EXPR, [...]): Remove unused tree codes.Richard Guenther2006-11-111-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2006-11-11 Richard Guenther <rguenther@suse.de> * tree.def (FIX_CEIL_EXPR, FIX_FLOOR_EXPR, FIX_ROUND_EXPR): Remove unused tree codes. * tree-vrp.c (extract_range_from_unary_expr): Remove handling of FIX_CEIL_EXPR, FIX_FLOOR_EXPR and FIX_ROUND_EXPR. * tree-pretty-print.c (dump_generic_node, op_prio): Likewise. * tree.c (stabilize_reference): Likewise. * fold-const.c (fold_convert_const_int_from_real, operand_equal_p, fold_unary): Likewise. * tree-gimple.c (is_gimple_cast): Likewise. * dwarf2out.c (loc_descriptor_from_tree_1): Likewise. * expr.c (expand_expr_real_1): Likewise. * tree-eh.c (tree_could_trap_p): Likewise. * gimplify.c (gimplify_expr): Likewise. * tree-inline.c (estimate_num_insns_1): Likewise. * tree-cfg.c (verify_expr): Likewise. cp/ * typeck.c (build_unary_op): Likewise. java/ * check-init.c (check_init): Likewise. ada/ * trans.c (maybe_stabilize_reference): Likewise. fortran/ * trans-intrinsic.c (enum rounding_mode): New enum. (build_fix_expr, gfc_conv_intrinsic_aint, gfc_conv_intrinsic_mod, gfc_conv_intrinsic_function): Use it instead of FIX_CEIL_EXPR, FIX_FLOOR_EXPR, FIX_ROUND_EXPR and FIX_TRUNC_EXPR. From-SVN: r118692
* fold-const.c (operand_equal_p): Don't check for TREE_CONSTANT_OVERFLOW when ↵Roger Sayle2006-11-111-11/+3
| | | | | | | | | comparing constants. * fold-const.c (operand_equal_p) <INTEGER_CST, REAL_CST, VECTOR_CST>: Don't check for TREE_CONSTANT_OVERFLOW when comparing constants. From-SVN: r118685
* builtins.c (fold_builtin_cos): Use fold_strip_sign_ops().Kaveh R. Ghazi2006-11-111-0/+11
| | | | | | | | | | | * builtins.c (fold_builtin_cos): Use fold_strip_sign_ops(). (fold_builtin_hypot): Likewise. * fold-const.c (fold_strip_sign_ops): Handle "odd" builtins. testsuite: * gcc.dg/builtins-20.c: Add more cases for stripping sign ops. From-SVN: r118683
* fold-const.c (negate_mathfn_p): Add BUILT_IN_ERF.Kaveh R. Ghazi2006-11-111-0/+1
| | | | | | | | | * fold-const.c (negate_mathfn_p): Add BUILT_IN_ERF. testsuite: * gcc.dg/torture/builtin-symmetric-1.c: New test. From-SVN: r118682
* re PR middle-end/29726 (invalid folding of ((X >> C1) & C2) != 0 or "M-x is ↵Serge Belyshev2006-11-091-1/+1
| | | | | | | | | | | | | | | | undefined" in emacs) 2006-11-09 Serge Belyshev <belyshev@depni.sinp.msu.ru> PR middle-end/29726 * fold-const.c (fold_binary) <EQ_EXPR>: Fix typo in variable name. * gcc.dg/fold-eqandshift-1.c (test5): Uncomment function. (test6): Ditto. (dg-final): Add scan-tree-dump-times patterns for test5 and test6. * gcc.dg/fold-eqandshift-3.c: New test case. From-SVN: r118625
* tree-ssa-propagate.c (set_rhs): Restructure validity tests as a test for ↵Roger Sayle2006-11-081-7/+1
| | | | | | | | | | | | | | | inclusion rather than as a test for... * tree-ssa-propagate.c (set_rhs): Restructure validity tests as a test for inclusion rather than as a test for exclusion. * tree-ssa-ccp.c (fold_stmt_r) <COND_EXPR>: Use set_rhs to modify the condition after calling fold_binary. * fold-const.c (fold_inf_compare): Remove in_gimple_form check. (fold_binary) <LT_EXPR, GT_EXPR, LE_EXPR, GE_EXPR>: Likewise. * builtins.c (fold_builtin_isascii): Likewise. (fold_builtin_isdigit): Likewise. From-SVN: r118593
* re PR middle-end/29695 (Folding breaks (a & 0x80) ? 0x80 : 0 for unsigned ↵Jakub Jelinek2006-11-051-7/+70
| | | | | | | | | | | | | char or unsigned short a) PR middle-end/29695 * fold-const.c (fold_ternary): Fix A < 0 ? <sign bit of A> : 0 simplification. * gcc.c-torture/execute/pr29695-1.c: New test. * gcc.c-torture/execute/pr29695-2.c: New test. From-SVN: r118497
* extend.texi (__builtin_bswap32): Document.Eric Christopher2006-11-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* re PR middle-end/23470 (a*a (for floats) is not considered always postive ↵Roger Sayle2006-11-011-13/+44
| | | | | | | | | | | | | | (-ffast-math only)) PR middle-end/23470 * tree.h (tree_expr_nonnegative_p): Return "bool" instead of "int". * fold-const.c (tree_expr_nonnegative_p): Likewise. Consider pow(x,y) and powi(x,y) to be nonnegative if either x is nonnegative or y is an even integer. * gcc.dg/pr23470-1.c: New test case. From-SVN: r118355
* fold-const.c (fold_comparison): Fold ~X op ~Y as Y op X.Roger Sayle2006-10-291-7/+22
| | | | | | | | | | | * fold-const.c (fold_comparison): Fold ~X op ~Y as Y op X. Fold ~X op C as X op' ~C, where op' is the swapped comparison. (fold_binary): ~X eq/ne C is now handled in fold_comparison. Fold -X eq/ne -Y as X eq/ne Y. * gcc.dg/fold-compare-1.c: New test case. From-SVN: r118158
* re PR tree-optimization/15458 (Combine ~ and ^.)Roger Sayle2006-10-291-0/+7
| | | | | | | | | | PR tree-optimization/15458 * fold-const.c (fold_binary): Optimize ~X ^ C as X ^ ~C, where C is a constant. * gcc.dg/fold-xornot-1.c: New test case. From-SVN: r118152
* fold-const.c (maybe_canonicalize_comparison): Fix code to match comment.Richard Guenther2006-10-281-1/+1
| | | | | | | | | 2006-10-28 Richard Guenther <rguenther@suse.de> * fold-const.c (maybe_canonicalize_comparison): Fix code to match comment. From-SVN: r118110
* re PR middle-end/26899 (Fold does not fold (i0 > i1 + 1) || (i1 < i0 - 1))Richard Guenther2006-10-281-0/+124
| | | | | | | | | | | | | | | | 2006-10-28 Richard Guenther <rguenther@suse.de> PR middle-end/26899 * fold-const.c (maybe_canonicalize_comparison_1): Helper for maybe_canonicalize_comparison. (maybe_canonicalize_comparison): New function for canonicalizing comparison trees. (fold_comparison): Call it to canonicalize comparisons with constants involved. * gcc.dg/tree-ssa/pr26899.c: New testcase. From-SVN: r118106
* [multiple changes]Richard Guenther2006-10-231-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | 2006-10-24 Richard Guenther <rguenther@suse.de> PR middle-end/27132 PR middle-end/23295 * builtins.c (fold_binary): Remove checks for flag_wrapv and flag_trapv where negate_expr_p covers these cases. * gcc.dg/pr27132.c: New testcase. * gcc.dg/pr23295.c: Likewise. * gcc.dg/tree-ssa/pr23294.c: Adjust patterns. * g++.dg/tree-ssa/pr19807.C: Likewise. 2006-10-23 Richard Guenther <rguenther@suse.de> PR middle-end/29548 * fold-const.c (fold_plusminus_mult_expr): Check exact power of two on the absolute value. (fold_binary): Fold x * -C to -x * C if x is easily negatable and negating -C does not overflow. From-SVN: r117969
* re PR middle-end/26898 (Fold does not fold signed + CST1 CMP signed + CST2)Richard Guenther2006-10-211-0/+42
| | | | | | | | | | | | | 2006-10-21 Richard Guenther <rguenther@suse.de> PR middle-end/26898 * fold-const.c (fold_comparison): Fold signed comparisons of the form X +- C1 CMP Y +- C2. * gcc.dg/torture/pr26898-1.c: New testcase. * gcc.dg/torture/pr26898-2.c: Likewise. From-SVN: r117931
* fold-const.c (add_double): Rename to add_double_with_sign.Eric Botcazou2006-10-191-22/+35
| | | | | | | | | | | | | | | | * fold-const.c (add_double): Rename to add_double_with_sign. Add 'unsigned_p' parameter and take it into account for the overflow. (mul_double): Rename to mul_double_with_sign. Add 'unsigned_p' parameter and take it into account for the overflow. (fold_div_compare): Call add_double_with_sign instead of add_double and mul_double_with_sign instead of mul_double, passing them the unsignedness of the type. * tree.h (add_double): Macroize. (add_double_with_sign): New prototype. (mul_double): Macroize. (mul_double_with_sign): New prototype. From-SVN: r117887
* re PR middle-end/28814 (in compare_values, at tree-vrp.c:415)Richard Guenther2006-08-251-1/+2
| | | | | | | | | | | | 2006-08-26 Richard Guenther <rguenther@suse.de> PR middle-end/28814 * fold-const.c (fold_binary): Fold temporary to correct type before constructing new comparison. * gcc.dg/torture/pr28814.c: New testcase. From-SVN: r116439
* re PR middle-end/28268 (ICE with simple vector operations)Richard Guenther2006-07-071-2/+2
| | | | | | | | | | | | | | | 2006-07-07 Richard Guenther <rguenther@suse.de> PR middle-end/28268 * tree.h (build_one_cst): Declare. * tree.c (build_one_cst): New function. * tree-ssa-math-opts.c (get_constant_one): Remove. (insert_reciprocals): Use build_one_cst. * fold-const.c (fold_plusminus_mult): Likewise. * gcc.dg/torture/pr28268.c: New testcase. From-SVN: r115263
* re PR tree-optimization/28162 (ICE in set_value_range, at tree-vrp.c:157)Richard Guenther2006-07-051-4/+4
| | | | | | | | | | | | 2006-07-05 Richard Guenther <rguenther@suse.de> PR tree-optimization/28162 * fold-const.c (fold_binary): For (-A) * (-B) -> A * B make sure to convert the operands to the correct type. * gcc.dg/pr28162.c: New testcase. From-SVN: r115202
* re PR middle-end/28151 (ICE with complex math)Eric Botcazou2006-06-251-48/+34
| | | | | | | | PR middle-end/28151 * fold-const.c (const_binop): Be prepared for self returning zero. Simplify code handling complex values. From-SVN: r114992
* expr.c (expand_expr_real_1): For vector constants with integer modes...Roger Sayle2006-06-201-7/+5
| | | | | | | | | | | | | | * expr.c (expand_expr_real_1) <VECTOR_CST>: For vector constants with integer modes, attempt to directly construct an integer constant. * fold-const.c (native_encode_vector): Determine the size of each element from the vector type instead of the first vector element. * tree.c (build_constructor_single): Mark a CONSTRUCTOR as constant, if all of its elements/components are constant. (build_constructor_from_list): Likewise. From-SVN: r114815
* re PR middle-end/28045 (Bitfield, &&, and optimization => bad code generation)Richard Guenther2006-06-191-0/+5
| | | | | | | | | | | | 2006-06-19 Richard Guenther <rguenther@suse.de> PR middle-end/28045 * fold-const.c (operand_equal_p): Check if the argument types have the same precision before stripping NOPs. * gcc.dg/torture/pr28045.c: New testcase. From-SVN: r114772
* re PR middle-end/27116 (Incorrect integer division (wrong sign).)Richard Guenther2006-06-161-50/+54
| | | | | | | | | | | | | | | | | | | | | 2006-06-16 Richard Guenther <rguenther@suse.de> PR middle-end/27116 * fold-const.c (negate_expr_p): Do not introduce undefined overflow in negating INTEGER_CSTs. (fold_negate_expr): Rename from negate_expr. Revert last change for folding BIT_NOT_EXPR. Change semantics to return NULL_TREE for non-simplified negations. Do not strip type conversions and unify type handling. (negate_expr): New function, wrap around fold_negate_expr but ensure building a tree always. Strip type conversions here, fold to result type. (fold_unary): Use fold_negate_expr for folding NEGATE_EXPR. * gcc.dg/pr15785-1.c: Revert last change. * gcc.dg/torture/pr27116-2.c: New testcase. From-SVN: r114723
* fold-const.c (fold_truthop): Only return new tree node if we canonicalized ↵Michael Matz2006-06-161-1/+7
| | | | | | | | | | | | | | something. 2006-06-16 Michael Matz <matz@suse.de> Richard Guenther <rguenther@suse.de> * fold-const.c (fold_truthop): Only return new tree node if we canonicalized something. Co-Authored-By: Richard Guenther <rguenther@suse.de> From-SVN: r114713
* fold-const.c (fold_truth_not_expr): Rename from invert_truthvalue.Richard Guenther2006-06-151-30/+44
| | | | | | | | | | | | | | | | | | 2006-06-15 Richard Guenther <rguenther@suse.de> * fold-const.c (fold_truth_not_expr): Rename from invert_truthvalue. Give it fold_* semantics to avoid generating garbage. (invert_truthvalue): New function. Wrapper around fold_truth_not_expr. (optimize_minmax_comparison): Avoid creating garbage. (fold_unary): Use fold_truth_not_expr for folding TRUTH_NOT_EXPR. (fold_ternary): Replace uses of invert_truthvalue with fold_truth_not_expr where applicable. * tree.h (fold_truth_not_expr): Prototype. From-SVN: r114683
* Check for Objective-C++ in deciding certain COND_EXPR folding.Fariborz Jahanian2006-06-131-1/+2
| | | | | | | | Check for Objective-C++ in deciding certain COND_EXPR folding. OKed by Geoff Keating. From-SVN: r114619
* re PR middle-end/27116 (Incorrect integer division (wrong sign).)Richard Guenther2006-06-081-2/+6
| | | | | | | | | | | | | | 2006-06-08 Richard Guenther <rguenther@suse.de> PR middle-end/27116 * fold-const.c (negate_expr_p): We can negate BIT_NOT_EXPR only, if overflow is defined and not trapping. (negate_expr): Likewise. * gcc.dg/torture/pr27116.c: New testcase. * gcc.dg/pr15785-1.c: Remove test for invalid transformation. From-SVN: r114483
* tree.h: Declare folding_initializer.Mark Shinwell2006-06-041-2/+9
| | | | | | | | | | | | | | | | | gcc: * tree.h: Declare folding_initializer. * builtins.c (fold_builtin_constant_p): Give definite answer if folding inside an initializer. * fold-const.c: Define folding_initializer. (START_FOLD_INIT): Save and then set folding_initializer. (END_FOLD_INIT): Restore folding_initializer. gcc/testsuite: * gcc.c-torture/compile/builtin_constant_p.c: New test. From-SVN: r114358
* re PR tree-optimization/27039 (Unable to determine # of iterations for a ↵Richard Guenther2006-06-041-28/+35
| | | | | | | | | | | | | | | | simple loop) 2006-06-04 Richard Guenther <rguenther@suse.de> PR tree-optimization/27039 * fold-const.c (fold_comparison): Handle pointer comparison again for all comparison codes. Compare offsets in signed size type. (fold_binary): Move code from here. * gcc.dg/tree-ssa/loop-17.c: New testcase. From-SVN: r114357
* fold-const.c (fold_unary): Ensure folded expressions are type correct.Roger Sayle2006-06-021-34/+55
| | | | | | | | | * fold-const.c (fold_unary) <CONJ_EXPR>: Ensure folded expressions are type correct. Clean-up. <REALPART_EXPR>: Likewise. Optimize creal(~z) as creal(z). <IMAGPART_EXPR>: Likewise. Optimize cimag(~z) as -cimag(z). From-SVN: r114330
* re PR tree-optimization/23452 (Optimizing CONJG_EXPR (a) * a)Roger Sayle2006-05-301-0/+57
| | | | | | | | | | | | PR tree-optimization/23452 * fold-const.c (fold_mult_zconjz): New subroutine of fold_binary, to optimize z * conj(z) as realpart(z)^2 + imagpart(z)^2. (fold_binary) <MULT_EXPR>: Call fold_mult_zconjz for integral complex values and with -ffast-math for FP complex values. * gcc.dg/fold-mulconj-1.c: New test case. From-SVN: r114246
* re PR middle-end/27773 (ICE: in find_lattice_value, at tree-complex.c:133)Richard Guenther2006-05-271-8/+2
| | | | | | | | | | | | 2006-05-27 Richard Guenther <rguenther@suse.de> PR middle-end/27773 * fold-const.c (fold_plusminus_mult_expr): Use fold_convert to produce a constant of value 1 of generic type. * gcc.dg/torture/pr27773.c: New testcase. From-SVN: r114158
* re PR middle-end/27743 (Wrong code for ((unsigned) ((a) >> 2)) >> 15)Richard Guenther2006-05-251-1/+1
| | | | | | | | | | | | 2006-05-25 Richard Guenther <rguenther@suse.de> PR middle-end/27743 * fold-const.c (fold_binary): Do not look at the stripped op0 for (a OP c1) OP c2 to a OP (c1+c2) shift optimization. * gcc.dg/torture/pr27743.c: New testcase. From-SVN: r114112
* re PR middle-end/26622 (ICE in extract_insn, at recog.c:2084)Kazu Hirata2006-05-211-2/+4
| | | | | | | | | | | | | gcc/ PR tree-optimization/26622. * fold-const.c (fold_ternary) <COND_EXPR>: Call fold_convert on arg1. gcc/testsuite/ PR tree-optimization/26622. * gcc.c-torture/compile/pr26622.c: New. From-SVN: r113956