[PATCH] Fix for mklog
Hi all, Current mklog in some cases do not checks whether function have real changes or not. I fixed it by removing $doubtfunc and adding protection against EOF. Example: diff --git a/gcc/cfg.c b/gcc/cfg.c index 6070d9e..cb3dfd9 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -555,10 +555,10 @@ alloc_aux_for_block (basic_block bb, int size) } +void +free_aux_for_edges (void) +{ + free_aux_for_edges (cfun); +} + DEBUG_FUNCTION void debug_bb (basic_block bb) { Current mklog output, function debug_bb is reported but it does not have any changes within. gcc/ChangeLog: DATE * cfg.c (free_aux_for_edges): (debug_bb): Patched mklog output: gcc/ChangeLog: DATE * cfg.c (free_aux_for_edges): Ok to commit? --Marat contrib/ChangeLog: 2014-11-05 Marat Zakirov m.zaki...@samsung.com * mklog: Always doubt in functions. Add EOF protection. diff --git a/contrib/mklog b/contrib/mklog index 6ed4c6e..8e3c6b6 100755 --- a/contrib/mklog +++ b/contrib/mklog @@ -108,10 +108,22 @@ sub remove_suffixes ($) { return $filename; } +sub is_context_hunk_start { + return @_[0] =~ /^\*\*\*\*\*\** ([a-zA-Z0-9_].*)/; +} + +sub is_unified_hunk_start { + return @_[0] =~ /^@@ .* @@ ([a-zA-Z0-9_].*)/; +} + # Check if line is a top-level declaration. # TODO: ignore preprocessor directives except maybe #define ? sub is_top_level { my ($function, $is_context_diff) = (@_); + if (is_unified_hunk_start ($function) + || is_context_hunk_start ($function)) { + return 1; + } if ($is_context_diff) { $function =~ s/^..//; } else { @@ -200,14 +212,10 @@ foreach (@diff_lines) { $look_for_funs = 0; } -# Mark if we met doubtfully changed function. -$doubtfunc = 0; -if ($diff_lines[$line_idx] =~ /^@@ .* @@ ([a-zA-Z0-9_].*)/) { - $doubtfunc = 1; +if (is_unified_hunk_start ($diff_lines[$line_idx])) { $is_context_diff = 0; } -elsif ($diff_lines[$line_idx] =~ /^\*\*\*\*\*\** ([a-zA-Z0-9_].*)/) { - $doubtfunc = 1; +elsif (is_context_hunk_start ($diff_lines[$line_idx])) { $is_context_diff = 1; } @@ -222,7 +230,6 @@ foreach (@diff_lines) { # # The third pattern looks for the starts of functions or classes # within a diff block both for context and unified diff files. - if ($look_for_funs (/^\*\*\*\*\*\** ([a-zA-Z0-9_].*)/ || /^@@ .* @@ ([a-zA-Z0-9_].*)/ @@ -249,19 +256,19 @@ foreach (@diff_lines) { } # Check is function really modified $no_real_change = 0; - if ($doubtfunc) { - $idx = $line_idx; + $idx = $line_idx; # Skip line info in context diffs. - while ($is_context_diff $diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) { - ++$idx; - } + while ($idx = $#diff_lines $is_context_diff +$diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) { + ++$idx; + } # Check all lines till the first change # for the presence of really changed function - do { - ++$idx; - $no_real_change = is_top_level ($diff_lines[$idx], $is_context_diff); - } while (!$no_real_change ($diff_lines[$idx] !~ /^[-+!]/)) - } + do { + ++$idx; + $no_real_change = $idx $#diff_lines + || is_top_level ($diff_lines[$idx], $is_context_diff); + } while (!$no_real_change ($diff_lines[$idx] !~ /^[-+!]/)); if ($fn !$seen_names{$fn} !$no_real_change) { # If this is the first function in the file, we display it next # to the filename, so we need an extra space before the opening
Re: [PATCH, ifcvt] Allow CC mode if HAVE_cbranchcc4 (fix s390 build)
On 11/06/2014 08:44 AM, Zhenqiang Chen wrote: Hi, The patch add runtime check to fix s390 build fail (https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00050.html). And there is additional code to workaround s390 cstorecc4 issue. Bootstrap and no make check regression on X86-64. Build s390-linux-gnu and s390x-linux-gnu. I do not have env to run full s390 tests. Would anyone in the TO list help to run the s390 tests? Thanks! -Zhenqiang ChangeLog: 2014-11-06 Zhenqiang Chen zhenqiang.c...@arm.com * ifcvt.c (noce_emit_cmove, noce_get_alt_condition, noce_get_condition): Allow CC mode if HAVE_cbranchcc4. (noce_emit_store_flag): Change CC REG as cond_complex. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index f4002f9..7f7b7c1 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -849,7 +849,10 @@ noce_emit_store_flag (struct noce_if_info *if_info, rtx x, int reversep, enum rtx_code code; cond_complex = (! general_operand (XEXP (cond, 0), VOIDmode) - || ! general_operand (XEXP (cond, 1), VOIDmode)); + || ! general_operand (XEXP (cond, 1), VOIDmode) + /* For s390, CC REG is general_operand. But cstorecc4 only + handles CCZ1, which can not handle others like CCU. */ + || GET_MODE_CLASS (GET_MODE (XEXP (cond, 0))) == MODE_CC); I'd like to know more about this. This seems like a mistake in the backend. +#ifdef HAVE_cbranchcc4 + if (GET_MODE_CLASS (GET_MODE (cmp_a)) != MODE_CC + || cmp_b != const0_rtx + || !(HAVE_cbranchcc4)) +#endif Please add #ifndef HAVE_cbranchcc4 # define HAVE_cbranchcc4 #endif at the top of ifcvt.c along with all of the others. Then use normal C tests instead of preprocessor tests. + int allow_cc_mode = false; +#ifdef HAVE_cbranchcc4 + allow_cc_mode = HAVE_cbranchcc4; +#endif E.g. this becomes bool allow_cc_mode = HAVE_cbranchcc4; r~
Re: [PATCH, PR63742][ARM] Fix arm *movhi_insn_arch4 pattern for big-endian
The idea is simple: Use movw for certain const source operand instead of ldrh. And exclude the const values which cannot be handled by mov/mvn/movw. I am doing regression test for this patch. Assuming no issue pops up, OK for trunk? So, doesn't that makes the bug latent for architectures older than armv6t2 and big endian and only fixed this in ARM state ? I'd prefer a complete solution please. What about *thumb2_movhi_insn in thumb2.md ? Actually, we fix the bug by excluding the const values which cannot be handled. The patch still works even without the adding of movw here. The new movw alternative here is just an small code optimization for certain arch. We can handle consts by movw instead of ldrh and this better for performance. We find that this bug is not reproducible for *thumb2_movhi_insn. The reason is that this pattern can always move consts using movw. --- gcc/ChangeLog (revision 216838) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,12 @@ +2014-11-05 Felix Yang felix.y...@huawei.com + Shanyao Chen chenshan...@huawei.com + I'm assuming you have copyright assignments sorted. Yes, both my employer(Huawei) and I have signed copyright assignments with FSF. +(define_predicate arm_movw_immediate_operand + (and (match_test TARGET_32BIT arm_arch_thumb2) + (ior (match_code high) I don't see why you need to check for high here ? Yeah, I double checked and found that it's not necessary here. Thanks for pointing this out. Attached please find the updated patch. Reg-tested for armeb-none-eabi. OK for the trunk? Index: gcc/ChangeLog === --- gcc/ChangeLog (revision 216838) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,12 @@ +2014-11-05 Felix Yang felix.y...@huawei.com + Shanyao Chen chenshan...@huawei.com + + PR target/63742 + * config/arm/predicates.md (arm_hi_operand): New predicate. + (arm_movw_immediate_operand): Similarly. + * config/arm/arm.md (*movhi_insn_arch4): Use arm_hi_operand instead of + general_operand and add movw to the output template. + 2014-10-29 Richard Sandiford richard.sandif...@arm.com * addresses.h, alias.c, asan.c, auto-inc-dec.c, bt-load.c, builtins.c, Index: gcc/config/arm/predicates.md === --- gcc/config/arm/predicates.md(revision 216838) +++ gcc/config/arm/predicates.md(working copy) @@ -144,6 +144,11 @@ (and (match_code const_int) (match_test INTVAL (op) == 0))) +(define_predicate arm_movw_immediate_operand + (and (match_test TARGET_32BIT arm_arch_thumb2) + (and (match_code const_int) + (match_test (INTVAL (op) 0x) == 0 + ;; Something valid on the RHS of an ARM data-processing instruction (define_predicate arm_rhs_operand (ior (match_operand 0 s_register_operand) @@ -211,6 +216,11 @@ (ior (match_operand 0 arm_rhs_operand) (match_operand 0 arm_not_immediate_operand))) +(define_predicate arm_hi_operand + (ior (match_operand 0 arm_rhsm_operand) + (ior (match_operand 0 arm_not_immediate_operand) +(match_operand 0 arm_movw_immediate_operand + (define_predicate arm_di_operand (ior (match_operand 0 s_register_operand) (match_operand 0 arm_immediate_di_operand))) Index: gcc/config/arm/arm.md === --- gcc/config/arm/arm.md (revision 216838) +++ gcc/config/arm/arm.md (working copy) @@ -6285,8 +6285,8 @@ ;; Pattern to recognize insn generated default case above (define_insn *movhi_insn_arch4 - [(set (match_operand:HI 0 nonimmediate_operand =r,r,m,r) - (match_operand:HI 1 general_operand rIk,K,r,mi))] + [(set (match_operand:HI 0 nonimmediate_operand =r,r,r,m,r) + (match_operand:HI 1 arm_hi_operand rIk,K,j,r,mi))] TARGET_ARM arm_arch4 (register_operand (operands[0], HImode) @@ -6294,16 +6294,18 @@ @ mov%?\\t%0, %1\\t%@ movhi mvn%?\\t%0, #%B1\\t%@ movhi + movw%?\\t%0, %1\\t%@ movhi str%(h%)\\t%1, %0\\t%@ movhi ldr%(h%)\\t%0, %1\\t%@ movhi [(set_attr predicable yes) - (set_attr pool_range *,*,*,256) - (set_attr neg_pool_range *,*,*,244) + (set_attr pool_range *,*,*,*,256) + (set_attr neg_pool_range *,*,*,*,244) (set_attr_alternative type [(if_then_else (match_operand 1 const_int_operand ) (const_string mov_imm ) (const_string mov_reg)) (const_string mvn_imm) + (const_string mov_imm) (const_string store1) (const_string load1)])] ) movhi_insn_arch4-fix-v2.patch Description: movhi_insn_arch4-fix-v2.patch
RE: [Ping] [PATCH, 9/10] aarch64: generate conditional compare instructions
-Original Message- From: Richard Henderson [mailto:r...@redhat.com] Sent: Wednesday, November 05, 2014 9:42 PM To: Zhenqiang Chen Cc: gcc-patches@gcc.gnu.org Subject: Re: [Ping] [PATCH, 9/10] aarch64: generate conditional compare instructions On 11/05/2014 10:05 AM, Zhenqiang Chen wrote: I had retested all the ccmp patches. Bootstrap and no make check regression on X86-64. Bootstrap and no make check regression on AARCH64 qemu. OK for trunk? No patch? Or what is it that you're wanting approval for? Sorry! The patch is attached. In fact, there is no real change from its original version: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg01914.html And there is no comment after https://gcc.gnu.org/ml/gcc-patches/2014-10/msg02717.html So I retest it and ping again. Thanks! -Zhenqiang 9-gen-ccmp.patch Description: Binary data
[PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
This merges patterns implementing the bitwise patterns from tree-ssa-forwprop.c. I've removed duplicate functionality from fold-const.c as I found them, some may be still lurking in the depths. This also fixes a bug in genmatch which made user-defined predicates matching anything, thus (match foo @0 (if ... not work (that is: ignored). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2014-11-06 Richard Biener rguent...@suse.de * match.pd: Implement bitwise binary and unary simplifications from tree-ssa-forwprop.c. * fold-const.c (fold_unary_loc): Remove them here. (fold_binary_loc): Likewise. * tree-ssa-forwprop.c (simplify_not_neg_expr): Remove. (truth_valued_ssa_name): Likewise. (lookup_logical_inverted_value): Likewise. (simplify_bitwise_binary_1): Likewise. (hoist_conversion_for_bitop_p): Likewise. (simplify_bitwise_binary_boolean): Likewise. (simplify_bitwise_binary): Likewise. (pass_forwprop::execute): Remove calls to simplify_not_neg_expr and simplify_bitwise_binary. * genmatch.c (dt_node::append_true_op): Use safe_as_a for parent. (decision_tree::insert): Also insert non-expressions. * gcc.dg/tree-ssa/forwprop-28.c: Adjust scanning for the desired transform. Index: trunk/gcc/fold-const.c === --- trunk.orig/gcc/fold-const.c 2014-11-05 13:31:01.131942296 +0100 +++ trunk/gcc/fold-const.c 2014-11-05 13:35:29.362930558 +0100 @@ -8008,8 +8008,6 @@ fold_unary_loc (location_t loc, enum tre case BIT_NOT_EXPR: if (TREE_CODE (arg0) == INTEGER_CST) return fold_not_const (arg0, type); - else if (TREE_CODE (arg0) == BIT_NOT_EXPR) - return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); /* Convert ~ (-A) to A - 1. */ else if (INTEGRAL_TYPE_P (type) TREE_CODE (arg0) == NEGATE_EXPR) return fold_build2_loc (loc, MINUS_EXPR, type, @@ -11152,26 +11150,6 @@ fold_binary_loc (location_t loc, arg1); } - /* (X Y) | Y is (X, Y). */ - if (TREE_CODE (arg0) == BIT_AND_EXPR - operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) - return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 0)); - /* (X Y) | X is (Y, X). */ - if (TREE_CODE (arg0) == BIT_AND_EXPR - operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) - reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) - return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 1)); - /* X | (X Y) is (Y, X). */ - if (TREE_CODE (arg1) == BIT_AND_EXPR - operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) - reorder_operands_p (arg0, TREE_OPERAND (arg1, 1))) - return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 1)); - /* X | (Y X) is (Y, X). */ - if (TREE_CODE (arg1) == BIT_AND_EXPR - operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0) - reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) - return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 0)); - /* (X ~Y) | (~X Y) is X ^ Y */ if (TREE_CODE (arg0) == BIT_AND_EXPR TREE_CODE (arg1) == BIT_AND_EXPR) @@ -11391,42 +11369,6 @@ fold_binary_loc (location_t loc, operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) return omit_one_operand_loc (loc, type, integer_zero_node, arg0); - /* Canonicalize (X | C1) C2 as (X C2) | (C1 C2). */ - if (TREE_CODE (arg0) == BIT_IOR_EXPR - TREE_CODE (arg1) == INTEGER_CST - TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) - { - tree tmp1 = fold_convert_loc (loc, type, arg1); - tree tmp2 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); - tree tmp3 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); - tmp2 = fold_build2_loc (loc, BIT_AND_EXPR, type, tmp2, tmp1); - tmp3 = fold_build2_loc (loc, BIT_AND_EXPR, type, tmp3, tmp1); - return - fold_convert_loc (loc, type, - fold_build2_loc (loc, BIT_IOR_EXPR, - type, tmp2, tmp3)); - } - - /* (X | Y) Y is (X, Y). */ - if (TREE_CODE (arg0) == BIT_IOR_EXPR - operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) - return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 0)); - /* (X | Y) X is (Y, X). */ - if (TREE_CODE (arg0) == BIT_IOR_EXPR - operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) - reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) - return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 1)); - /* X (X | Y) is (Y, X). */ - if (TREE_CODE (arg1) == BIT_IOR_EXPR - operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) -
Re: [PATCH 3/5] IPA ICF pass
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63747 is likely caused by this patch. compare_gimple_switch does not check CASE_LOW and CASE_HIGH, resulting merging functions not identical. Interestingly in the first a few versions of this patch CASE_LOW/HIGH were checked. But last versions only checks CASE_LABEL. What was the intention? It sounds like an accidental change. CASE_LOW/CASE_HIGH needs to be compared ;) Honza Thanks, Joey On Thu, Oct 23, 2014 at 5:18 AM, Jiong Wang wong.kwongyuan.to...@gmail.com wrote: PR 63574 ICE building libjava (segfault) on arm-linux-gnueabihf is caused by this commit. from the backtrace, the ICF pass is trying to compare two label tree node without type info. while looks like compare_operand expect the type info always be not empty before invoking func_checker::compatible_types_p. I think we should add a similiar t1/t2 check at the start of func_checker::compatible_types_p, just like what has been done at the head of func_checker::compare_operand. And I verified if we add that check, the crash gone away. Regards, Jiong 2014-10-15 18:03 GMT+01:00 Martin Liška mli...@suse.cz: On 10/14/2014 06:04 PM, Jan Hubicka wrote: diff --git a/gcc/cgraph.h b/gcc/cgraph.h index fb41b01..2de98b4 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -172,6 +172,12 @@ public: /* Dump referring in list to FILE. */ void dump_referring (FILE *); + /* Get number of references for this node. */ + inline unsigned get_references_count (void) + { +return ref_list.references ? ref_list.references-length () : 0; + } Probably better called num_references() (like we have num_edge in basic-block.h) @@ -8068,6 +8069,19 @@ it may significantly increase code size (see @option{--param ipcp-unit-growth=@var{value}}). This flag is enabled by default at @option{-O3}. +@item -fipa-icf +@opindex fipa-icf +Perform Identical Code Folding for functions and read-only variables. +The optimization reduces code size and may disturb unwind stacks by replacing +a function by equivalent one with a different name. The optimization works +more effectively with link time optimization enabled. + +Nevertheless the behavior is similar to Gold Linker ICF optimization, GCC ICF +works on different levels and thus the optimizations are not same - there are +equivalences that are found only by GCC and equivalences found only by Gold. + +This flag is enabled by default at @option{-O2}. ... and -Os? +case ARRAY_REF: +case ARRAY_RANGE_REF: + { + x1 = TREE_OPERAND (t1, 0); + x2 = TREE_OPERAND (t2, 0); + y1 = TREE_OPERAND (t1, 1); + y2 = TREE_OPERAND (t2, 1); + + if (!compare_operand (array_ref_low_bound (t1), + array_ref_low_bound (t2))) + return return_false_with_msg (); + if (!compare_operand (array_ref_element_size (t1), + array_ref_element_size (t2))) + return return_false_with_msg (); + if (!compare_operand (x1, x2)) + return return_false_with_msg (); + return compare_operand (y1, y2); + } No need for {...} if there are no local vars. +bool +func_checker::compare_function_decl (tree t1, tree t2) +{ + bool ret = false; + + if (t1 == t2) +return true; + + symtab_node *n1 = symtab_node::get (t1); + symtab_node *n2 = symtab_node::get (t2); + + if (m_ignored_source_nodes != NULL m_ignored_target_nodes != NULL) +{ + ret = m_ignored_source_nodes-contains (n1) +m_ignored_target_nodes-contains (n2); + + if (ret) + return true; +} + + /* If function decl is WEAKREF, we compare targets. */ + cgraph_node *f1 = cgraph_node::get (t1); + cgraph_node *f2 = cgraph_node::get (t2); + + if(f1 f2 f1-weakref f2-weakref) +ret = f1-alias_target == f2-alias_target; + + return ret; Comparing aliases is bit more complicated than just handling weakrefs. I have patch for symtab_node::equivalent_address_p somewhre in queue. lets just drop the fancy stuff for the moment and compare f1f2 for equivalence. + ret = compare_decl (t1, t2); Why functions are not compared with compare_decl while variables are? + + return return_with_debug (ret); +} + +void +func_checker::parse_labels (sem_bb *bb) +{ + for (gimple_stmt_iterator gsi = gsi_start_bb (bb-bb); !gsi_end_p (gsi); + gsi_next (gsi)) +{ + gimple stmt = gsi_stmt (gsi); + + if (gimple_code (stmt) == GIMPLE_LABEL) + { + tree t = gimple_label_label (stmt); + gcc_assert (TREE_CODE (t) == LABEL_DECL); + + m_label_bb_map.put (t, bb-bb-index); + } +} +} + +/* Basic block equivalence comparison function that returns true if +
[PATCH, i386, MPX] Add target filter for MPX tests
Hi, This patch adds target filter for recently added MPX tests. I put check function into a new file because I'm going to also add there some MPX runtime tests related functions and use in it another exp file. Since there is no change in compiler I just checked I get no fails for modified tests on x86_64 and x32. OK for trunk? Thanks, Ilya -- gcc/testsuite/ 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * lib/mpx-dg.exp: New. * gcc.target/i386/i386.exp: Load mpx-dg.exp. * gcc.target/i386/chkp-builtins-1.c: Require mpx target. * gcc.target/i386/chkp-builtins-2.c: Likewise. * gcc.target/i386/chkp-builtins-3.c: Likewise. * gcc.target/i386/chkp-builtins-4.c: Likewise. * gcc.target/i386/chkp-const-check-1.c: Likewise. * gcc.target/i386/chkp-const-check-2.c: Likewise. * gcc.target/i386/chkp-lifetime-1.c: Likewise. * gcc.target/i386/chkp-remove-bndint-1.c: Likewise. * gcc.target/i386/chkp-remove-bndint-2.c: Likewise. diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c index bcc1198..2acc087 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c +++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -fdump-tree-chkp } */ /* { dg-final { scan-tree-dump-not bnd_init_ptr_bounds chkp } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c index 1f4a244..dc62238 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c +++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -fdump-tree-chkp } */ /* { dg-final { scan-tree-dump-not bnd_copy_ptr_bounds chkp } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c index ea54ede..055f0ed 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c +++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -fdump-tree-chkp } */ /* { dg-final { scan-tree-dump-not bnd_set_ptr_bounds chkp } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c index cee780b..434df78 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c +++ b/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -fdump-tree-chkp } */ /* { dg-final { scan-tree-dump-not bnd_null_ptr_bounds chkp } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c b/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c index 2cd5af1..53e0828 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c +++ b/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt } */ /* { dg-final { scan-tree-dump-not bndcl chkpopt } } */ /* { dg-final { scan-tree-dump-not bndcu chkpopt } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c b/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c index 98497f9..18e497a 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c +++ b/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -O2 -Wchkp } */ int test (int *p) diff --git a/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c b/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c index bcecdd0..5ceaa8e 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c +++ b/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt-details } */ /* { dg-final { scan-tree-dump Moving creation of \[^ \]+ down to its use chkpopt } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c index db71004..377f5c4 100644 --- a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c +++ b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ /* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-optimized } */ /* { dg-final { scan-tree-dump-not bndint optimized } } */ diff --git a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c
Re: [PATCH] Fix for mklog
On 11/06/2014 11:00 AM, Marat Zakirov wrote: - if ($doubtfunc) { - $idx = $line_idx; + $idx = $line_idx; # Skip line info in context diffs. - while ($is_context_diff $diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) { - ++$idx; - } + while ($idx = $#diff_lines $is_context_diff +$diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) { + ++$idx; + } In original mklog this part was only run immediately after start of new hunk (which is correct) whereas with your patch it can now run in the middle of hunk. -Y
Re: [gomp4] Move libgomp plugins into subdirectory
Hi Julian! On Wed, 5 Nov 2014 17:57:10 +, Julian Brown jul...@codesourcery.com wrote: This patch moves plugin-nvptx.c and plugin-host.c (from oacc-host.c) into a new plugin subdirectory, as requested by Jakub, and to match more closely the layout of the Intel MIC pieces. This also moves the autotools bits to enable the NVPTX plugin and locate CUDA libraries into the plugin directory's (new) configury bits. Hmm. And then we cross-include files in libgomp/ from libgomp/plugin/ as well as the other way round (libgomp/oacc-host.c including libgomp/plugin/plugin-host.c, for example) -- whilst these two regimes are configured by two separate Autoconf instances? Is this really the intended scheme, or should we maybe rather have a top-level libgomp Autoconf/Automake system (as before), which is amended by libgomp/plugin/configfrag.ac and libgomp/plugin/Makefrag.am files that are included from libgomp/configure.ac and libgomp/Makefile.am? Test results look reasonable with my (patched for PTX support) version of the gomp4 branch. I'll apply it there shortly. Mid-air collision with my yesterday's libgomp changes -- with your patch in (r217162), gomp-4_0-branch doesn't even build; the files added/moved to libgomp/plugins/ are missing some of my changes. (I didn't look/compare in more detail.) libgomp/ * Makefile.am (SUBDIRS): Add plugin. (DIST_SUBDIRS): Define. (libgomp_plugin_nvptx_*): Remove nvptx support from here. (libgomp_plugin_host_nonshm_*): Likewise. * Makefile.in: Regenerate. * configure: Regenerate. * oacc-host.c: Replace with #include of plugin/plugin-host.c code, move implementation to the latter. * plugin/plugin-host.c: New file. * plugin-nvptx.c: Move to... * plugin/plugin-nvptx.c: New file. * plugin/Makefile.am: New. * plugin/Makefile.in: Regenerate. * plugin/aclocal.m4: Regenerate. * plugin/configure: Regenerate. Please check in the regenerated libgomp/config.h.in, update contrib/gcc_update, and make generation of libgomp/testsuite/libgomp-test-support.exp work again, that is, substitution of @CUDA_DRIVER_INCLUDE@ and @CUDA_DRIVER_LIB@ (perhaps move instantiation from libgomp/configure.ac to libgomp/plugin/configure.ac). Grüße, Thomas signature.asc Description: PGP signature
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Nov 6, 2014, at 12:55 AM, Richard Biener rguent...@suse.de wrote: This merges patterns implementing the bitwise patterns from tree-ssa-forwprop.c. I've removed duplicate functionality from fold-const.c as I found them, some may be still lurking in the depths. This also fixes a bug in genmatch which made user-defined predicates matching anything, thus (match foo @0 (if ... not work (that is: ignored). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Only one small comment. Richard. 2014-11-06 Richard Biener rguent...@suse.de * match.pd: Implement bitwise binary and unary simplifications from tree-ssa-forwprop.c. * fold-const.c (fold_unary_loc): Remove them here. (fold_binary_loc): Likewise. * tree-ssa-forwprop.c (simplify_not_neg_expr): Remove. (truth_valued_ssa_name): Likewise. (lookup_logical_inverted_value): Likewise. (simplify_bitwise_binary_1): Likewise. (hoist_conversion_for_bitop_p): Likewise. (simplify_bitwise_binary_boolean): Likewise. (simplify_bitwise_binary): Likewise. (pass_forwprop::execute): Remove calls to simplify_not_neg_expr and simplify_bitwise_binary. * genmatch.c (dt_node::append_true_op): Use safe_as_a for parent. (decision_tree::insert): Also insert non-expressions. * gcc.dg/tree-ssa/forwprop-28.c: Adjust scanning for the desired transform. Index: trunk/gcc/fold-const.c === --- trunk.orig/gcc/fold-const.c2014-11-05 13:31:01.131942296 +0100 +++ trunk/gcc/fold-const.c2014-11-05 13:35:29.362930558 +0100 @@ -8008,8 +8008,6 @@ fold_unary_loc (location_t loc, enum tre case BIT_NOT_EXPR: if (TREE_CODE (arg0) == INTEGER_CST) return fold_not_const (arg0, type); - else if (TREE_CODE (arg0) == BIT_NOT_EXPR) -return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); /* Convert ~ (-A) to A - 1. */ else if (INTEGRAL_TYPE_P (type) TREE_CODE (arg0) == NEGATE_EXPR) return fold_build2_loc (loc, MINUS_EXPR, type, @@ -11152,26 +11150,6 @@ fold_binary_loc (location_t loc, arg1); } - /* (X Y) | Y is (X, Y). */ - if (TREE_CODE (arg0) == BIT_AND_EXPR - operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) -return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 0)); - /* (X Y) | X is (Y, X). */ - if (TREE_CODE (arg0) == BIT_AND_EXPR - operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) - reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) -return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 1)); - /* X | (X Y) is (Y, X). */ - if (TREE_CODE (arg1) == BIT_AND_EXPR - operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) - reorder_operands_p (arg0, TREE_OPERAND (arg1, 1))) -return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 1)); - /* X | (Y X) is (Y, X). */ - if (TREE_CODE (arg1) == BIT_AND_EXPR - operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0) - reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) -return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 0)); - /* (X ~Y) | (~X Y) is X ^ Y */ if (TREE_CODE (arg0) == BIT_AND_EXPR TREE_CODE (arg1) == BIT_AND_EXPR) @@ -11391,42 +11369,6 @@ fold_binary_loc (location_t loc, operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) return omit_one_operand_loc (loc, type, integer_zero_node, arg0); - /* Canonicalize (X | C1) C2 as (X C2) | (C1 C2). */ - if (TREE_CODE (arg0) == BIT_IOR_EXPR - TREE_CODE (arg1) == INTEGER_CST - TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) -{ - tree tmp1 = fold_convert_loc (loc, type, arg1); - tree tmp2 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); - tree tmp3 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); - tmp2 = fold_build2_loc (loc, BIT_AND_EXPR, type, tmp2, tmp1); - tmp3 = fold_build2_loc (loc, BIT_AND_EXPR, type, tmp3, tmp1); - return -fold_convert_loc (loc, type, - fold_build2_loc (loc, BIT_IOR_EXPR, - type, tmp2, tmp3)); -} - - /* (X | Y) Y is (X, Y). */ - if (TREE_CODE (arg0) == BIT_IOR_EXPR - operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) -return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 0)); - /* (X | Y) X is (Y, X). */ - if (TREE_CODE (arg0) == BIT_IOR_EXPR - operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) - reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) -return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 1)); - /* X (X | Y) is (Y, X). */ - if (TREE_CODE (arg1) == BIT_IOR_EXPR - operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) - reorder_operands_p (arg0, TREE_OPERAND
Re: [Ping] [PATCH, 9/10] aarch64: generate conditional compare instructions
+ /* Generate insn to match ccmp_and/ccmp_ior. */ + target = gen_rtx_REG (mode, CC_REGNUM); + emit_insn (gen_rtx_SET (VOIDmode, target, + gen_rtx_fmt_ee (COMPARE, VOIDmode, + bit_op, const0_rtx))); Invalid mode for the compare; should be mode. Otherwise ok. r~
Re: [AArch64] [BE] Fix vector load/stores to not use ld1/st1
On 10 October 2014 16:19, Alan Hayward alan.hayw...@arm.com wrote: This patch is dependant on [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.” It fixes up movoi/ci/xi for Big Endian, so that we end up with the lsb of a big-endian integer to be in the low byte of the highest-numbered register. movoi uses stp/ldp movxi needs a split version (which is shared with register-register movxi), which just splits to two new movs movci can then split to three movs. A future patch will instead split to an movoi and a movti. There are no changes for LE. Ran whole of check with both parts of Make large opaque integer modes endianness-safe”. No regressions. ChangeLog: gcc/: 2014-10-10 Alan Hayward alan.hayw...@arm.com * config/aarch64/aarch64.c (aarch64_classify_address): Allow extra addressing modes for BE. (aarch64_print_operand): new operand for printing a q register+1. (aarch64_simd_emit_reg_reg_move): replacement for aarch64_simd_disambiguate_copy that plants the required mov. * config/aarch64/aarch64-protos.h (aarch64_simd_emit_reg_reg_move): replacement for aarch64_simd_disambiguate_copy. * config/aarch64/aarch64-simd.md (define_split) Use new aarch64_simd_emit_reg_reg_move. (define_expand movmode) less restrictive predicates. (define_insn *aarch64_movmode) Simplify and only allow for LE. (define_insn *aarch64_be_movoi) New. BE only. Plant ldp or stp. (define_insn *aarch64_be_movci) New. BE only. No instructions. (define_insn *aarch64_be_movxi) New. BE only. No instructions. (define_split) OI mov. Use new aarch64_simd_emit_reg_reg_move. (define_split) CI mov. Use new aarch64_simd_emit_reg_reg_move. On BE plant movs for reg to/from mem case. (define_split) XI mov. Use new aarch64_simd_emit_reg_reg_move. On BE plant movs for reg to/from mem case. OK /Marcus Hello, It seems that this patch breaks the compile of some testcases under big-endian. On example: testsuite/gcc.target/aarch64/advsimd-intrinsics/ vldX.c Any thing I missed? Please confirm. Thanks. $ aarch64_be-linux-gnu-gcc vldX.c vldX.c: In function 'exec_vldX': vldX.c:686:1: internal compiler error: in change_address_1, at emit-rtl.c:2096 } ^ 0x73b18c change_address_1 /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:2096 0xdbd278 gen_split_2991(rtx_insn*, rtx_def**) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/config/aarch64/aarch64-simd.md:4436 0x743aa1 try_split(rtx_def*, rtx_def*, int) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:3639 0x9b8c93 split_insn /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:2901 0x9b8ee7 split_all_insns_noflow() /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:3042 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See http://gcc.gnu.org/bugs.html for instructions.
Re: [PATCH] Fix for mklog
On 11/06/2014 12:07 PM, Yury Gribov wrote: On 11/06/2014 11:00 AM, Marat Zakirov wrote: -if ($doubtfunc) { -$idx = $line_idx; +$idx = $line_idx; # Skip line info in context diffs. -while ($is_context_diff $diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) { -++$idx; -} +while ($idx = $#diff_lines $is_context_diff +$diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) { +++$idx; +} In original mklog this part was only run immediately after start of new hunk (which is correct) whereas with your patch it can now run in the middle of hunk. Ok, I've inspected the context diff format and it seems that I was wrong - line markers (^--- and ^***) can appear inside hunks. So patch LGTM but you need to wait for maintainer's (i.e. Diego's) approval. -Y
Re: [AArch64] [BE] Fix vector load/stores to not use ld1/st1
On 06/11/2014 09:09, Yangfei (Felix) felix.y...@huawei.com wrote: On 10 October 2014 16:19, Alan Hayward alan.hayw...@arm.com wrote: This patch is dependant on [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.” It fixes up movoi/ci/xi for Big Endian, so that we end up with the lsb of a big-endian integer to be in the low byte of the highest-numbered register. movoi uses stp/ldp movxi needs a split version (which is shared with register-register movxi), which just splits to two new movs movci can then split to three movs. A future patch will instead split to an movoi and a movti. There are no changes for LE. Ran whole of check with both parts of Make large opaque integer modes endianness-safe”. No regressions. ChangeLog: gcc/: 2014-10-10 Alan Hayward alan.hayw...@arm.com * config/aarch64/aarch64.c (aarch64_classify_address): Allow extra addressing modes for BE. (aarch64_print_operand): new operand for printing a q register+1. (aarch64_simd_emit_reg_reg_move): replacement for aarch64_simd_disambiguate_copy that plants the required mov. * config/aarch64/aarch64-protos.h (aarch64_simd_emit_reg_reg_move): replacement for aarch64_simd_disambiguate_copy. * config/aarch64/aarch64-simd.md (define_split) Use new aarch64_simd_emit_reg_reg_move. (define_expand movmode) less restrictive predicates. (define_insn *aarch64_movmode) Simplify and only allow for LE. (define_insn *aarch64_be_movoi) New. BE only. Plant ldp or stp. (define_insn *aarch64_be_movci) New. BE only. No instructions. (define_insn *aarch64_be_movxi) New. BE only. No instructions. (define_split) OI mov. Use new aarch64_simd_emit_reg_reg_move. (define_split) CI mov. Use new aarch64_simd_emit_reg_reg_move. On BE plant movs for reg to/from mem case. (define_split) XI mov. Use new aarch64_simd_emit_reg_reg_move. On BE plant movs for reg to/from mem case. OK /Marcus Hello, It seems that this patch breaks the compile of some testcases under big-endian. On example: testsuite/gcc.target/aarch64/advsimd-intrinsics/ vldX.c Any thing I missed? Please confirm. Thanks. $ aarch64_be-linux-gnu-gcc vldX.c vldX.c: In function 'exec_vldX': vldX.c:686:1: internal compiler error: in change_address_1, at emit-rtl.c:2096 } ^ 0x73b18c change_address_1 /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:2096 0xdbd278 gen_split_2991(rtx_insn*, rtx_def**) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/config/aarch64/aarch64-simd .md:4436 0x743aa1 try_split(rtx_def*, rtx_def*, int) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:3639 0x9b8c93 split_insn /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:2901 0x9b8ee7 split_all_insns_noflow() /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:3042 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See http://gcc.gnu.org/bugs.html for instructions. Did you try my patch with or without it’s dependency ? [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.” (David Sherwood) Without that above patch then I would expect some tests to fail. In addition, it looks like David has had some problems merging that patch to the latest head - I’d suggest not using this patch until David has sorted his. Alan.
Re: [PATCH, i386, MPX] Add target filter for MPX tests
Hello! 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * lib/mpx-dg.exp: New. * gcc.target/i386/i386.exp: Load mpx-dg.exp. * gcc.target/i386/chkp-builtins-1.c: Require mpx target. * gcc.target/i386/chkp-builtins-2.c: Likewise. * gcc.target/i386/chkp-builtins-3.c: Likewise. * gcc.target/i386/chkp-builtins-4.c: Likewise. * gcc.target/i386/chkp-const-check-1.c: Likewise. * gcc.target/i386/chkp-const-check-2.c: Likewise. * gcc.target/i386/chkp-lifetime-1.c: Likewise. * gcc.target/i386/chkp-remove-bndint-1.c: Likewise. * gcc.target/i386/chkp-remove-bndint-2.c: Likewise. OK. Thanks, Uros.
Re: [AArch64] [BE] Fix vector load/stores to not use ld1/st1
Hello, It seems that this patch breaks the compile of some testcases under big-endian. On example: testsuite/gcc.target/aarch64/advsimd-intrinsics/ vldX.c Any thing I missed? Please confirm. Thanks. $ aarch64_be-linux-gnu-gcc vldX.c vldX.c: In function 'exec_vldX': vldX.c:686:1: internal compiler error: in change_address_1, at emit-rtl.c:2096 } ^ 0x73b18c change_address_1 /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:2096 0xdbd278 gen_split_2991(rtx_insn*, rtx_def**) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/config/aarch64/aarch64-s imd .md:4436 0x743aa1 try_split(rtx_def*, rtx_def*, int) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:3639 0x9b8c93 split_insn /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:2901 0x9b8ee7 split_all_insns_noflow() /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:3042 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See http://gcc.gnu.org/bugs.html for instructions. Did you try my patch with or without it’s dependency ? [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.” (David Sherwood) Without that above patch then I would expect some tests to fail. In addition, it looks like David has had some problems merging that patch to the latest head - I’d suggest not using this patch until David has sorted his. Alan. Yeah, I also merged with it's dependency. I tried the patch with this snapshot: gcc version 5.0.0 20141029 (experimental).
Re: [gomp4] Move libgomp plugins into subdirectory
On Thu, 6 Nov 2014 10:06:00 +0100 Thomas Schwinge tho...@codesourcery.com wrote: Hi Julian! On Wed, 5 Nov 2014 17:57:10 +, Julian Brown jul...@codesourcery.com wrote: This patch moves plugin-nvptx.c and plugin-host.c (from oacc-host.c) into a new plugin subdirectory, as requested by Jakub, and to match more closely the layout of the Intel MIC pieces. This also moves the autotools bits to enable the NVPTX plugin and locate CUDA libraries into the plugin directory's (new) configury bits. Hmm. And then we cross-include files in libgomp/ from libgomp/plugin/ as well as the other way round (libgomp/oacc-host.c including libgomp/plugin/plugin-host.c, for example) -- whilst these two regimes are configured by two separate Autoconf instances? Is this really the intended scheme, or should we maybe rather have a top-level libgomp Autoconf/Automake system (as before), which is amended by libgomp/plugin/configfrag.ac and libgomp/plugin/Makefrag.am files that are included from libgomp/configure.ac and libgomp/Makefile.am? I don't know -- I was trying to follow existing practice (or how I imagine that to be) with regard to recursive autotools invocations (e.g. libjava/libltdl), and I have some FUD, probably misplaced, about how well non-recursive autotools works. A couple of the header files (oacc-plugin.h, libgomp-plugin.h) might be better placed within the plugin directory, but plugins will generally still need to include some headers direct from libgomp/. Maybe this reorg is just a bad idea? Test results look reasonable with my (patched for PTX support) version of the gomp4 branch. I'll apply it there shortly. Mid-air collision with my yesterday's libgomp changes -- with your patch in (r217162), gomp-4_0-branch doesn't even build; the files added/moved to libgomp/plugins/ are missing some of my changes. (I didn't look/compare in more detail.) Apologies, I thought I'd fixed those up, but it looks like I missed a bit. libgomp/ * Makefile.am (SUBDIRS): Add plugin. (DIST_SUBDIRS): Define. (libgomp_plugin_nvptx_*): Remove nvptx support from here. (libgomp_plugin_host_nonshm_*): Likewise. * Makefile.in: Regenerate. * configure: Regenerate. * oacc-host.c: Replace with #include of plugin/plugin-host.c code, move implementation to the latter. * plugin/plugin-host.c: New file. * plugin-nvptx.c: Move to... * plugin/plugin-nvptx.c: New file. * plugin/Makefile.am: New. * plugin/Makefile.in: Regenerate. * plugin/aclocal.m4: Regenerate. * plugin/configure: Regenerate. Please check in the regenerated libgomp/config.h.in, update contrib/gcc_update, and make generation of libgomp/testsuite/libgomp-test-support.exp work again, that is, substitution of @CUDA_DRIVER_INCLUDE@ and @CUDA_DRIVER_LIB@ (perhaps move instantiation from libgomp/configure.ac to libgomp/plugin/configure.ac). I'll fix this. Thanks, Julian
Re: [PATCH] Limit removal of UBSAN_NULL checks
On Wed, Nov 05, 2014 at 11:08:27PM +0100, Jakub Jelinek wrote: I wonder if for the case where you don't remove, gimple_bb (g) == gimple_bb (stmt) and tree_int_cst_compare (cur_align, align) == 0 it wouldn't be worthwhile to v.pop (); so that the vector doesn't grow up unnecessarily too Good idea. I've added that. much. Maybe also bump the 30 limit to 100-200? Now that you don't walk the whole vector each time, it is only a matter of memory consumption (perhaps instead of having a constant limit for every vector it might be better to just have a limit on the total size of all the sanopt vectors (say a few megabytes)? And count towards that limit the allocated () size of the vector, once you have some size allocated, not pushing stuff in there doesn't make you consume more memory. Or just don't have a limit at all. I removed the limit altogether. I believe the vectors won't grow too much anyway. Thanks for review. ubsan.exp passed, bootstrap-ubsan running - ok if it passes? 2014-11-06 Marek Polacek pola...@redhat.com * sanopt.c (sanopt_optimize_walker): Limit removal of the checks. Remove vector limit. testsuite/ * c-c++-common/ubsan/align-2.c: Add dg-output. * c-c++-common/ubsan/align-4.c: Likewise. * c-c++-common/ubsan/align-6.c: New test. * c-c++-common/ubsan/align-7.c: New test. * c-c++-common/ubsan/align-8.c: New test. * g++.dg/ubsan/null-1.C: Add dg-output. * g++.dg/ubsan/null-2.C: Likewise. * g++.dg/ubsan/null-3.C: New test. * g++.dg/ubsan/null-4.C: New test. * g++.dg/ubsan/null-5.C: New test. diff --git gcc/sanopt.c gcc/sanopt.c index 4483ff7..0fc032a 100644 --- gcc/sanopt.c +++ gcc/sanopt.c @@ -130,7 +130,30 @@ sanopt_optimize_walker (basic_block bb, struct sanopt_ctx *ctx) /* At this point we shouldn't have any statements that aren't dominating the current BB. */ tree align = gimple_call_arg (g, 2); - remove = tree_int_cst_le (cur_align, align); + int kind = tree_to_shwi (gimple_call_arg (g, 1)); + /* If this is a NULL pointer check where we had segv +anyway, we can remove it. */ + if (integer_zerop (align) + (kind == UBSAN_LOAD_OF + || kind == UBSAN_STORE_OF + || kind == UBSAN_MEMBER_ACCESS)) + remove = true; + /* Otherwise remove the check in non-recovering +mode, or if the stmts have same location. */ + else if (integer_zerop (align)) + remove = !(flag_sanitize_recover SANITIZE_NULL) +|| flag_sanitize_undefined_trap_on_error +|| gimple_location (g) + == gimple_location (stmt); + else if (tree_int_cst_le (cur_align, align)) + remove = !(flag_sanitize_recover + SANITIZE_ALIGNMENT) +|| flag_sanitize_undefined_trap_on_error +|| gimple_location (g) + == gimple_location (stmt); + if (!remove gimple_bb (g) == gimple_bb (stmt) + tree_int_cst_compare (cur_align, align) == 0) + v.pop (); break; } } @@ -147,7 +170,7 @@ sanopt_optimize_walker (basic_block bb, struct sanopt_ctx *ctx) } gsi_remove (gsi, true); } - else if (v.length () 30) + else v.safe_push (stmt); } } diff --git gcc/testsuite/c-c++-common/ubsan/align-2.c gcc/testsuite/c-c++-common/ubsan/align-2.c index 02a26e2..071de8c 100644 --- gcc/testsuite/c-c++-common/ubsan/align-2.c +++ gcc/testsuite/c-c++-common/ubsan/align-2.c @@ -51,4 +51,6 @@ main () /* { dg-output \.c:(13|16):\[0-9]*: \[^\n\r]*store to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.* } */ /* { dg-output \.c:23:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.* } */ /* { dg-output \.c:(29|30):\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.* } */ +/* { dg-output \.c:30:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.* } */ +/* { dg-output
Re: [gomp4] acc reductions with multiple variables
Hi! On Fri, 31 Oct 2014 16:35:27 -0700, Cesar Philippidis ce...@codesourcery.com wrote: This patch does the following: [...] gcc/ * omp-low.c (oacc_max_threads): New function. (lower_reduction_clauses): Use the GOACC thread builtin functions to determine the thread count. Handle multiple reduction variables. (expand_omp_for_static_nochunk): Likewise. (expand_omp_for_static_chunk): Likewise. (finalize_reduction_data): General cleanups. (process_reduction_data): Use acc_get_device_type to determine nthreads at runtime. I fixed, conservatively, a bootstrap failure in gomp-4_branch's r217183: commit 7b80846629e7ed87bfd9efe42a7b49712b38c5a6 Author: tschwinge tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4 Date: Thu Nov 6 10:04:25 2014 + Fix bootstrap failure. [...]/source-gcc/gcc/omp-low.c: In function 'void lower_reduction_clauses(tree, gimple_statement_base**, omp_context*)': [...]/source-gcc/gcc/omp-low.c:4611:70: error: 'tid' may be used uninitialized in this function [-Werror=maybe-uninitialized] lower_reduction_var_helper (stmt_seqp, ctx, tid, var, new_var); ^ cc1plus: all warnings being treated as errors make[3]: *** [omp-low.o] Error 1 make[3]: Leaving directory `[...]/build-gcc/gcc' make[2]: *** [all-stage2-gcc] Error 2 make[2]: Leaving directory `[...]/build-gcc' make[1]: *** [stage2-bubble] Error 2 make[1]: Leaving directory `[...]/build-gcc' make: *** [all] Error 2 gcc/ * omp-low.c (lower_reduction_clauses): Initialize tid. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@217183 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 4 gcc/omp-low.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index d140a35..0bc9080 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,3 +1,7 @@ +2014-11-06 Thomas Schwinge tho...@codesourcery.com + + * omp-low.c (lower_reduction_clauses): Initialize tid. + 2014-11-05 Thomas Schwinge tho...@codesourcery.com * tree-core.h (enum omp_clause_code): Remove OMP_CLAUSE_HOST and diff --git gcc/omp-low.c gcc/omp-low.c index 0b45e69..23d9f5a8 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -4530,7 +4530,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx) { gimple_seq sub_seq = NULL; gimple stmt; - tree x, c, tid; + tree x, c, tid = NULL_TREE; int count = 0; /* SIMD reductions are handled in lower_rec_input_clauses. */ Grüße, Thomas signature.asc Description: PGP signature
[PATCH, testsuite, obvious] Do not produce optimized dump in devirt-4[45].C
Hi, g++.dg/ipa/devirt-44.C and g++.dg/ipa/devirt-45.C leave behind an optimized dump which they don't even use. Fixed thusly, tested by runing make -k check RUNTESTFLAGS=dg.exp=ipa/*.C, will commit shortly as obvious. Thanks, Martin 2014-11-06 Martin Jambor mjam...@suse.cz * g++.dg/ipa/devirt-44.C: Do not produce tree optimized dump. * g++.dg/ipa/devirt-45.C: Likewise. diff --git a/gcc/testsuite/g++.dg/ipa/devirt-44.C b/gcc/testsuite/g++.dg/ipa/devirt-44.C index bd6c198..cfc6e55 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-44.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-44.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options -O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized } */ +/* { dg-options -O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining } */ struct A { virtual int foo () {return 1;} int wrapfoo () {foo();} diff --git a/gcc/testsuite/g++.dg/ipa/devirt-45.C b/gcc/testsuite/g++.dg/ipa/devirt-45.C index 5c47e08..4616c95 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-45.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-45.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options -O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized } */ +/* { dg-options -O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining } */ struct A { virtual int foo () {return 1;} int wrapfoo () {foo();}
Re: [PATCH] Limit removal of UBSAN_NULL checks
On Thu, Nov 06, 2014 at 10:56:17AM +0100, Marek Polacek wrote: --- gcc/sanopt.c +++ gcc/sanopt.c @@ -130,7 +130,30 @@ sanopt_optimize_walker (basic_block bb, struct sanopt_ctx *ctx) /* At this point we shouldn't have any statements that aren't dominating the current BB. */ tree align = gimple_call_arg (g, 2); - remove = tree_int_cst_le (cur_align, align); + int kind = tree_to_shwi (gimple_call_arg (g, 1)); + /* If this is a NULL pointer check where we had segv + anyway, we can remove it. */ + if (integer_zerop (align) +(kind == UBSAN_LOAD_OF + || kind == UBSAN_STORE_OF + || kind == UBSAN_MEMBER_ACCESS)) + remove = true; + /* Otherwise remove the check in non-recovering + mode, or if the stmts have same location. */ + else if (integer_zerop (align)) + remove = !(flag_sanitize_recover SANITIZE_NULL) + || flag_sanitize_undefined_trap_on_error + || gimple_location (g) + == gimple_location (stmt); + else if (tree_int_cst_le (cur_align, align)) + remove = !(flag_sanitize_recover + SANITIZE_ALIGNMENT) + || flag_sanitize_undefined_trap_on_error + || gimple_location (g) + == gimple_location (stmt); + if (!remove gimple_bb (g) == gimple_bb (stmt) +tree_int_cst_compare (cur_align, align) == 0) Sorry for being slow on this, but in the current algorithm you are using the latest vector element from each bb only anyway, so the tree_int_cst_compare (cur_align, align) == 0 is unnecessary, even if the condition isn't true, and thus in your patch we would not pop the old one, we'd still never use the not popped element, as the stmt pushed after it would be used instead, or both stmts popped up if the domwalk left the bb already. If you want, commit your patch as is and in test the one liner together with some other change. Jakub
Re: [gomp4] Move libgomp plugins into subdirectory
On Thu, Nov 06, 2014 at 10:06:00AM +0100, Thomas Schwinge wrote: Hi Julian! On Wed, 5 Nov 2014 17:57:10 +, Julian Brown jul...@codesourcery.com wrote: This patch moves plugin-nvptx.c and plugin-host.c (from oacc-host.c) into a new plugin subdirectory, as requested by Jakub, and to match more closely the layout of the Intel MIC pieces. This also moves the autotools bits to enable the NVPTX plugin and locate CUDA libraries into the plugin directory's (new) configury bits. Hmm. And then we cross-include files in libgomp/ from libgomp/plugin/ as well as the other way round (libgomp/oacc-host.c including libgomp/plugin/plugin-host.c, for example) -- whilst these two regimes are configured by two separate Autoconf instances? Is this really the intended scheme, or should we maybe rather have a top-level libgomp Autoconf/Automake system (as before), which is amended by libgomp/plugin/configfrag.ac and libgomp/plugin/Makefrag.am files that are included from libgomp/configure.ac and libgomp/Makefile.am? I agree a plugin fragment into libgomp/configure.ac and/or libgomp/Makefile* is better. Jakub
Re: [AArch64] [BE] Fix vector load/stores to not use ld1/st1
On 6 November 2014 10:28, Alan Hayward alan.hayw...@arm.com wrote: On 06/11/2014 09:09, Yangfei (Felix) felix.y...@huawei.com wrote: On 10 October 2014 16:19, Alan Hayward alan.hayw...@arm.com wrote: This patch is dependant on [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.” It fixes up movoi/ci/xi for Big Endian, so that we end up with the lsb of a big-endian integer to be in the low byte of the highest-numbered register. movoi uses stp/ldp movxi needs a split version (which is shared with register-register movxi), which just splits to two new movs movci can then split to three movs. A future patch will instead split to an movoi and a movti. There are no changes for LE. Ran whole of check with both parts of Make large opaque integer modes endianness-safe”. No regressions. ChangeLog: gcc/: 2014-10-10 Alan Hayward alan.hayw...@arm.com * config/aarch64/aarch64.c (aarch64_classify_address): Allow extra addressing modes for BE. (aarch64_print_operand): new operand for printing a q register+1. (aarch64_simd_emit_reg_reg_move): replacement for aarch64_simd_disambiguate_copy that plants the required mov. * config/aarch64/aarch64-protos.h (aarch64_simd_emit_reg_reg_move): replacement for aarch64_simd_disambiguate_copy. * config/aarch64/aarch64-simd.md (define_split) Use new aarch64_simd_emit_reg_reg_move. (define_expand movmode) less restrictive predicates. (define_insn *aarch64_movmode) Simplify and only allow for LE. (define_insn *aarch64_be_movoi) New. BE only. Plant ldp or stp. (define_insn *aarch64_be_movci) New. BE only. No instructions. (define_insn *aarch64_be_movxi) New. BE only. No instructions. (define_split) OI mov. Use new aarch64_simd_emit_reg_reg_move. (define_split) CI mov. Use new aarch64_simd_emit_reg_reg_move. On BE plant movs for reg to/from mem case. (define_split) XI mov. Use new aarch64_simd_emit_reg_reg_move. On BE plant movs for reg to/from mem case. OK /Marcus Hello, It seems that this patch breaks the compile of some testcases under big-endian. On example: testsuite/gcc.target/aarch64/advsimd-intrinsics/ vldX.c Any thing I missed? Please confirm. Thanks. $ aarch64_be-linux-gnu-gcc vldX.c vldX.c: In function 'exec_vldX': vldX.c:686:1: internal compiler error: in change_address_1, at emit-rtl.c:2096 } ^ 0x73b18c change_address_1 /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:2096 0xdbd278 gen_split_2991(rtx_insn*, rtx_def**) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/config/aarch64/aarch64-simd .md:4436 0x743aa1 try_split(rtx_def*, rtx_def*, int) /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/emit-rtl.c:3639 0x9b8c93 split_insn /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:2901 0x9b8ee7 split_all_insns_noflow() /home/jjj/p660/p660_build_dir_be/src/trunk/gcc/recog.c:3042 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See http://gcc.gnu.org/bugs.html for instructions. Did you try my patch with or without it’s dependency ? [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.” (David Sherwood) Without that above patch then I would expect some tests to fail. Yes, we already have vldX and vuzp/vzip tests failing in aarch64_be. They are PR63652 and 636523. In addition, it looks like David has had some problems merging that patch to the latest head - I’d suggest not using this patch until David has sorted his. I've been looking at these PRs, but I should probably give a try to David's patch once it's updated. Alan.
[PATCH][AArch64] Add bounds checking to vqdm*_lane intrinsics via a qualifier that also flips endianness
This generates out-of-range errors at compile- (rather than assemble-)time for the vqdm*_lane intrinsics, and also provides a single place to do bigendian lane-swapping for all those intrinsics (and others to follow in later patches). This allows us to remove many define_expands that just do a range-check and endian-swap before outputting the RTL for a corresponding _internal insn. Changes to aarch64-simd.md are not as big as they look, they are highly repetitive, like the code they are removing! Testcases are also repetitive, as unfortunately dg-error doesn't care *how many* errors there were matching it's pattern, as long as at least 1, hence having to separate each into own file - the last 0 in the dg-error disables the line-number checking, as the line numbers in our error messages refer to lines within arm_neon.h rather than within the test case. (They do at least mention the user function containing the call to the intrinsic.) Ok for trunk? --Alan gcc/ChangeLog: * config/aarch64/aarch64.c (aarch64_simd_lane_bounds): Display indices. * config/aarch64/aarch64-builtins.c (enum aarch64_type_qualifiers): Add qualifier_lane_index. (aarch64_types_ternop_lane_qualifiers, TYPES_TERNOP_LANE): Rename to... (aarch64_types_quadop_lane_qualifiers, TYPES_QUADOP_LANE): ...these. (aarch64_types_ternop_lane_qualifiers, TYPES_TERNOP_LANE): New. (aarch64_types_getlane_qualifiers): Rename to... (aarch64_types_binop_imm_qualifiers): ...this. (TYPES_SHIFTIMM): Follow renaming. (TYPES_GETLANE): Rename to... (TYPE_GETREG): ...this. (aarch64_types_setlane_qualifiers): Rename to... (aarch64_type_ternop_imm_qualifiers): ...this. (TYPES_SHIFTINSERT, TYPES_SHIFTACC): Follow renaming. (TYPES_SETLANE): Follow renaming above, and rename self to... (TYPE_SETREG): ...this. (enum builtin_simd_arg): Add SIMD_ARG_LANE_INDEX. (aarch64_simd_expand_args): Add range check and endianness-flip. (aarch64_simd_expand_builtin): Add mapping for qualifier_lane_index. * config/aarch64/aarch64-simd.md (aarch64_sqrdmulh_lanemode_internal *2): Rename to... (aarch64_sqrdmulh_lanemode): ...this, and remove lane bounds check. (aarch64_sqdmulh_lanemode *2, aarch64_sqrdmulh_lanemode *2): Delete. (aarch64_sqrdmulh_laneqmode_internal): Rename to... (aarch64_sqrdmulh_lanemode): ...this. (aarch64_sqdmlSBINQOPS:asl_lanemode_internal *2): Rename to... (aarch64_sqdmlSBINQOPS:asl_lanemode): ...this. (aarch64_sqdmlSBINQOPS:asl_laneqmode_internal *2): Rename to... (aarch64_sqdmlSBINQOPS:asl_laneqmode): ...this. (aarch64_sqdmull_lanemode_internal *2): Rename to... (aarch64_sqdmull_lanemode): ...this. (aarch64_sqdmull_laneqmode_internal *2): Rename to... (aarch64_sqdmull_laneqmode): ...this. (aarch64_sqdmulh_laneqmode, aarch64_sqrdmulh_laneqmode, (aarch64_sqdmlal_lanemode, aarch64_sqdmlal_laneqmode, aarch64_sqdmlsl_lanemode, aarch64_sqdmlsl_laneqmode, aarch64_sqdmull_lanemode, aarch64_sqdmull_laneqmode): Delete. (aarch64_sqdmlal2_lanemode, aarch64_sqdmlal2_laneqmode, aarch64_sqdmlsl2_lanemode, aarch64_sqdmlsl2_laneqmode, aarch64_sqdmull2_lanemode, aarch64_sqdmull2_laneqmode): Remove bounds check and lane flip. * config/aarch64/aarch64-simd-builtins.def (be_checked_get_lane, get_dregoi, get_dregci, getdregxi, get_qregoi,get_qregci, get_qregxi, set_qregoi, set_qregci, set_qregxi): Change qualifiers to GETREG. (sqdmlal_lane, sqdmlsl_lane, sqdmlal_laneq, sqdmlsl_laneq, sqdmlal2_lane, sqdmlsl2_lane, sqdmlal2_laneq, sqdmlsl2_laneq): Follow renaming of TERNOP_LANE to QUADOP_LANE. (sqdmull_lane, sqdmull_laneq, sqdmull2_lane, sqdmull2_laneq, sqdmulh_lane, sqdmulh_laneq, sqrdmulh_lane, sqrdmulh_laneq): Set qualifiers to TERNOP_LANE. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/vqdmlal_high_lane_s16_indices_1.c: New test. * gcc.target/aarch64/simd/vqdmlal_high_lane_s32_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlal_high_laneq_s16_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlal_high_laneq_s32_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlal_lane_s16_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlal_lane_s32_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlal_laneq_s16_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlal_laneq_s32_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlalh_lane_s16_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlals_lane_s32_indices_1.c: Likewise. * gcc.target/aarch64/simd/vqdmlsl_high_lane_s16_indices_1.c: Likewise. *
[PATCHv5][PING^3] Vimrc config with GNU formatting
On 10/21/2014 07:24 PM, Yury Gribov wrote: On 10/13/2014 02:26 PM, Yury Gribov wrote: On 10/02/2014 09:14 PM, Yury Gribov wrote: On 09/17/2014 09:08 PM, Yury Gribov wrote: On 09/16/2014 08:38 PM, Yury Gribov wrote: Hi all, This is the third version of the patch. A list of changes since last version: * move config to contrib so that it's _not_ enabled by default (current score is 2/1 in favor of no Vim config by default) * update Makefile.in to make .local.vimrc if developer asks for it * disable autoformatting for flex files * fix filtering of non-GNU sources (libsanitizer) * added some small fixes in cinoptions based on feedback from community As noted by Richard, the config does not do a good job of formatting unbound {} blocks e.g. void foo () { int x; { // I'm an example of bad bad formatting } } but it seems to be the best we can get with Vim's cindent (and I don't think anyone seriously considers writing a custom indentexpr). Ok to commit? New vesion with support for another popular local .vimrc plugin. Hi all, Here is a new vesion of vimrc patch. Hope I got email settings right this time. Changes since v4: * fixed and enhanced docs * added support for .lvimrc in Makefile * minor fixes in cinoptions and formatoptions (reported by Segher) * removed shiftwidth settings (as it does not really relate to code formatting) commit 3f560e9dd16a5e914b6f2ba82edffe13dfde944c Author: Yury Gribov y.gri...@samsung.com Date: Thu Oct 2 15:50:52 2014 +0400 2014-10-02 Laurynas Biveinis laurynas.bivei...@gmail.com Yury Gribov y.gri...@samsung.com Vim config with GNU formatting. contrib/ * vimrc: New file. / * .gitignore: Added .local.vimrc and .lvimrc. * Makefile.tpl (vimrc, .lvimrc, .local.vimrc): New targets. * Makefile.in: Regenerate. diff --git a/.gitignore b/.gitignore index e9b56be..ab97ac6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,9 @@ POTFILES TAGS TAGS.sub +.local.vimrc +.lvimrc + .gdbinit .gdb_history diff --git a/Makefile.in b/Makefile.in index d6105b3..f3a34af 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2384,6 +2384,18 @@ mail-report-with-warnings.log: warning.log chmod +x $@ echo If you really want to send e-mail, run ./$@ now +# Local Vim config + +$(srcdir)/.local.vimrc: + $(LN_S) $(srcdir)/contrib/vimrc $@ + +$(srcdir)/.lvimrc: + $(LN_S) $(srcdir)/contrib/vimrc $@ + +vimrc: $(srcdir)/.local.vimrc $(srcdir)/.lvimrc + +.PHONY: vimrc + # Installation targets. .PHONY: install uninstall diff --git a/Makefile.tpl b/Makefile.tpl index f7c7e38..b98930c 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -867,6 +867,18 @@ mail-report-with-warnings.log: warning.log chmod +x $@ echo If you really want to send e-mail, run ./$@ now +# Local Vim config + +$(srcdir)/.local.vimrc: + $(LN_S) $(srcdir)/contrib/vimrc $@ + +$(srcdir)/.lvimrc: + $(LN_S) $(srcdir)/contrib/vimrc $@ + +vimrc: $(srcdir)/.local.vimrc $(srcdir)/.lvimrc + +.PHONY: vimrc + # Installation targets. .PHONY: install uninstall diff --git a/contrib/vimrc b/contrib/vimrc new file mode 100644 index 000..34e8f35 --- /dev/null +++ b/contrib/vimrc @@ -0,0 +1,45 @@ + Code formatting settings for Vim. + + To enable this for GCC files by default, you can either source this file + in your .vimrc via autocmd: + :au BufNewFile,BufReadPost path/to/gcc/* :so path/to/gcc/contrib/vimrc + or source the script manually for each newly opened file: + :so contrib/vimrc + You could also use numerous plugins that enable local vimrc e.g. + mbr's localvimrc or thinca's vim-localrc (but note that the latter + is much less secure). To install local vimrc config, run + $ make vimrc + from GCC build folder. + + Copyright (C) 2014 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/. + +function! SetStyle() + let l:fname = expand(%:p) + if stridx(l:fname, 'libsanitizer') != -1 +return + endif + let l:ext = fnamemodify(l:fname, :e) + let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java'] + if index(l:c_exts, l:ext) != -1 +setlocal cindent +setlocal softtabstop=2 +setlocal cinoptions=4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 +setlocal textwidth=80 +setlocal formatoptions-=ro formatoptions+=cqlt + endif +endfunction + +call SetStyle()
Fix ICE with thunks taking argument passed by reference
Hi, PR63573 is about ICE when expanding thunk call for function taking as a parameter structure passed by reference. This structure in fact contains only one integer and thus it is promoted to register by argument setup in function.c (as an optimization). This is an sensible optimization, but when expanding the tailcall we need memory location to store the value into to pass it again by reference. Because we lost the original memory location we ICE because we have addressable flag set on decl whose DECL_RTL is register. This patch fixes it up by reverting to original memory location in calls.c. This is of course not safe in general because the register value may be hcanged, but the path is executed only when THUNK flag of the call statement is set and that is set only in thunks where the values are not updated. Ugly hack but I can not think of better way to fix the ugly hacks already in there to make thunk expansion happen in tailcall. This fixed boostrap on ppc64-linux and the set of testsuite failures match ones before the bug was introduced. OK? PR bootstrap/63573 * calls.c (initialize_argument_information): When emitting thunk call use original memory placement of the argument. Index: calls.c === --- calls.c (revision 216942) +++ calls.c (working copy) @@ -1210,6 +1211,15 @@ initialize_argument_information (int num TREE_CODE (base) != SSA_NAME (!DECL_P (base) || MEM_P (DECL_RTL (base) { + /* Argument setup code may have copied the value to register. We +that optimization now because the tail call code must use +the original location. */ + if (TREE_CODE (args[i].tree_value) == PARM_DECL + !MEM_P (DECL_RTL (args[i].tree_value)) + DECL_INCOMING_RTL (args[i].tree_value) + MEM_P (DECL_INCOMING_RTL (args[i].tree_value))) + set_decl_rtl (args[i].tree_value, DECL_INCOMING_RTL (args[i].tree_value)); + mark_addressable (args[i].tree_value); /* We can't use sibcalls if a callee-copied argument is
Re: [PATCH, libfortran] PR 47007, 61847 Locale failures in libgfortran
On Wed, Nov 5, 2014 at 12:48 PM, Janne Blomqvist blomqvist.ja...@gmail.com wrote: Hi, the attached patch fixes a few locale related failures in libgfortran, in the case where the POSIX 2008 extended locale functionality and extensions strto{f,d,ld}_l are present. These failures typically occur when libgfortran is used from a program which has set the locale with setlocale(), and the locale uses a different decimal separator than the C locale. The patch fixes this by creating a C locale which is then used by strto{f,d,ld}_l, and also is installed as the per-thread locale when starting a formatted IO, then reset to the previous value when the IO is done. I have chosen to not fallback to calling setlocale() in case the POSIX 2008 locale stuff isn't available, as that could create nasty hard to debug race conditions in a multi-threaded program. (I think Jerry's proposed patch which checks the locale for the decimal separator is still useful as a fallback in case the POSIX 2008 locale stuff isn't available) Hi, updated patch attached. Since the patch sets the per-thread locale with uselocale, using the non-standard strto{f,d,ld}_l functions isn't necessary. When getting rid of this part of the original patch, I noticed a few failures due to the uselocale() calls being in the wrong places. These are fixed in the updated patch. Also Jakub's suggestion has been incorporated. Further, investigation revealed that some targets (Darwin and Freebsd) have the extended locale functionality in xlocale.h rather than locale.h as POSIX 2008 specifies. So check for that header. Finally, as we set the per-thread locale to C, we'd lose localized error messages. So the updated patch fixes this by updating the gf_strerror() function as well. Regtested on x86_64-unknown-linux-gnu, Ok for trunk? 2014-11-06 Janne Blomqvist j...@gcc.gnu.org PR libfortran/47007 PR libfortran/61847 * config.h.in: Regenerated. * configure: Regenerated. * configure.ac (AC_CHECK_HEADERS_ONCE): Check for xlocale.h. (AC_CHECK_FUNCS_ONCE): Check for newlocale, freelocale, uselocale, strerror_l. * io/io.h (locale.h): Include. (xlocale.h): Include if present. (c_locale): New variable. (st_parameter_dt): Add old_locale member. * io/transfer.c (data_transfer_init): Set thread locale to c_locale if doing formatted transfer. (finalize_transfer): Reset thread locale to previous. * io/unit.c (c_locale): New variable. (init_units): Init c_locale. (close_units): Free c_locale. * runtime/error.c (locale.h): Include. (xlocale.h): Include if present. (gf_strerror): Use strerror_l if available. Reset locale to LC_GLOBAL_LOCALE for strerror_r branch. -- Janne Blomqvist diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index b3150f4..f54104b 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -255,7 +255,7 @@ AC_CHECK_TYPES([ptrdiff_t]) # check header files (we assume C89 is available, so don't check for that) AC_CHECK_HEADERS_ONCE(unistd.h sys/time.h sys/times.h sys/resource.h \ sys/types.h sys/stat.h sys/wait.h floatingpoint.h ieeefp.h fenv.h fptrap.h \ -fpxcp.h pwd.h complex.h) +fpxcp.h pwd.h complex.h xlocale.h) GCC_HEADER_STDINT(gstdint.h) @@ -290,7 +290,8 @@ else strcasestr getrlimit gettimeofday stat fstat lstat getpwuid vsnprintf dup \ getcwd localtime_r gmtime_r getpwuid_r ttyname_r clock_gettime \ readlink getgid getpid getppid getuid geteuid umask getegid \ - secure_getenv __secure_getenv mkostemp strnlen strndup strtok_r) + secure_getenv __secure_getenv mkostemp strnlen strndup strtok_r newlocale \ + freelocale uselocale strerror_l) fi # Check strerror_r, cannot be above as versions with two and three arguments exist diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index 1e0d092..0ff5dcc 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -32,6 +32,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include gthr.h + +/* POSIX 2008 specifies that the extended locale stuff is found in + locale.h, but some systems have them in xlocale.h. */ + +#include locale.h + +#ifdef HAVE_XLOCALE_H +#include xlocale.h +#endif + + /* Forward declarations. */ struct st_parameter_dt; typedef struct stream stream; @@ -40,6 +51,11 @@ struct format_data; typedef struct fnode fnode; struct gfc_unit; +#ifdef HAVE_NEWLOCALE +/* We have POSIX 2008 extended locale stuff. */ +extern locale_t c_locale; +#endif + /* Macros for testing what kinds of I/O we are doing. */ @@ -450,6 +466,9 @@ typedef struct st_parameter_dt char *line_buffer; struct format_data *fmt; namelist_info *ionml; +#ifdef HAVE_NEWLOCALE + locale_t old_locale; +#endif /* Current position within the look-ahead line buffer. */ int line_buffer_pos; /* Storage area for values except for strings. Must be diff --git
Re: [PATCH, testsuite, obvious] Do not produce optimized dump in devirt-4[45].C
Hello! g++.dg/ipa/devirt-44.C and g++.dg/ipa/devirt-45.C leave behind an optimized dump which they don't even use. Fixed thusly, tested by runing make -k check RUNTESTFLAGS=dg.exp=ipa/*.C, will commit shortly as obvious. 2014-11-06 Martin Jambor mjam...@suse.cz * g++.dg/ipa/devirt-44.C: Do not produce tree optimized dump. * g++.dg/ipa/devirt-45.C: Likewise. Already fixed in r217097 [1] ... [1] https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=217097 Uros.
Re: [PATCH] Limit removal of UBSAN_NULL checks
On Thu, Nov 06, 2014 at 11:10:37AM +0100, Jakub Jelinek wrote: Sorry for being slow on this, but in the current algorithm you are using the latest vector element from each bb only anyway, so the tree_int_cst_compare (cur_align, align) == 0 is unnecessary, even if the condition isn't true, and thus in your patch we would not pop the old one, we'd still never use the not popped element, as the stmt pushed after it would be used instead, or both stmts popped up if the domwalk left the bb already. Ah, yeah, after some drawing on paper, I agree. I should've notice that earlier :/. If you want, commit your patch as is and in test the one liner together with some other change. I'll do that. Thanks, Marek
Re: Fix ICE with thunks taking argument passed by reference
On Thu, 6 Nov 2014, Jan Hubicka wrote: Hi, PR63573 is about ICE when expanding thunk call for function taking as a parameter structure passed by reference. This structure in fact contains only one integer and thus it is promoted to register by argument setup in function.c (as an optimization). This is an sensible optimization, but when expanding the tailcall we need memory location to store the value into to pass it again by reference. Because we lost the original memory location we ICE because we have addressable flag set on decl whose DECL_RTL is register. This patch fixes it up by reverting to original memory location in calls.c. This is of course not safe in general because the register value may be hcanged, but the path is executed only when THUNK flag of the call statement is set and that is set only in thunks where the values are not updated. Ugly hack but I can not think of better way to fix the ugly hacks already in there to make thunk expansion happen in tailcall. This fixed boostrap on ppc64-linux and the set of testsuite failures match ones before the bug was introduced. OK? PR bootstrap/63573 * calls.c (initialize_argument_information): When emitting thunk call use original memory placement of the argument. Index: calls.c === --- calls.c (revision 216942) +++ calls.c (working copy) @@ -1210,6 +1211,15 @@ initialize_argument_information (int num TREE_CODE (base) != SSA_NAME (!DECL_P (base) || MEM_P (DECL_RTL (base) { + /* Argument setup code may have copied the value to register. We + that optimization now because the tail call code must use + the original location. */ The last sentence probably misses some words. + if (TREE_CODE (args[i].tree_value) == PARM_DECL +!MEM_P (DECL_RTL (args[i].tree_value)) +DECL_INCOMING_RTL (args[i].tree_value) +MEM_P (DECL_INCOMING_RTL (args[i].tree_value))) + set_decl_rtl (args[i].tree_value, DECL_INCOMING_RTL (args[i].tree_value)); Please fix the long line. I don't know calls.c so no further comments or approval from me. Sorry, Richard.
RE: [PATCH, C++] Fix PR63366: __complex not equivalent to __complex double in C++
From: Jason Merrill [mailto:ja...@redhat.com] Sent: Wednesday, October 29, 2014 4:43 PM Since this is a GNU extension, I think we want to be compatible with the C front end, which has else if (specs-complex_p) { specs-typespec_word = cts_double; pedwarn (specs-locations[cdw_complex], OPT_Wpedantic, ISO C does not support plain %complex% meaning %double complex%); } right after the code that parallels the block I mentioned in my earlier mail. What about the following patch? diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d26a432..d3ab81c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9158,11 +9158,23 @@ grokdeclarator (const cp_declarator *declarator, } /* No type at all: default to `int', and set DEFAULTED_INT because it was not a user-defined typedef. */ - if (type == NULL_TREE (signed_p || unsigned_p || long_p || short_p)) + if (type == NULL_TREE) { - /* These imply 'int'. */ - type = integer_type_node; - defaulted_int = 1; + if (signed_p || unsigned_p || long_p || short_p) + { + /* These imply 'int'. */ + type = integer_type_node; + defaulted_int = 1; + } + /* If we just have complex, it is equivalent to complex double. */ + else if (!longlong !explicit_int128 + decl_spec_seq_has_spec_p (declspecs, ds_complex)) + { + type = double_type_node; + pedwarn (declspecs-locations[ds_complex], OPT_Wpedantic, + ISO C++ does not support plain %complex% meaning + %double complex%); + } } /* Gather flags. */ explicit_int = declspecs-explicit_int_p; @@ -9345,13 +9357,8 @@ grokdeclarator (const cp_declarator *declarator, { if (TREE_CODE (type) != INTEGER_TYPE TREE_CODE (type) != REAL_TYPE) error (complex invalid for %qs, name); - /* If we just have complex, it is equivalent to -complex double, but if any modifiers at all are specified it is -the complex form of TYPE. E.g, complex short is -complex short int. */ - else if (defaulted_int ! longlong ! explicit_int128 - ! (long_p || short_p || signed_p || unsigned_p)) - type = complex_double_type_node; + /* If a modifier is specified, the resulting complex is the complex +form of TYPE. E.g, complex short is complex short int. */ else if (type == integer_type_node) type = complex_integer_type_node; else if (type == float_type_node) diff --git a/gcc/testsuite/g++.dg/torture/pr63366.C b/gcc/testsuite/g++.dg/torture/pr63366.C new file mode 100644 index 000..f089123 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63366.C @@ -0,0 +1,10 @@ +// { dg-do run } +// { dg-options -pedantic } + +#include typeinfo + +int +main (void) +{ + return typeid (__complex) != typeid (__complex double); /* { dg-warning ISO C\\+\\+ does not support plain 'complex' meaning 'double complex' } */ +} ChangeLog entries would be as follows: *** cp/ChangeLog *** 2014-11-03 Thomas Preud'homme thomas.preudho...@arm.com PR C++/63366 * decl.c (grokdeclarator): Set default for complex alone to complex double and issue a pedantic warn for it. *** testsuite/ChangeLog *** 2014-11-03 Thomas Preud'homme thomas.preudho...@arm.com PR C++/63366 * g++.dg/torture/pr63366.C: New test. Ok for trunk? Best regards, Thomas
Re: [libcc1, build] Enable libcc1 on Solaris
Hi Phil, The configure change is fine. Also the include. (From a libcc authorship point of view). I am not aware of the history of AF_UNIX over AF_LOCAL so I have no comment on that. Please await permission the glibc manual states AF_UNIX This is a synonym for AF_LOCAL. Although AF_LOCAL is mandated by POSIX.1g, AF_UNIX is portable to more systems. AF_UNIX was the traditional name stemming from BSD, so even most POSIX systems support it. It is also the name of choice in the Unix98 specification. (The same is true for PF_UNIX vs. PF_LOCAL). (http://www.gnu.org/software/libc/manual/html_node/Address-Formats.html) from a GCC maintainer (I am not one). You probably should become the libcc1 maintainer, though :-) Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [libcc1, build] Enable libcc1 on Solaris
On 06/11/14 11:33, Rainer Orth wrote: Hi Phil, The configure change is fine. Also the include. (From a libcc authorship point of view). I am not aware of the history of AF_UNIX over AF_LOCAL so I have no comment on that. Please await permission the glibc manual states AF_UNIX This is a synonym for AF_LOCAL. Although AF_LOCAL is mandated by POSIX.1g, AF_UNIX is portable to more systems. AF_UNIX was the traditional name stemming from BSD, so even most POSIX systems support it. It is also the name of choice in the Unix98 specification. (The same is true for PF_UNIX vs. PF_LOCAL). (http://www.gnu.org/software/libc/manual/html_node/Address-Formats.html) OK that looks great. Thanks for explaining! from a GCC maintainer (I am not one). You probably should become the libcc1 maintainer, though :-) I am quite new to GCC (the vast majority of my work is over in GDB), so not sure how these things work. I'll be happy to do what the GCC community think best. We plan to extend libcc1 to include C++ as a next step (after the GDB patches are approved). So I will be around a lot. Cheers Phil
[PATCH, Pointer Bounds Checker, Builtins instrumentation 1/5] Builtin codes and decls
Hi, This is the first patch in a series to enable builtin function calls instrumentation by Poitner Bounds Checker. Previously builtins instrumentation was disabled in checker because it allowed two function calls with the same function code have different set of arguments. Here I try another approach where function codes are not reused by instrumented calls. Basic idea is to provide each function code with a pair to be used for instrumented call. It's achieved by additional include of builtins.def into built_in_class enum. Instrumented builtins shouldn't be visible for users. Also when checker is disabled we don't need decls for them at all. Therefore function decls for instrumented function are not created at compiler initialization, but lazily created on demand. These decls are mainly requested by checker itslef and by LTO streamer to read instrumented code. This patch introduces new builtin codes, functions for builtin clones creation and modifies LTO streamer. Thanks, Ilya -- 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * tree-core.h (built_in_class): Add builtin codes to be used by Pointer Bounds Checker for instrumented builtin functions. * tree-streamer-in.c: Include ipa-chkp.h. (streamer_get_builtin_tree): Create instrumented decl if required. * ipa-chkp.h (chkp_maybe_clone_builtin_fndecl): New. * ipa-chkp.c (chkp_build_instrumented_fndecl): Support builtin function decls. (chkp_maybe_clone_builtin_fndecl): New. (chkp_maybe_create_clone): Support builtin function decls. diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c index f910583..691adfd 100644 --- a/gcc/ipa-chkp.c +++ b/gcc/ipa-chkp.c @@ -130,6 +130,16 @@ chkp_build_instrumented_fndecl (tree fndecl) make own copy. */ DECL_ATTRIBUTES (new_decl) = copy_list (DECL_ATTRIBUTES (fndecl)); + /* Change builtin function code. */ + if (DECL_BUILT_IN (new_decl)) +{ + gcc_assert (DECL_BUILT_IN_CLASS (new_decl) == BUILT_IN_NORMAL); + gcc_assert (DECL_FUNCTION_CODE (new_decl) BEGIN_CHKP_BUILTINS); + DECL_FUNCTION_CODE (new_decl) + = (enum built_in_function)(DECL_FUNCTION_CODE (new_decl) + + BEGIN_CHKP_BUILTINS + 1); +} + return new_decl; } @@ -355,6 +365,30 @@ chkp_add_bounds_params_to_function (tree fndecl) chkp_copy_function_type_adding_bounds (TREE_TYPE (fndecl)); } +tree +chkp_maybe_clone_builtin_fndecl (tree fndecl) +{ + tree clone; + enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); + + gcc_assert (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL + fcode BEGIN_CHKP_BUILTINS); + + fcode = (enum built_in_function) (fcode + BEGIN_CHKP_BUILTINS + 1); + clone = builtin_decl_explicit (fcode); + if (clone) +return clone; + + clone = chkp_build_instrumented_fndecl (fndecl); + chkp_add_bounds_params_to_function (clone); + + gcc_assert (DECL_FUNCTION_CODE (clone) == fcode); + + set_builtin_decl (fcode, clone, false); + + return clone; +} + /* Return clone created for instrumentation of NODE or NULL. */ cgraph_node * @@ -365,6 +399,52 @@ chkp_maybe_create_clone (tree fndecl) gcc_assert (!node-instrumentation_clone); + if (DECL_BUILT_IN (fndecl) + (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL + || DECL_FUNCTION_CODE (fndecl) = BEGIN_CHKP_BUILTINS)) +return NULL; + + clone = node-instrumented_version; + + /* For builtin functions we may loose and recreate + cgraph node. We should check if we already have + instrumented version. */ + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL + fndecl == builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)) + !clone) +{ + enum built_in_function fncode = DECL_FUNCTION_CODE (fndecl); + tree new_decl; + + fncode = (enum built_in_function) (fncode + BEGIN_CHKP_BUILTINS + 1); + new_decl = builtin_decl_explicit (fncode); + + /* We've actually already created an instrumented clone once. +Restore it. */ + if (new_decl) + { + clone = cgraph_node::get (new_decl); + + if (!clone) + { + gcc_assert (!gimple_has_body_p (fndecl)); + clone = cgraph_node::get_create (new_decl); + clone-externally_visible = node-externally_visible; + clone-local = node-local; + clone-address_taken = node-address_taken; + clone-thunk = node-thunk; + clone-alias = node-alias; + clone-weakref = node-weakref; + clone-cpp_implicit_alias = node-cpp_implicit_alias; + clone-orig_decl = fndecl; + clone-instrumentation_clone = true; + } + + clone-instrumented_version = node; + node-instrumented_version = clone; + } +} + if (!clone) { tree new_decl = chkp_build_instrumented_fndecl (fndecl); @@ -409,6 +489,15 @@
[Patchv3] Control SRA and IPA-SRA by a param rather than MOVE_RATIO
On Fri, Oct 31, 2014 at 10:46:12AM +, Richard Biener wrote: On Wed, Oct 29, 2014 at 3:39 PM, James Greenhalgh wrote: I suppose I could port any target with a definition of MOVE_RATIO to override the default parameter value in their option overriding code, but that makes this a very large patch set (many targets define MOVE_RATIO). Is this an avenue worth exploring? I agree the very special target hook is not ideal. Hi, Did you have any further thoughts on this? I'm still unable to come up with a way to set these parameters which allows them to default to their current (MOVE_RATIO derived) values. If the only way to make this work is to add code to TARGET_OPTION_OVERRIDE for all targets that define MOVE_RATIO, then I suppose I can do that, but I'd prefer a neater way to make it work, if you can think of one. Maybe instead of putting the code in opts.c put it right before we call targetm.target_option.override () in toplev.c:process_options. With a comment on why it cannot be in opts.c. Ah, that makes sense. The (much simplified) patch then looks like this... Bootstrapped on x86_64, ARM and AArch64 with no issues. OK? Thanks, James --- gcc/ 2014-11-06 James Greenhalgh james.greenha...@arm.com * params.def (sra-max-scalarization-size-Ospeed): New. (sra-max-scalarization-size-Osize): Likewise. * doc/invoke.texi (sra-max-scalarization-size-Ospeed): Document. (sra-max-scalarization-size-Osize): Likewise. * toplev.c (process_options): Set default values for new parameters. * tree-sra.c (analyze_all_variable_accesses): Use new parameters. * targhooks.c (get_move_ratio): Remove static designator. * target.h (get_move_ratio): Declare. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 792f25b..fcc5c89 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10403,6 +10403,16 @@ parameters only when their cumulative size is less or equal to @option{ipa-sra-ptr-growth-factor} times the size of the original pointer parameter. +@item sra-max-scalarization-size-Ospeed +@item sra-max-scalarization-size-Osize +The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to +replace scalar parts of aggregates with uses of independent scalar +variables. These parameters control the maximum size, in storage units, +of aggregate which will be considered for replacement when compiling for +speed +(@option{sra-max-scalarization-size-Ospeed}) or size +(@option{sra-max-scalarization-size-Osize}) respectively. + @item tm-max-aggregate-size When making copies of thread-local variables in a transaction, this parameter specifies the size in bytes after which variables are diff --git a/gcc/params.def b/gcc/params.def index beff7e6..7cba3b3 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -950,6 +950,18 @@ DEFPARAM (PARAM_TM_MAX_AGGREGATE_SIZE, pairs, 9, 0, 0) +DEFPARAM (PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED, + sra-max-scalarization-size-Ospeed, + Maximum size, in storage units, of an aggregate which should be + considered for scalarization when compiling for speed, + 0, 0, 0) + +DEFPARAM (PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE, + sra-max-scalarization-size-Osize, + Maximum size, in storage units, of an aggregate which should be + considered for scalarization when compiling for size, + 0, 0, 0) + DEFPARAM (PARAM_IPA_CP_VALUE_LIST_SIZE, ipa-cp-value-list-size, Maximum size of a list of values associated with each parameter for diff --git a/gcc/target.h b/gcc/target.h index 40d7841..65250ed 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -102,6 +102,10 @@ extern int elf_record_gcc_switches (print_switch_type type, const char *); we disable such optimizations on such targets, using this function. */ extern bool target_default_pointer_address_modes_p (void); +/* For hooks which use the MOVE_RATIO macro, this gives the legacy default + behaviour. */ +extern unsigned int get_move_ratio (bool); + struct stdarg_info; struct spec_info_def; struct hard_reg_set_container; diff --git a/gcc/targhooks.c b/gcc/targhooks.c index eef3d45..d798217 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1409,7 +1409,7 @@ default_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, /* For hooks which use the MOVE_RATIO macro, this gives the legacy default behaviour. SPEED_P is true if we are compiling for speed. */ -static unsigned int +unsigned int get_move_ratio (bool speed_p ATTRIBUTE_UNUSED) { unsigned int move_ratio; diff --git a/gcc/toplev.c b/gcc/toplev.c index 2c570d4..71589f2 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1265,6 +1265,20 @@ process_options (void) so we can correctly initialize debug output. */ no_backend = lang_hooks.post_options (main_input_filename); + /* Set default values for parameters relation to the Scalar Reduction + of Aggregates passes (SRA and IP-SRA). We must do this here,
Re: [gofrontend-dev] [PATCH 4/4] Gccgo port to s390[x] -- part II
On Tue, Nov 04, 2014 at 08:16:51PM -0800, Ian Taylor wrote: The way to do it is not by copying the test. If the test needs to be customized, add additional files that use // +build lines to pick which files is built. Move them into a directory, like method4.go or other tests that use rundir. Currently go-test.exp does not look at the build lines of the files in subdirectories. Before I add that to the gcc testsuite start adding that, is it certain that the golang testsuite will be able to understand that and compile only the requested files? Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany
[PATCH, Pointer Bounds Checker, Builtins instrumentation 2/5] Instrument builtin calls
Hi, This patch enables instrumentation of chosen builtin calls. Thanks, Ilya -- 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * ipa-chkp.c (chkp_versioning): Clone builtin functions. (chkp_instrument_normal_builtin): New. (chkp_add_bounds_to_call_stmt): Support builtin functions. (chkp_replace_function_pointer): Likewise. diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c index 691adfd..ee7de48 100644 --- a/gcc/ipa-chkp.c +++ b/gcc/ipa-chkp.c @@ -577,8 +577,9 @@ chkp_versioning (void) (!flag_chkp_instrument_marked_only || lookup_attribute (bnd_instrument, DECL_ATTRIBUTES (node-decl))) - /* No builtins instrumentation for now. */ - DECL_BUILT_IN_CLASS (node-decl) == NOT_BUILT_IN) + (!DECL_BUILT_IN (node-decl) + || (DECL_BUILT_IN_CLASS (node-decl) == BUILT_IN_NORMAL + DECL_FUNCTION_CODE (node-decl) BEGIN_CHKP_BUILTINS))) chkp_maybe_create_clone (node-decl); } diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index df7d425..9e2efdb 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -1586,6 +1586,50 @@ chkp_find_bound_slots (const_tree type, bitmap res) chkp_find_bound_slots_1 (type, res, 0); } +/* Return 1 if call to FNDECL should be instrumented + and 0 otherwise. */ + +static bool +chkp_instrument_normal_builtin (tree fndecl) +{ + switch (DECL_FUNCTION_CODE (fndecl)) +{ +case BUILT_IN_STRLEN: +case BUILT_IN_STRCPY: +case BUILT_IN_STRNCPY: +case BUILT_IN_STPCPY: +case BUILT_IN_STPNCPY: +case BUILT_IN_STRCAT: +case BUILT_IN_STRNCAT: +case BUILT_IN_MEMCPY: +case BUILT_IN_MEMPCPY: +case BUILT_IN_MEMSET: +case BUILT_IN_MEMMOVE: +case BUILT_IN_BZERO: +case BUILT_IN_STRCMP: +case BUILT_IN_STRNCMP: +case BUILT_IN_BCMP: +case BUILT_IN_MEMCMP: +case BUILT_IN_MEMCPY_CHK: +case BUILT_IN_MEMPCPY_CHK: +case BUILT_IN_MEMMOVE_CHK: +case BUILT_IN_MEMSET_CHK: +case BUILT_IN_STRCPY_CHK: +case BUILT_IN_STRNCPY_CHK: +case BUILT_IN_STPCPY_CHK: +case BUILT_IN_STPNCPY_CHK: +case BUILT_IN_STRCAT_CHK: +case BUILT_IN_STRNCAT_CHK: +case BUILT_IN_MALLOC: +case BUILT_IN_CALLOC: +case BUILT_IN_REALLOC: + return 1; + +default: + return 0; +} +} + /* Add bound arguments to call statement pointed by GSI. Also performs a replacement of user checker builtins calls with internal ones. */ @@ -1619,7 +1663,7 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) DECL_FUNCTION_CODE (fndecl) == BUILT_IN_OBJECT_SIZE) return; - /* Donothing for calls to legacy functions. */ + /* Do nothing for calls to legacy functions. */ if (fndecl lookup_attribute (bnd_legacy, DECL_ATTRIBUTES (fndecl))) return; @@ -1686,11 +1730,18 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) if (!flag_chkp_instrument_calls) return; - /* Avoid instrumented builtin functions for now. Due to IPA - it also means we have to avoid instrumentation of indirect - calls. */ - if (fndecl DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN) -return; + /* We instrument only some subset of builtins. We also instrument + builtin calls to be inlined. */ + if (fndecl + DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL + !chkp_instrument_normal_builtin (fndecl)) +{ + struct cgraph_node *clone = chkp_maybe_create_clone (fndecl); + if (!clone + || !gimple_has_body_p (clone-decl) + || !lookup_attribute (always_inline, DECL_ATTRIBUTES (fndecl))) + return; +} /* If function decl is available then use it for formal arguments list. Otherwise use function type. */ @@ -1764,14 +1815,6 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) } new_args.release (); - /* If we call built-in function and pass no bounds then - we do not need to change anything. */ - if (new_call == call - fndecl - DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - fndecl == builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) - return; - /* For direct calls fndecl is replaced with instrumented version. */ if (fndecl) { @@ -3905,15 +3948,21 @@ chkp_replace_function_pointer (tree *op, int *walk_subtrees, { if (TREE_CODE (*op) == FUNCTION_DECL !lookup_attribute (bnd_legacy, DECL_ATTRIBUTES (*op)) - /* Do not replace builtins for now. */ - DECL_BUILT_IN_CLASS (*op) == NOT_BUILT_IN) + (DECL_BUILT_IN_CLASS (*op) == NOT_BUILT_IN + /* For builtins we replace pointers only for selected +function and functions having definitions. */ + || (DECL_BUILT_IN_CLASS (*op) == BUILT_IN_NORMAL + (chkp_instrument_normal_builtin (*op) + || gimple_has_body_p (*op) { struct cgraph_node *node = cgraph_node::get_create (*op); +
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Richard Biener wrote: +/* Simplify (A B) OP0 (C B) to (A OP0 C) B. */ +/* (x | CST1) CST2 - (x CST2) | (CST1 CST2) */ As soon as there are 2+ operations in the result, this comment in fwprop_ssa_val becomes outdated, no? /* We continue matching along SSA use-def edges for SSA names that are not single-use. Currently there are no patterns that would cause any issues with that. */ (I am not opposing the patch, just trying to understand how things work for when I'll propose new patterns) -- Marc Glisse
[PATCH, Pointer Bounds Checker, Builtins instrumentation 3/5] Expand instrumented builtin calls
Hi, This patch adds support of instrumented builtin calls in expand. Calls are mostly expanded as calls. But some of them reuse existing string function calls expand functions (memcpy expand was slightly refactored for that). This is the last enabling patch in this series. Remaining two patches are performance ones. Thanks, Ilya -- 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * builtins.c (expand_builtin_memcpy_args): New. (expand_builtin_memcpy): Call expand_builtin_memcpy_args. (expand_builtin_memcpy_with_bounds): New. (expand_builtin_mempcpy_with_bounds): New. (expand_builtin_mempcpy_args): Add orig_exp arg. Support BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK (expand_builtin_memset_with_bounds): New. (expand_builtin_memset_args): Support BUILT_IN_CHKP_MEMSET_NOBND_NOCHK. (expand_builtin_with_bounds): New. * builtins.h (expand_builtin_with_bounds): New. * expr.c (expand_expr_real_1): Support instrumented builtin calls. diff --git a/gcc/builtins.c b/gcc/builtins.c index 71fbf09..b34f855 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -133,15 +133,19 @@ static rtx expand_builtin_strcmp (tree, rtx); static rtx expand_builtin_strncmp (tree, rtx, machine_mode); static rtx builtin_memcpy_read_str (void *, HOST_WIDE_INT, machine_mode); static rtx expand_builtin_memcpy (tree, rtx); +static rtx expand_builtin_memcpy_with_bounds (tree, rtx); +static rtx expand_builtin_memcpy_args (tree, tree, tree, rtx, tree); static rtx expand_builtin_mempcpy (tree, rtx, machine_mode); +static rtx expand_builtin_mempcpy_with_bounds (tree, rtx, machine_mode); static rtx expand_builtin_mempcpy_args (tree, tree, tree, rtx, - machine_mode, int); + machine_mode, int, tree); static rtx expand_builtin_strcpy (tree, rtx); static rtx expand_builtin_strcpy_args (tree, tree, rtx); static rtx expand_builtin_stpcpy (tree, rtx, machine_mode); static rtx expand_builtin_strncpy (tree, rtx); static rtx builtin_memset_gen_str (void *, HOST_WIDE_INT, machine_mode); static rtx expand_builtin_memset (tree, rtx, machine_mode); +static rtx expand_builtin_memset_with_bounds (tree, rtx, machine_mode); static rtx expand_builtin_memset_args (tree, tree, tree, rtx, machine_mode, tree); static rtx expand_builtin_bzero (tree); static rtx expand_builtin_strlen (tree, rtx, machine_mode); @@ -3176,6 +3180,81 @@ determine_block_size (tree len, rtx len_rtx, GET_MODE_MASK (GET_MODE (len_rtx))); } +/* Helper function to do the actual work for expand_builtin_memcpy. */ + +static rtx +expand_builtin_memcpy_args (tree dest, tree src, tree len, rtx target, tree exp) +{ + const char *src_str; + unsigned int src_align = get_pointer_alignment (src); + unsigned int dest_align = get_pointer_alignment (dest); + rtx dest_mem, src_mem, dest_addr, len_rtx; + HOST_WIDE_INT expected_size = -1; + unsigned int expected_align = 0; + unsigned HOST_WIDE_INT min_size; + unsigned HOST_WIDE_INT max_size; + unsigned HOST_WIDE_INT probable_max_size; + + /* If DEST is not a pointer type, call the normal function. */ + if (dest_align == 0) +return NULL_RTX; + + /* If either SRC is not a pointer type, don't do this + operation in-line. */ + if (src_align == 0) +return NULL_RTX; + + if (currently_expanding_gimple_stmt) +stringop_block_profile (currently_expanding_gimple_stmt, + expected_align, expected_size); + + if (expected_align dest_align) +expected_align = dest_align; + dest_mem = get_memory_rtx (dest, len); + set_mem_align (dest_mem, dest_align); + len_rtx = expand_normal (len); + determine_block_size (len, len_rtx, min_size, max_size, + probable_max_size); + src_str = c_getstr (src); + + /* If SRC is a string constant and block move would be done + by pieces, we can avoid loading the string from memory + and only stored the computed constants. */ + if (src_str + CONST_INT_P (len_rtx) + (unsigned HOST_WIDE_INT) INTVAL (len_rtx) = strlen (src_str) + 1 + can_store_by_pieces (INTVAL (len_rtx), builtin_memcpy_read_str, + CONST_CAST (char *, src_str), + dest_align, false)) +{ + dest_mem = store_by_pieces (dest_mem, INTVAL (len_rtx), + builtin_memcpy_read_str, + CONST_CAST (char *, src_str), + dest_align, false, 0); + dest_mem = force_operand (XEXP (dest_mem, 0), target); + dest_mem = convert_memory_address (ptr_mode, dest_mem); + return dest_mem; +} + + src_mem = get_memory_rtx (src, len); + set_mem_align (src_mem, src_align); + + /* Copy word part most expediently. */ + dest_addr = emit_block_move_hints (dest_mem, src_mem, len_rtx, +
Re: [PATCH] Correctly check dg-require-effective-target in avx512 tests.
On 05 Nov 17:17, Uros Bizjak wrote: On Wed, Nov 5, 2014 at 5:14 PM, Ilya Tocar tocarip.in...@gmail.com wrote: Hi, Currently we only check for dg-require-effective-target avx512vl in avx512vl tests. We should also check for avx512dq/avx512bw. Patch bwllow does this. Ok for trunk? OK, if tested on some simulator. I've tested it on sde [1], but those changes are compile-time only. Committed as rev 217188. [1]https://software.intel.com/en-us/articles/intel-software-development-emulator
Re: [PING^3][PATCH] Warn about unclosed pragma omp declare target.
Ping. On 30 Oct 18:31, Ilya Tocar wrote: Ping. On 20 Oct 19:26, Ilya Tocar wrote: Ping. On 02 Oct 17:38, Ilya Tocar wrote: Ping. On 15 Aug 16:26, Ilya Tocar wrote: Ping. On 29 Jul 18:45, Ilya Tocar wrote: Hi, As discussed here in https://gcc.gnu.org/ml/gcc/2014-01/msg00189.html Gcc should complain about pragma omp declare target without corresponding pragma omp end declare target. This patch adds a warning for those cases. Bootstraps/passes make-check. Ok for trunk? ChangeLog: 2014-07-29 Ilya Tocar ilya.to...@intel.com * c-decl.c (omp_declare_target_location_stack): New. * c-lang.h (omp_declare_target_location_stack): Declare. * c-parser.c (warn_unclosed_pragma_omp_target): New. (c_parser_translation_unit): Call it. (c_parser_omp_declare_target): Remeber location. (c_parser_omp_end_declare_target): Forget location. And ChangeLog for testsuite: 2014-07-29 Ilya Tocar ilya.to...@intel.com * gcc.dg/gomp//target-3.c: New testcase. --- gcc/c/c-decl.c | 3 +++ gcc/c/c-lang.h | 3 +++ gcc/c/c-parser.c | 22 +- gcc/testsuite/gcc.dg/gomp/target-3.c | 33 + 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/target-3.c diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 2a4b439..2dd5b2c 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -158,6 +158,9 @@ enum machine_mode c_default_pointer_mode = VOIDmode; /* If non-zero, implicit omp declare target attribute is added into the attribute lists. */ int current_omp_declare_target_attribute; + +/* Holds locations of currently open omp declare target pragmas. */ +veclocation_t omp_declare_target_location_stack; /* Each c_binding structure describes one binding of an identifier to a decl. All the decls in a scope - irrespective of namespace - are diff --git a/gcc/c/c-lang.h b/gcc/c/c-lang.h index e974906..cef995c 100644 --- a/gcc/c/c-lang.h +++ b/gcc/c/c-lang.h @@ -59,4 +59,7 @@ struct GTY(()) language_function { attribute lists. */ extern GTY(()) int current_omp_declare_target_attribute; +/* Holds locations of currently open omp declare target pragmas. */ +extern veclocation_t omp_declare_target_location_stack; + #endif /* ! GCC_C_LANG_H */ diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index e32bf04..0b96fe9 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1255,6 +1255,8 @@ static bool c_parser_cilk_verify_simd (c_parser *, enum pragma_context); static tree c_parser_array_notation (location_t, c_parser *, tree, tree); static tree c_parser_cilk_clause_vectorlength (c_parser *, tree, bool); +static void warn_unclosed_pragma_omp_target (); + /* Parse a translation unit (C90 6.7, C99 6.9). translation-unit: @@ -1290,6 +1292,8 @@ c_parser_translation_unit (c_parser *parser) } while (c_parser_next_token_is_not (parser, CPP_EOF)); } + + warn_unclosed_pragma_omp_target (); } /* Parse an external declaration (C90 6.7, C99 6.9). @@ -13068,8 +13072,10 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, static void c_parser_omp_declare_target (c_parser *parser) { + location_t loc = c_parser_peek_token (parser)-location; c_parser_skip_to_pragma_eol (parser); current_omp_declare_target_attribute++; + omp_declare_target_location_stack.safe_push (loc); } static void @@ -13104,7 +13110,10 @@ c_parser_omp_end_declare_target (c_parser *parser) error_at (loc, %#pragma omp end declare target% without corresponding %#pragma omp declare target%); else -current_omp_declare_target_attribute--; +{ + current_omp_declare_target_attribute--; + omp_declare_target_location_stack.pop (); +} } @@ -14267,4 +14276,15 @@ c_parser_array_notation (location_t loc, c_parser *parser, tree initial_index, return value_tree; } +static void +warn_unclosed_pragma_omp_target () +{ + int i; + for (i = 0; i current_omp_declare_target_attribute; i++) +warning_at (omp_declare_target_location_stack[i], 0, + %#pragma omp declare target% without corresponding + %#pragma omp end declare target%); +
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Richard Biener wrote: +/* Try simple folding for X op !X, and X op X with the help + of the truth_valued_p and logical_inverted_value predicates. */ +(match truth_valued_p + @0 + (if (INTEGRAL_TYPE_P (type) TYPE_PRECISION (type) == 1))) +(for op (lt le eq ne ge gt truth_and truth_andif truth_or truth_orif truth_xor) + (match truth_valued_p + (op @0 @1))) +(match truth_valued_p + (truth_not @0)) + +(match (logical_inverted_value @0) + (bit_not truth_valued_p@0)) +(match (logical_inverted_value @0) + (eq @0 integer_zerop) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (ne truth_valued_p@0 integer_onep) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) + +/* X !X - 0. */ +(simplify + (bit_and:c @0 (logical_inverted_value @0)) + { build_zero_cst (type); }) +/* X | !X and X ^ !X - 1, , if X is truth-valued. */ +(for op (bit_ior bit_xor) + (simplify + (op:c truth_valued_p@0 (logical_inverted_value @0)) + { build_one_cst (type); })) Shouldn't that be build_true_cst (type) so it is -1 for vectors? It seems that it could match: vec a, b; vec c=ab; vec d=~c; vec e=c|d; -- Marc Glisse
[PATCH, Pointer Bounds Checker, Builtins instrumentation 4/5] Use alternative instrumented string function calls
Hi, This patch adds instrumentation optimization to use string function with no checks and/or bounds copy. Thanks, Ilya -- gcc/ 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * tree-chkp-opt.c (chkp_get_nobnd_fndecl): New. (chkp_get_nochk_fndecl): New. (chkp_optimize_string_function_calls): New. (chkp_opt_execute): Call chkp_optimize_string_function_calls. * tree-cfg.h (insert_cond_bb): New. * tree-cfg.c (insert_cond_bb): New. gcc/testsuite/ 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * gcc.target/i386/chkp-stropt-1.c: New. * gcc.target/i386/chkp-stropt-2.c: New. * gcc.target/i386/chkp-stropt-3.c: New. * gcc.target/i386/chkp-stropt-4.c: New. * gcc.target/i386/chkp-stropt-5.c: New. * gcc.target/i386/chkp-stropt-6.c: New. * gcc.target/i386/chkp-stropt-7.c: New. * gcc.target/i386/chkp-stropt-8.c: New. * gcc.target/i386/chkp-stropt-9.c: New. * gcc.target/i386/chkp-stropt-10.c: New. * gcc.target/i386/chkp-stropt-11.c: New. * gcc.target/i386/chkp-stropt-12.c: New. * gcc.target/i386/chkp-stropt-13.c: New. * gcc.target/i386/chkp-stropt-14.c: New. * gcc.target/i386/chkp-stropt-15.c: New. * gcc.target/i386/chkp-stropt-16.c: New. diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-1.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-1.c new file mode 100644 index 000..c005041 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-stropt-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions } */ +/* { dg-final { scan-tree-dump memcpy_nochk chkpopt } } */ +/* { dg-final { cleanup-tree-dump chkpopt } } */ + +#include string.h + +void test (int *buf1, int *buf2, size_t len) +{ + memcpy (buf1, buf2, len); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-10.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-10.c new file mode 100644 index 000..9b3c15f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-stropt-10.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions } */ +/* { dg-final { scan-tree-dump-not memset_nobnd chkpopt } } */ +/* { dg-final { cleanup-tree-dump chkpopt } } */ + +#include string.h + +void test (void *buf1, int c, size_t len) +{ + memset (buf1, c, len); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-11.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-11.c new file mode 100644 index 000..7ef079c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-stropt-11.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions } */ +/* { dg-final { scan-tree-dump-not memmove_nobnd chkpopt } } */ +/* { dg-final { cleanup-tree-dump chkpopt } } */ + +#include string.h + +void test (void *buf1, void *buf2, size_t len) +{ + memmove (buf1, buf2, len); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-12.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-12.c new file mode 100644 index 000..94e936d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-stropt-12.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions -D_GNU_SOURCE } */ +/* { dg-final { scan-tree-dump-not mempcpy_nobnd chkpopt } } */ +/* { dg-final { cleanup-tree-dump chkpopt } } */ + +#include string.h + +void test (void *buf1, void *buf2, size_t len) +{ + mempcpy (buf1, buf2, len); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-13.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-13.c new file mode 100644 index 000..f6d38c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-stropt-13.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions -fchkp-use-fast-string-functions } */ +/* { dg-final { scan-tree-dump memcpy_nobnd_nochk chkpopt } } */ +/* { dg-final { cleanup-tree-dump chkpopt } } */ + +#include string.h + +void test (int *buf1, int *buf2, size_t len) +{ + memcpy (buf1, buf2, len); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-14.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-14.c new file mode 100644 index 000..a7f43cb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-stropt-14.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions -fchkp-use-fast-string-functions } */ +/*
Re: [PATCH] PR36312
It looks like -soname, and libgnat-5.0.so both end up in the infiles array. I'm not sure if that's supposed to happen or not. On Wed, Nov 5, 2014 at 9:57 PM, Eric Botcazou ebotca...@adacore.com wrote: 2014-10-25 Anthony Brandon anthony.bran...@gmail.com PR driver/36312 * diagnostic-core.h: Add prototype for fatal_error. * diagnostic.c (fatal_error): New function fatal_error. * gcc.c (store_arg): Remove have_o_argbuf_index. (process_command): Check if input and output files are the same. * toplev.c (init_asm_output): Check if input and output files are the same. This breaks the build of the shared Ada library: rm -f rts/libgna*.so cd rts; `echo /home/eric/build/gcc/native/./gcc/xgcc - B/home/eric/build/gcc/native/./gcc/ -B/home/eric/install/gcc/x86_64-suse- linux/bin/ -B/home/eric/install/gcc/x86_64-suse-linux/lib/ -isystem /home/eric/install/gcc/x86_64-suse-linux/include -isystem /home/eric/install/gcc/x86_64-suse-linux/sys-include\ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` - shared -g -O2 \ -fpic \ -o libgnat-5.0.so \ a-assert.o a-btgbso.o a-calari.o a-calcon.o a-caldel.o a-calend.o a- calfor.o a-catizo.o a-cbdlli.o a-cbhama.o a-cbhase.o a-cbmutr.o a-cborma.o a- cborse.o a-cbprqu.o a-cbsyqu.o a-cdlili.o a-cfdlli.o a-cfhama.o a-cfhase.o a- cfinve.o a-cforma.o a-cforse.o a-cgaaso.o a-cgarso.o a-cgcaso.o a-chacon.o a- chahan.o a-charac.o a-chlat1.o a-chlat9.o a-chtgbk.o a-chtgbo.o a-chtgke.o a- chtgop.o a-chzla1.o a-chzla9.o a-cidlli.o a-cihama.o a-cihase.o a-cimutr.o a- ciorma.o a-ciormu.o a-ciorse.o a-clrefi.o a-coboho.o a-cobove.o a-cofove.o a- cogeso.o a-cohama.o a-cohase.o a-cohata.o a-coinho.o a-coinve.o a-colien.o a- colire.o a-comlin.o a-comutr.o a-contai.o a-convec.o a-coorma.o a-coormu.o a- coorse.o a-coprnu.o a-coteio.o a-crbltr.o a-crbtgk.o a-crbtgo.o a-crdlli.o a- csquin.o a-cuprqu.o a-cusyqu.o a-cwila1.o a-cwila9.o a-decima.o a-diocst.o a- direct.o a-direio.o a-dirval.o a-einuoc.o a-elchha.o a-envvar.o a-except.o a- exctra.o a-finali.o a-flteio.o a-fwteio.o a-fzteio.o a-inteio.o a-ioexce.o a- iteint.o a-iwteio.o a-izteio.o a-lcteio.o a-lfteio.o a-lfwtio.o a-lfztio.o a- liteio.o a-liwtio.o a-liztio.o a-llctio.o a-llftio.o a-llfwti.o a-llfzti.o a- llitio.o a-lliwti.o a-llizti.o a-locale.o a-ncelfu.o a-ngcefu.o a-ngcoar.o a- ngcoty.o a-ngelfu.o a-ngrear.o a-nlcefu.o a-nlcoar.o a-nlcoty.o a-nlelfu.o a- nllcar.o a-nllcef.o a-nllcty.o a-nllefu.o a-nllrar.o a-nlrear.o a-nscefu.o a- nscoty.o a-nselfu.o a-nucoar.o a-nucoty.o a-nudira.o a-nuelfu.o a-nuflra.o a- numaux.o a-numeri.o a-nurear.o a-rbtgbk.o a-rbtgbo.o a-rbtgso.o a-sbecin.o a- sbhcin.o a-sblcin.o a-scteio.o a-secain.o a-sequio.o a-sfecin.o a-sfhcin.o a- sflcin.o a-sfteio.o a-sfwtio.o a-sfztio.o a-shcain.o a-siocst.o a-siteio.o a- siwtio.o a-siztio.o a-slcain.o a-ssicst.o a-ssitio.o a-ssiwti.o a-ssizti.o a- stboha.o a-stfiha.o a-stmaco.o a-storio.o a-strbou.o a-stream.o a-strfix.o a- strhas.o a-string.o a-strmap.o a-strsea.o a-strsup.o a-strunb.o a-ststio.o a- stunau.o a-stunha.o a-stuten.o a-stwibo.o a-stwifi.o a-stwiha.o a-stwima.o a- stwise.o a-stwisu.o a-stwiun.o a-stzbou.o a-stzfix.o a-stzhas.o a-stzmap.o a- stzsea.o a-stzsup.o a-stzunb.o a-suecin.o a-suenco.o a-suenst.o a-suewst.o a- suezst.o a-suhcin.o a-sulcin.o a-suteio.o a-swbwha.o a-swfwha.o a-swmwco.o a- swunau.o a-swuwha.o a-swuwti.o a-szbzha.o a-szfzha.o a-szmzco.o a-szunau.o a- szuzha.o a-szuzti.o a-tags.o a-teioed.o a-textio.o a-tgdico.o a-tiboio.o a- ticoau.o a-ticoio.o a-tideau.o a-tideio.o a-tienau.o a-tienio.o a-tifiio.o a- tiflau.o a-tiflio.o a-tigeau.o a-tiinau.o a-tiinio.o a-timoau.o a-timoio.o a- tiocst.o a-tirsfi.o a-titest.o a-tiunio.o a-unccon.o a-uncdea.o a-undesu.o a- wichha.o a-wichun.o a-widcha.o a-witeio.o a-wrstfi.o a-wtcoau.o a-wtcoio.o a- wtcstr.o a-wtdeau.o a-wtdeio.o a-wtedit.o a-wtenau.o a-wtenio.o a-wtfiio.o a- wtflau.o a-wtflio.o a-wtgeau.o a-wtinau.o a-wtinio.o a-wtmoau.o a-wtmoio.o a- wttest.o a-wwboio.o a-wwunio.o a-zchara.o a-zchhan.o a-zchuni.o a-zrstfi.o a- ztcoau.o a-ztcoio.o a-ztcstr.o a-ztdeau.o a-ztdeio.o a-ztedit.o a-ztenau.o a- ztenio.o a-ztexio.o a-ztfiio.o a-ztflau.o a-ztflio.o a-ztgeau.o a-ztinau.o a- ztinio.o a-ztmoau.o a-ztmoio.o a-zttest.o a-zzboio.o a-zzunio.o ada.o calendar.o directio.o g-arrspl.o g-awk.o g-bubsor.o g-busora.o g-busorg.o g- byorma.o g-bytswa.o g-calend.o g-casuti.o g-catiio.o g-cgi.o g-cgicoo.o g- cgideb.o g-comlin.o g-comver.o g-crc32.o g-ctrl_c.o g-curexc.o g-debpoo.o g- debuti.o g-decstr.o g-deutst.o g-diopit.o g-dirope.o g-dynhta.o g-dyntab.o g- encstr.o g-enutst.o g-excact.o g-except.o g-exctra.o s-exctra.o g-expect.o g- exptty.o g-flocon.o g-forstr.o g-heasor.o g-hesora.o g-hesorg.o g-htable.o g- io.o g-io_aux.o g-locfil.o g-mbdira.o g-mbflra.o g-md5.o g-memdum.o g-moreex.o g-os_lib.o g-pehage.o g-rannum.o g-regexp.o g-regpat.o g-rewdat.o g-sechas.o
[PATCH, Pointer Bounds Checker, Builtins instrumentation 5/5] Support instrumented calls in strlen pass
Hi, This patch adds support of instrumented function calls into strlen pass. Whole series pass bootstrap and check on linux-x86_64. OK for trunk? Thanks, Ilya -- gcc/ 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * tree-ssa-strlen.c: include ipa-chkp.h. (get_string_length): Handle calls with bounds. (adjust_last_stmt): Likewise. (handle_builtin_strchr): Likewise. (handle_builtin_strcpy): Likewise. (handle_builtin_memcpy): Likewise. (handle_builtin_strcat): Likewise. gcc/testsuite/ 2014-11-06 Ilya Enkovich ilya.enkov...@intel.com * gcc.target/i386/chkp-strlen-1.c: New. * gcc.target/i386/chkp-strlen-2.c: New. * gcc.target/i386/chkp-strlen-3.c: New. * gcc.target/i386/chkp-strlen-4.c: New. * gcc.target/i386/chkp-strlen-5.c: New. diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-1.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-1.c new file mode 100644 index 000..ffb4f16 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-strlen-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen } */ +/* { dg-final { scan-tree-dump memcpy.chkp strlen } } */ +/* { dg-final { cleanup-tree-dump strlen } } */ + +#include string.h + +char *test (char *str1, char *str2) +{ + size_t len = strlen (str2); + strcpy (str1, str2); + return str1 + len; +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-2.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-2.c new file mode 100644 index 000..1ce426d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-strlen-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen } */ +/* { dg-final { scan-tree-dump-not strlen strlen } } */ +/* { dg-final { cleanup-tree-dump strlen } } */ + +#include string.h + +char *test (char *str1, char *str2) +{ + char *p = stpcpy (str1, str2); + size_t len = strlen (str1); + return p + len; +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-3.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-3.c new file mode 100644 index 000..447b9be --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-strlen-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen } */ +/* { dg-final { scan-tree-dump-times strlen 1 strlen } } */ +/* { dg-final { cleanup-tree-dump strlen } } */ + +#include string.h + +size_t test (char *str1, char *str2) +{ + size_t len = strlen (str2); + memcpy (str1, str2, len + 1); + return len + strlen (str1); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-4.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-4.c new file mode 100644 index 000..a9ebe2b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-strlen-4.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen -D_GNU_SOURCE } */ +/* { dg-final { scan-tree-dump-times strlen 1 strlen } } */ +/* { dg-final { cleanup-tree-dump strlen } } */ + +#include string.h + +char * test (char *str1, char *str2) +{ + size_t len = strlen (str2); + char *p = (char *)mempcpy (str1, str2, len + 1); + return p + len + strlen (str1); +} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-5.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-5.c new file mode 100644 index 000..37b664e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-strlen-5.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options -fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen } */ +/* { dg-final { scan-tree-dump-times strlen 2 strlen } } */ +/* { dg-final { scan-tree-dump memcpy strlen } } */ +/* { dg-final { cleanup-tree-dump strlen } } */ + +#include string.h + +size_t test (char *str1, char *str2) +{ + size_t len1 = strlen (str1); + size_t len2 = strlen (str2); + strcat (str1, str2); + return len1 + len2 + strlen (str1); +} diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index c224fd9..10db136 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -62,6 +62,10 @@ along with GCC; see the file COPYING3. If not see #include gimple-pretty-print.h #include params.h #include expr.h +#include ipa-ref.h +#include lto-streamer.h +#include cgraph.h +#include ipa-chkp.h /* A vector indexed by SSA_NAME_VERSION. 0 means unknown, positive value is an index into strinfo vector, negative value stands for @@ -417,6 +421,7 @@ get_string_length (strinfo si) if (si-stmt) { gimple stmt = si-stmt, lenstmt; + bool with_bounds = gimple_call_with_bounds_p (stmt); tree callee, lhs, fn, tem; location_t loc; gimple_stmt_iterator gsi; @@ -436,11 +441,20 @@ get_string_length (strinfo
Re: [PATCH 00/13] Go closures, libffi, and the static chain
On Thu, Nov 06, 2014 at 07:59:16AM +0100, Richard Henderson wrote: I haven't done powerpc yet. If you'd like to help, I'd be delighted. I was going to say that it doesn't look too difficult, but then I noticed we have a problem. PowerPC uses r11 as the static chain, a register that is allowed to be used by linkage stubs. So any call to a shared libffi will (or may) blow away r11. On ppc32, every plt call currently uses r11. On ppc64 ELFv1 most plt calls do (in fact r11 is loaded from the third word of the plt function descriptor if using a standard plt stub). On ppc64 ELFv2 just the lazy plt resolution trashes r11. -- Alan Modra Australia Development Lab, IBM
Re: [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper
On 16 Oct 13:22, Jakub Jelinek wrote: Can you please extract the configure{,.ac}, langhooks.c and varasm.c bits into a separate patch? That is preapproved for trunk right now, that isn't dependent on anything else. Done. The rest LGTM, but please run it through LTO review (Richard/Honza) too. Richard, is this patch OK for trunk? Thanks, -- Ilya
Re: [PARCH 1/2, x86, PR63534] Fix darwin bootstrap
Now I see that equiv reload could be special for PIC register. Let's apply more conservative patch. Darwin bootstrap passed with the patch applied on r216304 (along with already committed to trunk patches from PR63618 and PR63620). 2014-11-06 Evgeny Stupachenko evstu...@gmail.com PR target/63534 * config/i386/i386.c (builtin_setjmp_receiver): Use pic_offset_table_rtx for PIC register. (nonlocal_goto_receiver): Delete. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 7b1dd79..0df66ea 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -16989,10 +16989,9 @@ if (TARGET_MACHO) { rtx xops[3]; - rtx picreg = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM); rtx_code_label *label_rtx = gen_label_rtx (); emit_insn (gen_set_got_labelled (pic_offset_table_rtx, label_rtx)); - xops[0] = xops[1] = picreg; + xops[0] = xops[1] = pic_offset_table_rtx; xops[2] = machopic_gen_offset (gen_rtx_LABEL_REF (SImode, label_rtx)); ix86_expand_binary_operator (MINUS, SImode, xops); } @@ -17002,36 +17001,6 @@ DONE; }) -(define_insn_and_split nonlocal_goto_receiver - [(unspec_volatile [(const_int 0)] UNSPECV_NLGR)] - TARGET_MACHO !TARGET_64BIT flag_pic - # - reload_completed - [(const_int 0)] -{ - if (crtl-uses_pic_offset_table) -{ - rtx xops[3]; - rtx label_rtx = gen_label_rtx (); - rtx tmp; - - /* Get a new pic base. */ - emit_insn (gen_set_got_labelled (pic_offset_table_rtx, label_rtx)); - /* Correct this with the offset from the new to the old. */ - xops[0] = xops[1] = pic_offset_table_rtx; - label_rtx = gen_rtx_LABEL_REF (SImode, label_rtx); - tmp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, label_rtx), - UNSPEC_MACHOPIC_OFFSET); - xops[2] = gen_rtx_CONST (Pmode, tmp); - ix86_expand_binary_operator (MINUS, SImode, xops); -} - else -/* No pic reg restore needed. */ -emit_note (NOTE_INSN_DELETED); - - DONE; -}) - ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode. ;; Do not split instructions with mask registers. (define_split On Wed, Nov 5, 2014 at 3:59 PM, Evgeny Stupachenko evstu...@gmail.com wrote: On Tue, Nov 4, 2014 at 1:40 AM, Jeff Law l...@redhat.com wrote: On 11/01/14 06:39, Evgeny Stupachenko wrote: When PIC register is pseudo there is nothing special about it's value that setjmp can hurt. So if the pseudo register lives across setjmp_receiver RA should care about correct allocation (in case it is not saved/restored, it should go on stack). gcc.dg tests and specs I've tested behave like this. If the allocator picked a call-clobbered register for the PIC register, then we're obviously OK since the setjmp has to be expected to clobber the PIC register. But if the PIC register is in a call-saved register, then it's going to be assumed to not be clobbered across calls and I don't believe that is guaranteed for builtin setjmp/longjmp. Those restore SP, FP and an ARGP, but not anything else by default. I still don't see what is special for PIC register here. PIC pseudo now behave as every other pseudo register. If we assume that setjmp can change a pseudo register value we need IRA/LRA magic for each pseudo register. I believe that when we had EBX fixed, IRA/LRA don't save/restore it anywhere. Therefore we had to care about EBX value in special cases like setjmp/non-local goto. Now RA cares about PIC pseudo as well as about correct allocation for any pseudo register. So the callee might have clobbered the call saved hard register, expecting to restore its value in its epilogue. But due to the longjmp, that epilogue never gets called and thus the call-saved register won't have the right value in the receiver. Now if your argument is that IRA/LRA handle this, that's fine, a pointer to that code would be appreciated so that it can be quickly audited. Certainly the old local-alloc/global-alloc had magic for setjmp/longjmp and maybe IRA/LRA does too, but it's better to be sure than just assume. The initial problem comes from non-local goto as it tries to emit pseudo PIC register after reload. ? You mean it emits a reference to the pseudo into RTL? That would indicate that the allocators never put the pseudo into a hard register?!? RTL dumps with a few pointers to key insns would help here. Correct, that is why Darwin crashes with ICE on non-local goto. We still have: (define_insn_and_split nonlocal_goto_receiver [(unspec_volatile [(const_int 0)] UNSPECV_NLGR)] TARGET_MACHO !TARGET_64BIT flag_pic # reload_completed [(const_int 0)] { if (crtl-uses_pic_offset_table) { rtx xops[3]; rtx label_rtx = gen_label_rtx (); rtx tmp; /* Get a new pic base. */ emit_insn (gen_set_got_labelled (pic_offset_table_rtx, label_rtx)); . Here for MAC only we are trying
Re: [PATCH 00/13] Go closures, libffi, and the static chain
On 11/06/2014 01:48 PM, Alan Modra wrote: On Thu, Nov 06, 2014 at 07:59:16AM +0100, Richard Henderson wrote: I haven't done powerpc yet. If you'd like to help, I'd be delighted. I was going to say that it doesn't look too difficult, but then I noticed we have a problem. PowerPC uses r11 as the static chain, a register that is allowed to be used by linkage stubs. Hum. At the moment, the static chain is not part of the ABI -- it's private to the translation unit. But as soon as we start using this for the Go closure, it does become part of the ABI, so it would be best if we can choose a different register. That said, this *may* not actually be a problem. It's not the direct (possibly lazy bound) call into libffi that needs a static chain, it's the indirect call that libffi produces. And the indirect calls that Go produces. I'm pretty sure that there are no dynamically linked Go calls that require the static chain. They're used for closures, which are either fully indirect from a different translation unit, or locally bound closures through which the optimizer has seen the construction, and optimized to a direct call. Ian, have I missed a case where a closure could wind up with a direct call to a lazy bound function? r~
Re: Add uniform_inside_sphere_distribution
On 11/06/2014 02:23 AM, Marc Glisse wrote: On Wed, 5 Nov 2014, Ed Smith-Rowland wrote: On 11/05/2014 04:25 PM, Marc Glisse wrote: On Wed, 5 Nov 2014, Ed Smith-Rowland wrote: Like the uniform_on_sphere_distribution which is used inside, the 2-dimensional case uses rejection Could you point out where in the code you are special-casing dimension 2? Somehow I can't see it in the patch. My miscommunication. Sorry. The special casing - and all the hard work - is done by the contained uniform_on_sphere_distribution. In dimension 2, uniform_on_sphere_distribution generates a uniform random point in the unit disk and projects it to the circle. Using that + one more random number to regenerate a uniform random point in the disk seems wasteful to me. Good point. I'll check out a direct rejection and see what that gets me time-wise. The ratio is pi/4 which is pretty good.
Re: [PATCH 00/13] Go closures, libffi, and the static chain
Aren't there cases where the static chain register is needed? How does that work if it could be trashed on a plt call? On 11/06/2014 06:48 AM, Alan Modra wrote: On Thu, Nov 06, 2014 at 07:59:16AM +0100, Richard Henderson wrote: I haven't done powerpc yet. If you'd like to help, I'd be delighted. I was going to say that it doesn't look too difficult, but then I noticed we have a problem. PowerPC uses r11 as the static chain, a register that is allowed to be used by linkage stubs. So any call to a shared libffi will (or may) blow away r11. On ppc32, every plt call currently uses r11. On ppc64 ELFv1 most plt calls do (in fact r11 is loaded from the third word of the plt function descriptor if using a standard plt stub). On ppc64 ELFv2 just the lazy plt resolution trashes r11.
Re: FW: [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.
On 10 October 2014 16:58, David Sherwood david.sherw...@arm.com wrote: Hi, I forgot to mention that this patch needs was tested in combination with another patch by Alan Hayward (coming soon) and observed the following: x86_64: No regressions. aarch64: No regressions. aarch64_be: Lots of vector tests now fixed. No new regressions. I've tried your patch on target aarch64_be-none-elf, and gcc.target/aarch64/advsimd-intrinsics/vldX_lane.c gcc.target/aarch64/advsimd-intrinsics/vldX.c are still failing at runtime. Am I missing something? Christophe. Regards, David. -Original Message- From: David Sherwood [mailto:david.sherw...@arm.com] Sent: 10 October 2014 15:48 To: gcc-patches@gcc.gnu.org Subject: [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe. Hi, I have a fix (originally written by Tejas Belagod) for the following bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59810 Could someone take a look please? Thanks! David Sherwood. ChangeLog: gcc/: 2014-10-10 David Sherwood david.sherw...@arm.com * config/aarch64/aarch64-protos.h (aarch64_simd_attr_length_rglist, aarch64_reverse_mask): New decls. * config/aarch64/iterators.md (UNSPEC_REV_REGLIST): New enum. * config/aarch64/iterators.md (insn_count): New mode_attr. * config/aarch64/aarch64-simd.md (vec_store_lanes(o/c/x)i, vec_load_lanes(o/c/x)i): Fixed to work for Big Endian. * config/aarch64/aarch64-simd.md (aarch64_rev_reglist, aarch64_simd_(ld/st)(2/3/4)): Added. * config/aarch64/aarch64.c (aarch64_simd_attr_length_rglist, aarch64_reverse_mask): Added.
Re: [PATCH 00/13] Go closures, libffi, and the static chain
On 11/06/2014 02:10 PM, Lynn A. Boger wrote: Aren't there cases where the static chain register is needed? How does that work if it could be trashed on a plt call? No. At the moment the static chain is only used for nested functions, which are local to the translation unit, and are therefore locally bound, and therefore never go through the plt. r~
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: +/* Simplify (A B) OP0 (C B) to (A OP0 C) B. */ +/* (x | CST1) CST2 - (x CST2) | (CST1 CST2) */ As soon as there are 2+ operations in the result, this comment in fwprop_ssa_val becomes outdated, no? Yes, but in the above case the 2nd operand of the outer | folds to a constant, thus the whole expression only uses a single SSA name. Btw, I was careful to only convert patterns from tree-ssa-forwprop.c that do not care about the number of uses (if you look there are not many that do - mainly all the comparison simplification) /* We continue matching along SSA use-def edges for SSA names that are not single-use. Currently there are no patterns that would cause any issues with that. */ (I am not opposing the patch, just trying to understand how things work for when I'll propose new patterns) If it's entirely new patterns and the pattern is a simplification I wouldn't care about single-uses. CSE is supposed to fix things up for us. Exceptions may apply if for example the operation we transform to is more expensive than the two we combine it from. But well - apply common sense. I am currently trying to make us not regress ;) (I don't expect to get to replace the comparison simplification tree-ssa-forwprop.c does with patterns as fold_comparison and friends has so many transforms with interesting implementations - not during this stage1 at least) Richard.
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: +/* Try simple folding for X op !X, and X op X with the help + of the truth_valued_p and logical_inverted_value predicates. */ +(match truth_valued_p + @0 + (if (INTEGRAL_TYPE_P (type) TYPE_PRECISION (type) == 1))) +(for op (lt le eq ne ge gt truth_and truth_andif truth_or truth_orif truth_xor) + (match truth_valued_p + (op @0 @1))) +(match truth_valued_p + (truth_not @0)) + +(match (logical_inverted_value @0) + (bit_not truth_valued_p@0)) +(match (logical_inverted_value @0) + (eq @0 integer_zerop) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (ne truth_valued_p@0 integer_onep) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) + +/* X !X - 0. */ +(simplify + (bit_and:c @0 (logical_inverted_value @0)) + { build_zero_cst (type); }) +/* X | !X and X ^ !X - 1, , if X is truth-valued. */ +(for op (bit_ior bit_xor) + (simplify + (op:c truth_valued_p@0 (logical_inverted_value @0)) + { build_one_cst (type); })) Shouldn't that be build_true_cst (type) so it is -1 for vectors? It seems that it could match: vec a, b; vec c=ab; vec d=~c; vec e=c|d; Probably. Note that I copied this from tree-ssa-forwprop.c. Generally I try to avoid fixing bugs or improving things at this point to make the transition more obvious. Richard.
[patch] Fix ACATS c65003a
Hi, the compiler started to segfault on this ACATS test very recently, probably when the large Pointer Bounds Checker patch went in, although the issue had been latent. For the attached reduced testcase, the backtrace is: Starting program: /home/eric/build/gcc/native/stage1-gcc/gnat1 -quiet opt43.adb -O opt43.adb:8:05: warning: return statement missing following this statement opt43.adb:8:05: warning: Program_Error may be raised at run time Program received signal SIGSEGV, Segmentation fault. stmt_could_throw_1_p (stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2722 warning: Source file is more recent than executable. 2722 fp_operation = FLOAT_TYPE_P (t); (gdb) bt #0 stmt_could_throw_1_p (stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2722 #1 stmt_could_throw_p (stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2772 #2 0x00ec81ad in maybe_clean_eh_stmt_fn (ifun=0x769b45e8, stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2846 #3 0x00ec81e7 in maybe_clean_eh_stmt (stmt=optimized out) at /home/eric/svn/gcc/gcc/tree-eh.c:2856 #4 0x00ea9160 in execute_fixup_cfg () The problem is in fixup_noreturn_call; it contains this block of code: /* We need to remove SSA name to avoid checking errors. All uses are dominated by the noreturn and thus will be removed afterwards. We proactively remove affected non-PHI statements to avoid fixup_cfg from trying to update them and crashing. */ if (TREE_CODE (op) == SSA_NAME) { use_operand_p use_p; imm_use_iterator iter; gimple use_stmt; bitmap_iterator bi; unsigned int bb_index; bitmap blocks = BITMAP_ALLOC (NULL); FOR_EACH_IMM_USE_STMT (use_stmt, iter, op) { if (gimple_code (use_stmt) != GIMPLE_PHI) bitmap_set_bit (blocks, gimple_bb (use_stmt)-index); else FOR_EACH_IMM_USE_ON_STMT (use_p, iter) SET_USE (use_p, error_mark_node); } EXECUTE_IF_SET_IN_BITMAP (blocks, 0, bb_index, bi) delete_basic_block (BASIC_BLOCK_FOR_FN (cfun, bb_index)); BITMAP_FREE (blocks); release_ssa_name (op); } The .ssa dump of the affected function starts with: ;; Function Opt43 (_ada_opt43, funcdef_no=1, decl_uid=4096, cgraph_uid=1, symbol_order=1) Opt43 () { void * EXPTR; integer _5; integer _6; integer _8; integer _9; bb 2: _5 = opt43.func (); bb 3: _6 = _5; _8 = opt43.func (); bb 4: _9 = _8; if (_6 == _9) goto bb 5; else goto bb 6; When the above code processes the first call to opt43.func, it frees _5 and deletes bb 3, which in turn frees _6. But _6 is still referenced in the comparison statement in bb 4 and stmt_could_throw_1_p chokes because of that. The proposed fix is to avoid doing such a poor DCE in fixup_noreturn_call. Tested on x86_64-suse-linux, OK for the mainline? 2014-11-06 Eric Botcazou ebotca...@adacore.com * tree-cfgcleanup. (fixup_noreturn_call): Do not perform DCE here. 2014-11-06 Eric Botcazou ebotca...@adacore.com * gnat.dg/opt43.adb: New test. -- Eric BotcazouIndex: tree-cfgcleanup.c === --- tree-cfgcleanup.c (revision 217148) +++ tree-cfgcleanup.c (working copy) @@ -568,7 +568,6 @@ bool fixup_noreturn_call (gimple stmt) { basic_block bb = gimple_bb (stmt); - bool changed = false; if (gimple_call_builtin_p (stmt, BUILT_IN_RETURN)) return false; @@ -590,46 +589,29 @@ fixup_noreturn_call (gimple stmt) split_block (bb, stmt); } - changed |= remove_fallthru_edge (bb-succs); - - /* If there is LHS, remove it. */ - if (gimple_call_lhs (stmt)) + /* If there is an LHS, remove it. */ + tree lhs = gimple_call_lhs (stmt); + if (lhs) { - tree op = gimple_call_lhs (stmt); gimple_call_set_lhs (stmt, NULL_TREE); - /* We need to remove SSA name to avoid checking errors. - All uses are dominated by the noreturn and thus will - be removed afterwards. - We proactively remove affected non-PHI statements to avoid - fixup_cfg from trying to update them and crashing. */ - if (TREE_CODE (op) == SSA_NAME) + /* We need to initialize the SSA name to avoid checking errors. */ + if (TREE_CODE (lhs) == SSA_NAME) { - use_operand_p use_p; - imm_use_iterator iter; - gimple use_stmt; - bitmap_iterator bi; - unsigned int bb_index; - - bitmap blocks = BITMAP_ALLOC (NULL); - - FOR_EACH_IMM_USE_STMT (use_stmt, iter, op) + edge e = find_fallthru_edge (bb-succs); + if (e) { - if (gimple_code (use_stmt) != GIMPLE_PHI) - bitmap_set_bit (blocks, gimple_bb (use_stmt)-index); - else - FOR_EACH_IMM_USE_ON_STMT (use_p, iter) - SET_USE (use_p, error_mark_node); +
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Richard Biener wrote: On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: +/* Try simple folding for X op !X, and X op X with the help + of the truth_valued_p and logical_inverted_value predicates. */ +(match truth_valued_p + @0 + (if (INTEGRAL_TYPE_P (type) TYPE_PRECISION (type) == 1))) +(for op (lt le eq ne ge gt truth_and truth_andif truth_or truth_orif truth_xor) + (match truth_valued_p + (op @0 @1))) +(match truth_valued_p + (truth_not @0)) + +(match (logical_inverted_value @0) + (bit_not truth_valued_p@0)) +(match (logical_inverted_value @0) + (eq @0 integer_zerop) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (ne truth_valued_p@0 integer_onep) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) + +/* X !X - 0. */ +(simplify + (bit_and:c @0 (logical_inverted_value @0)) + { build_zero_cst (type); }) +/* X | !X and X ^ !X - 1, , if X is truth-valued. */ +(for op (bit_ior bit_xor) + (simplify + (op:c truth_valued_p@0 (logical_inverted_value @0)) + { build_one_cst (type); })) Shouldn't that be build_true_cst (type) so it is -1 for vectors? It seems that it could match: vec a, b; vec c=ab; vec d=~c; vec e=c|d; Probably. Note that I copied this from tree-ssa-forwprop.c. Generally I try to avoid fixing bugs or improving things at this point to make the transition more obvious. But truth_valued_ssa_name starts with: if (!INTEGRAL_TYPE_P (type)) return false; so it does not match vectors. lookup_logical_inverted_value has a similar test. -- Marc Glisse
Re: [Patchv3] Control SRA and IPA-SRA by a param rather than MOVE_RATIO
On Thu, Nov 6, 2014 at 12:53 PM, James Greenhalgh james.greenha...@arm.com wrote: On Fri, Oct 31, 2014 at 10:46:12AM +, Richard Biener wrote: On Wed, Oct 29, 2014 at 3:39 PM, James Greenhalgh wrote: I suppose I could port any target with a definition of MOVE_RATIO to override the default parameter value in their option overriding code, but that makes this a very large patch set (many targets define MOVE_RATIO). Is this an avenue worth exploring? I agree the very special target hook is not ideal. Hi, Did you have any further thoughts on this? I'm still unable to come up with a way to set these parameters which allows them to default to their current (MOVE_RATIO derived) values. If the only way to make this work is to add code to TARGET_OPTION_OVERRIDE for all targets that define MOVE_RATIO, then I suppose I can do that, but I'd prefer a neater way to make it work, if you can think of one. Maybe instead of putting the code in opts.c put it right before we call targetm.target_option.override () in toplev.c:process_options. With a comment on why it cannot be in opts.c. Ah, that makes sense. The (much simplified) patch then looks like this... Bootstrapped on x86_64, ARM and AArch64 with no issues. OK? Ok. Thanks, Richard. Thanks, James --- gcc/ 2014-11-06 James Greenhalgh james.greenha...@arm.com * params.def (sra-max-scalarization-size-Ospeed): New. (sra-max-scalarization-size-Osize): Likewise. * doc/invoke.texi (sra-max-scalarization-size-Ospeed): Document. (sra-max-scalarization-size-Osize): Likewise. * toplev.c (process_options): Set default values for new parameters. * tree-sra.c (analyze_all_variable_accesses): Use new parameters. * targhooks.c (get_move_ratio): Remove static designator. * target.h (get_move_ratio): Declare.
Re: [patch] Fix ACATS c65003a
On Thu, Nov 6, 2014 at 2:58 PM, Eric Botcazou ebotca...@adacore.com wrote: Hi, the compiler started to segfault on this ACATS test very recently, probably when the large Pointer Bounds Checker patch went in, although the issue had been latent. For the attached reduced testcase, the backtrace is: Starting program: /home/eric/build/gcc/native/stage1-gcc/gnat1 -quiet opt43.adb -O opt43.adb:8:05: warning: return statement missing following this statement opt43.adb:8:05: warning: Program_Error may be raised at run time Program received signal SIGSEGV, Segmentation fault. stmt_could_throw_1_p (stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2722 warning: Source file is more recent than executable. 2722 fp_operation = FLOAT_TYPE_P (t); (gdb) bt #0 stmt_could_throw_1_p (stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2722 #1 stmt_could_throw_p (stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2772 #2 0x00ec81ad in maybe_clean_eh_stmt_fn (ifun=0x769b45e8, stmt=0x76d2e460) at /home/eric/svn/gcc/gcc/tree-eh.c:2846 #3 0x00ec81e7 in maybe_clean_eh_stmt (stmt=optimized out) at /home/eric/svn/gcc/gcc/tree-eh.c:2856 #4 0x00ea9160 in execute_fixup_cfg () The problem is in fixup_noreturn_call; it contains this block of code: /* We need to remove SSA name to avoid checking errors. All uses are dominated by the noreturn and thus will be removed afterwards. We proactively remove affected non-PHI statements to avoid fixup_cfg from trying to update them and crashing. */ if (TREE_CODE (op) == SSA_NAME) { use_operand_p use_p; imm_use_iterator iter; gimple use_stmt; bitmap_iterator bi; unsigned int bb_index; bitmap blocks = BITMAP_ALLOC (NULL); FOR_EACH_IMM_USE_STMT (use_stmt, iter, op) { if (gimple_code (use_stmt) != GIMPLE_PHI) bitmap_set_bit (blocks, gimple_bb (use_stmt)-index); else FOR_EACH_IMM_USE_ON_STMT (use_p, iter) SET_USE (use_p, error_mark_node); } EXECUTE_IF_SET_IN_BITMAP (blocks, 0, bb_index, bi) delete_basic_block (BASIC_BLOCK_FOR_FN (cfun, bb_index)); BITMAP_FREE (blocks); release_ssa_name (op); } The .ssa dump of the affected function starts with: ;; Function Opt43 (_ada_opt43, funcdef_no=1, decl_uid=4096, cgraph_uid=1, symbol_order=1) Opt43 () { void * EXPTR; integer _5; integer _6; integer _8; integer _9; bb 2: _5 = opt43.func (); bb 3: _6 = _5; _8 = opt43.func (); bb 4: _9 = _8; if (_6 == _9) goto bb 5; else goto bb 6; When the above code processes the first call to opt43.func, it frees _5 and deletes bb 3, which in turn frees _6. But _6 is still referenced in the comparison statement in bb 4 and stmt_could_throw_1_p chokes because of that. The proposed fix is to avoid doing such a poor DCE in fixup_noreturn_call. Tested on x86_64-suse-linux, OK for the mainline? Can you instead of initializing it with 0, turn it into a default definition? Thus do sth like SSA_NAME_VAR (lhs) = create_tmp_reg (TREE_TYPE (lhs), NULL); set_ssa_default_def (cfun, SSA_NAME_VAR (lhs), lhs); Ok with that change. Thanks, Richard. 2014-11-06 Eric Botcazou ebotca...@adacore.com * tree-cfgcleanup. (fixup_noreturn_call): Do not perform DCE here. 2014-11-06 Eric Botcazou ebotca...@adacore.com * gnat.dg/opt43.adb: New test. -- Eric Botcazou
Re: [PATCH] OpenACC for C++ front end
Hi! On Wed, 5 Nov 2014 21:41:02 +, Joseph Myers jos...@codesourcery.com wrote: I think the TODO: XXX FIX -2 and TODO XXX: FIX -1 comments need, at least, more explanation of what the issue is and where the constants come from, even if something is left until later to be fixed. Such constants should go into include/gomp-constants.h. Jim, for avoidance of doubt, please commit any such review changes to gomp-4_0-branch, so that the (revised) patches that you submit and the actual diff from the last merge of trunk into gomp-4_0-branch and gomp-4_0-branch's current head are as similar as possible; preferably you're submitting exactly (a relevant part of) that diff. Grüße, Thomas signature.asc Description: PGP signature
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: +/* Try simple folding for X op !X, and X op X with the help + of the truth_valued_p and logical_inverted_value predicates. */ +(match truth_valued_p + @0 + (if (INTEGRAL_TYPE_P (type) TYPE_PRECISION (type) == 1))) +(for op (lt le eq ne ge gt truth_and truth_andif truth_or truth_orif truth_xor) + (match truth_valued_p + (op @0 @1))) +(match truth_valued_p + (truth_not @0)) + +(match (logical_inverted_value @0) + (bit_not truth_valued_p@0)) +(match (logical_inverted_value @0) + (eq @0 integer_zerop) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (ne truth_valued_p@0 integer_onep) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) + +/* X !X - 0. */ +(simplify + (bit_and:c @0 (logical_inverted_value @0)) + { build_zero_cst (type); }) +/* X | !X and X ^ !X - 1, , if X is truth-valued. */ +(for op (bit_ior bit_xor) + (simplify + (op:c truth_valued_p@0 (logical_inverted_value @0)) + { build_one_cst (type); })) Shouldn't that be build_true_cst (type) so it is -1 for vectors? It seems that it could match: vec a, b; vec c=ab; vec d=~c; vec e=c|d; Probably. Note that I copied this from tree-ssa-forwprop.c. Generally I try to avoid fixing bugs or improving things at this point to make the transition more obvious. But truth_valued_ssa_name starts with: if (!INTEGRAL_TYPE_P (type)) return false; so it does not match vectors. lookup_logical_inverted_value has a similar test. But truth_valued_p doesn't catch vector types, no? That said, the +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) would have a similar issue for vectors? I'll happily approve a patch that makes it work correctly for vectors (with a testcase)! A bug with a testcase that is miscompiled is also ok, I'll fix that then. Thanks, Richard.
[gimple-classes, committed 06/44] Yet more gcall *
gcc/ChangeLog.gimple-classes: * tree-ssa-forwprop.c (simplify_builtin_call): Strengthen local stmt2 from gimple to gcall * via a checked cast. Replace is_gimple_call with a dyn_cast, introducing local call_stmt1, and using the latter in place of stmt1 for typesafety. Introduce another local call_stmt1 for typesafety via a checked cast within the if (callee1) block, which is only reachable if we have a GIMPLE_CALL. * tree-ssa-reassoc.c (attempt_builtin_powi): Strengthen local pow_stmt from gimple to gcall *. * tree-ssa-strlen.c (get_string_length): Likewise for local stmt, via a checked cast. --- gcc/ChangeLog.gimple-classes | 14 ++ gcc/tree-ssa-forwprop.c | 25 ++--- gcc/tree-ssa-reassoc.c | 3 ++- gcc/tree-ssa-strlen.c| 2 +- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 33bd5bf..5c3cbd5 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,19 @@ 2014-10-31 David Malcolm dmalc...@redhat.com + * tree-ssa-forwprop.c (simplify_builtin_call): Strengthen local + stmt2 from gimple to gcall * via a checked cast. Replace + is_gimple_call with a dyn_cast, introducing local call_stmt1, + and using the latter in place of stmt1 for typesafety. + Introduce another local call_stmt1 for typesafety via a + checked cast within the if (callee1) block, which is only + reachable if we have a GIMPLE_CALL. + * tree-ssa-reassoc.c (attempt_builtin_powi): Strengthen local + pow_stmt from gimple to gcall *. + * tree-ssa-strlen.c (get_string_length): Likewise for local + stmt, via a checked cast. + +2014-10-31 David Malcolm dmalc...@redhat.com + * gimple.c (gimple_set_lhs): Add checked casts to gassign * and gcall * as appropriate. * tree-cfg.c (execute_fixup_cfg): Introduce local call_stmt diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 1f4c9de..3a03b9f 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -1515,7 +1515,8 @@ constant_pointer_difference (tree p1, tree p2) static bool simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) { - gimple stmt1, stmt2 = gsi_stmt (*gsi_p); + gimple stmt1; + gcall *stmt2 = as_a gcall * (gsi_stmt (*gsi_p)); tree vuse = gimple_vuse (stmt2); if (vuse == NULL) return false; @@ -1546,23 +1547,23 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) if (!tree_fits_shwi_p (val2) || !tree_fits_uhwi_p (len2)) break; - if (is_gimple_call (stmt1)) + if (gcall *call_stmt1 = dyn_cast gcall * (stmt1)) { /* If first stmt is a call, it needs to be memcpy or mempcpy, with string literal as second argument and constant length. */ - callee1 = gimple_call_fndecl (stmt1); + callee1 = gimple_call_fndecl (call_stmt1); if (callee1 == NULL_TREE || DECL_BUILT_IN_CLASS (callee1) != BUILT_IN_NORMAL - || gimple_call_num_args (stmt1) != 3) + || gimple_call_num_args (call_stmt1) != 3) break; if (DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMCPY DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMPCPY) break; - ptr1 = gimple_call_arg (stmt1, 0); - src1 = gimple_call_arg (stmt1, 1); - len1 = gimple_call_arg (stmt1, 2); - lhs1 = gimple_call_lhs (stmt1); + ptr1 = gimple_call_arg (call_stmt1, 0); + src1 = gimple_call_arg (call_stmt1, 1); + len1 = gimple_call_arg (call_stmt1, 2); + lhs1 = gimple_call_lhs (call_stmt1); if (!tree_fits_uhwi_p (len1)) break; str1 = string_constant (src1, off1); @@ -1668,12 +1669,14 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) new_str_cst = build_string_literal (src_len, src_buf); if (callee1) { + gcall *call_stmt1 = as_a gcall * (stmt1); + /* If STMT1 is a mem{,p}cpy call, adjust it and remove memset call. */ if (lhs1 DECL_FUNCTION_CODE (callee1) == BUILT_IN_MEMPCPY) - gimple_call_set_lhs (stmt1, NULL_TREE); - gimple_call_set_arg (stmt1, 1, new_str_cst); - gimple_call_set_arg (stmt1, 2, + gimple_call_set_lhs (call_stmt1, NULL_TREE); + gimple_call_set_arg (call_stmt1, 1, new_str_cst); + gimple_call_set_arg (call_stmt1, 2, build_int_cst (TREE_TYPE (len1), src_len)); update_stmt (stmt1); unlink_stmt_vdef (stmt2); diff --git
[gimple-classes, committed 02/44] Make replace_call_with_call_and_fold work on a gcall *
gcc/ChangeLog.gimple-classes: * gimple-fold.c (replace_call_with_call_and_fold): Strengthen param repl from gimple to gcall *. (gimple_fold_builtin_strcpy): Likewise for local repl. (gimple_fold_builtin_strncpy): Likewise. (gimple_fold_builtin_strcat): Likewise. (gimple_fold_builtin_strcat): Likewise. (gimple_fold_builtin_strcat_chk): Likewise. (gimple_fold_builtin_strncat_chk): Likewise. (gimple_fold_builtin_fputs): Likewise. (gimple_fold_builtin_memory_chk): Likewise. (gimple_fold_builtin_stxcpy_chk): Likewise. (gimple_fold_builtin_stxncpy_chk): Likewise. --- gcc/ChangeLog.gimple-classes | 15 +++ gcc/gimple-fold.c| 34 +- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 9998737..a47c471 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,20 @@ 2014-10-30 David Malcolm dmalc...@redhat.com + * gimple-fold.c (replace_call_with_call_and_fold): Strengthen + param repl from gimple to gcall *. + (gimple_fold_builtin_strcpy): Likewise for local repl. + (gimple_fold_builtin_strncpy): Likewise. + (gimple_fold_builtin_strcat): Likewise. + (gimple_fold_builtin_strcat): Likewise. + (gimple_fold_builtin_strcat_chk): Likewise. + (gimple_fold_builtin_strncat_chk): Likewise. + (gimple_fold_builtin_fputs): Likewise. + (gimple_fold_builtin_memory_chk): Likewise. + (gimple_fold_builtin_stxcpy_chk): Likewise. + (gimple_fold_builtin_stxncpy_chk): Likewise. + +2014-10-30 David Malcolm dmalc...@redhat.com + * asan.c (build_shadow_mem_access): Strengthen local g from gimple to gassign *. (maybe_create_ssa_name): Likewise. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 60a272f..e7456cd 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -738,7 +738,7 @@ replace_call_with_value (gimple_stmt_iterator *gsi, tree val) again. */ static void -replace_call_with_call_and_fold (gimple_stmt_iterator *gsi, gimple repl) +replace_call_with_call_and_fold (gimple_stmt_iterator *gsi, gcall *repl) { gimple stmt = gsi_stmt (*gsi); gimple_call_set_lhs (repl, gimple_call_lhs (stmt)); @@ -1459,7 +1459,7 @@ gimple_fold_builtin_strcpy (gimple_stmt_iterator *gsi, len = size_binop_loc (loc, PLUS_EXPR, len, build_int_cst (size_type_node, 1)); len = force_gimple_operand_gsi (gsi, len, true, NULL_TREE, true, GSI_SAME_STMT); - gimple repl = gimple_build_call (fn, 3, dest, src, len); + gcall *repl = gimple_build_call (fn, 3, dest, src, len); replace_call_with_call_and_fold (gsi, repl); return true; } @@ -1508,7 +1508,7 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi, len = fold_convert_loc (loc, size_type_node, len); len = force_gimple_operand_gsi (gsi, len, true, NULL_TREE, true, GSI_SAME_STMT); - gimple repl = gimple_build_call (fn, 3, dest, src, len); + gcall *repl = gimple_build_call (fn, 3, dest, src, len); replace_call_with_call_and_fold (gsi, repl); return true; } @@ -1565,7 +1565,7 @@ gimple_fold_builtin_strcat (gimple_stmt_iterator *gsi, tree dst, tree src) /* Create strlen (dst). */ gimple_seq stmts = NULL, stmts2; - gimple repl = gimple_build_call (strlen_fn, 1, dst); + gcall *repl = gimple_build_call (strlen_fn, 1, dst); gimple_set_location (repl, loc); if (gimple_in_ssa_p (cfun)) newdst = make_ssa_name (size_type_node, NULL); @@ -1589,7 +1589,7 @@ gimple_fold_builtin_strcat (gimple_stmt_iterator *gsi, tree dst, tree src) gimple_seq_add_stmt_without_update (stmts, repl); if (gimple_call_lhs (stmt)) { - repl = gimple_build_assign (gimple_call_lhs (stmt), dst); + gassign *repl = gimple_build_assign (gimple_call_lhs (stmt), dst); gimple_seq_add_stmt_without_update (stmts, repl); gsi_replace_with_seq_vops (gsi, stmts); /* gsi now points at the assignment to the lhs, get a @@ -1638,7 +1638,7 @@ gimple_fold_builtin_strcat_chk (gimple_stmt_iterator *gsi) if (!fn) return false; - gimple repl = gimple_build_call (fn, 2, dest, src); + gcall *repl = gimple_build_call (fn, 2, dest, src); replace_call_with_call_and_fold (gsi, repl); return true; } @@ -1682,7 +1682,7 @@ gimple_fold_builtin_strncat_chk (gimple_stmt_iterator *gsi) if (!fn) return false; - gimple repl = gimple_build_call (fn, 3, dest, src, size); + gcall *repl = gimple_build_call (fn, 3, dest, src, size); replace_call_with_call_and_fold (gsi, repl); return true; } @@ -1694,7 +1694,7 @@ gimple_fold_builtin_strncat_chk (gimple_stmt_iterator *gsi) if (!fn) return false; - gimple repl = gimple_build_call (fn, 3, dest, src, len); +
[gimple-classes, committed 00/44] Yet more accessor typesafety
I've pushed the following 44 patches to the git branch dmalcolm/gimple-classes. This is a work-in-progress towards making the rest of the gimple_assign_* accessors require a gassign * (or a const gassign *). Successfully bootstrappedregrtested the combination of the 44 patches upon the branch on x86_64-unknown-linux-gnu (Fedora 20) - same results relative to an unpatched control bootstrap of trunk's r216746. David Malcolm (44): Use gassign * rather than gimple in various places Make replace_call_with_call_and_fold work on a gcall * gimple-low.c: Use gcall * in a few places Use gcall * in more places More gcall * Yet more gcall * Add casting variants of various gimple_assign_*_p functions tree-ssa-forwprop.c: Use gassign * in various places auto-profile.c: Use gassign gimplify-me.c: Use gassign gimple-ssa-isolate-paths.c: Use gassign gimple-fold.c: Use gassign rewrite_to_defined_overflow takes a gassign * gimple-match-head.c: Use gassign graphite-sese-to-poly.c: Use gasssign tree-object-size.c: Use gassign tree-affine.c: Use gassign tree-call-cdce.c: Use gassign tree-data-ref.c: Use gassign tree-if-conv.c: Use gassign tree-eh.c: Use gassign tree-nested: Use gassign tree-ssa-alias.c: Use gassign tree-ssa-ccp.c: Use gassign tree-ssa-coalesce.c: Use gassign tree-ssa-copy.c: Use gassign tree-ssa-dce.c: Use gassign tree-ssa-dom.c: Use gassign tree-ssa-dse.c: Use gassign gimple-walk.c: Use gassign ipa-polymorphic-call.c: Use gassign Fix issues with gimple_assign_single_p and gimple_assign_load_p Use gassign within gimple_expr_type build_assign and build_type_cast take const gassign * gimple_assign_rhs_to_tree takes a const gassign * cfgexpand.c: Use gassign * ipa-split.c: Use gassign ipa-inline-analysis.c: Use gassign ipa-prop.c: Use gassign ipa-icf-gimple.c: Use gassign omp-low.c: Use gassign predict.c: Use gassign sese.c: Use gassign trans-mem.c: Use gassign gcc/ChangeLog.gimple-classes | 648 + gcc/asan.c | 56 ++-- gcc/auto-profile.c | 15 +- gcc/cfgexpand.c| 32 +- gcc/cfgexpand.h| 2 +- gcc/cgraph.c | 2 +- gcc/cgraphunit.c | 4 +- gcc/config/i386/i386.c | 2 +- gcc/gimple-builder.c | 11 +- gcc/gimple-builder.h | 14 +- gcc/gimple-fold.c | 217 +++--- gcc/gimple-fold.h | 2 +- gcc/gimple-low.c | 36 ++- gcc/gimple-match-head.c| 31 +- gcc/gimple-ssa-isolate-paths.c | 12 +- gcc/gimple-walk.c | 82 +++--- gcc/gimple.c | 24 +- gcc/gimple.h | 109 --- gcc/gimplify-me.c | 12 +- gcc/gimplify.c | 2 +- gcc/graphite-sese-to-poly.c| 41 +-- gcc/ipa-icf-gimple.c | 7 +- gcc/ipa-icf-gimple.h | 2 +- gcc/ipa-inline-analysis.c | 56 ++-- gcc/ipa-polymorphic-call.c | 34 ++- gcc/ipa-prop.c | 90 +++--- gcc/ipa-split.c| 30 +- gcc/omp-low.c | 35 +-- gcc/predict.c | 15 +- gcc/sese.c | 4 +- gcc/trans-mem.c| 32 +- gcc/tree-affine.c | 5 +- gcc/tree-call-cdce.c | 11 +- gcc/tree-cfg.c | 13 +- gcc/tree-cfgcleanup.c | 6 +- gcc/tree-cfgcleanup.h | 2 +- gcc/tree-data-ref.c| 11 +- gcc/tree-eh.c | 8 +- gcc/tree-emutls.c | 2 +- gcc/tree-if-conv.c | 49 ++-- gcc/tree-inline.c | 15 +- gcc/tree-loop-distribution.c | 2 +- gcc/tree-nested.c | 6 +- gcc/tree-nrv.c | 12 +- gcc/tree-object-size.c | 45 +-- gcc/tree-parloops.c| 8 +- gcc/tree-scalar-evolution.c| 7 +- gcc/tree-ssa-alias.c | 34 ++- gcc/tree-ssa-ccp.c | 39 +-- gcc/tree-ssa-coalesce.c| 15 +- gcc/tree-ssa-copy.c| 26 +- gcc/tree-ssa-copyrename.c | 6 +- gcc/tree-ssa-dce.c | 32 +- gcc/tree-ssa-dom.c | 84 +++--- gcc/tree-ssa-dse.c | 13 +- gcc/tree-ssa-forwprop.c| 110 +++ gcc/tree-ssa-loop-im.c | 14 +- gcc/tree-ssa-loop-niter.c | 4 +- gcc/tree-ssa-math-opts.c | 33 ++- gcc/tree-ssa-phiopt.c | 3 +- gcc/tree-ssa-pre.c | 2 +- gcc/tree-ssa-propagate.c | 6 +- gcc/tree-ssa-reassoc.c | 5 +- gcc/tree-ssa-strlen.c | 22 +- gcc/tree-ssa.c | 2 +- gcc/tree-switch-conversion.c | 4 +- gcc/tree-vect-data-refs.c | 8 +- gcc/tree-vect-generic.c| 4 +- gcc/tree-vect-loop-manip.c | 4 +- gcc/tree-vect-loop.c | 8 +- gcc/tree-vect-patterns.c | 15 +- gcc/tree-vect-slp.c
[gimple-classes, committed 03/44] gimple-low.c: Use gcall * in a few places
gcc/ChangeLog.gimple-classes: * gimple-low.c (lower_builtin_setjmp): Strengthen local stmt from gimple to gcall *, via a checked cast. (lower_builtin_posix_memalign): Likewise for local call. Strengthen local cond from gimple to gcond *. Split local gimple stmt into new locals assign_stmt1, call_stmt, and assign_stmt2, of appropriate types. --- gcc/ChangeLog.gimple-classes | 9 + gcc/gimple-low.c | 36 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index a47c471..5b408e3 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,3 +1,12 @@ +2014-10-31 David Malcolm dmalc...@redhat.com + + * gimple-low.c (lower_builtin_setjmp): Strengthen local stmt + from gimple to gcall *, via a checked cast. + (lower_builtin_posix_memalign): Likewise for local call. + Strengthen local cond from gimple to gcond *. + Split local gimple stmt into new locals assign_stmt1, + call_stmt, and assign_stmt2, of appropriate types. + 2014-10-30 David Malcolm dmalc...@redhat.com * gimple-fold.c (replace_call_with_call_and_fold): Strengthen diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index a30fae5..f817e25 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -738,7 +738,7 @@ lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data) static void lower_builtin_setjmp (gimple_stmt_iterator *gsi) { - gimple stmt = gsi_stmt (*gsi); + gcall *stmt = as_a gcall * (gsi_stmt (*gsi)); location_t loc = gimple_location (stmt); tree cont_label = create_artificial_label (loc); tree next_label = create_artificial_label (loc); @@ -823,7 +823,8 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) static void lower_builtin_posix_memalign (gimple_stmt_iterator *gsi) { - gimple stmt, call = gsi_stmt (*gsi); + gassign *assign_stmt1; + gcall *call = as_a gcall * (gsi_stmt (*gsi)); tree pptr = gimple_call_arg (call, 0); tree align = gimple_call_arg (call, 1); tree res = gimple_call_lhs (call); @@ -833,12 +834,13 @@ lower_builtin_posix_memalign (gimple_stmt_iterator *gsi) tree tem = create_tmp_var (ptr_type_node, NULL); TREE_ADDRESSABLE (tem) = 1; gimple_call_set_arg (call, 0, build_fold_addr_expr (tem)); - stmt = gimple_build_assign (ptr, tem); + assign_stmt1 = gimple_build_assign (ptr, tem); } else -stmt = gimple_build_assign (ptr, - fold_build2 (MEM_REF, ptr_type_node, pptr, -build_int_cst (ptr_type_node, 0))); +assign_stmt1 = + gimple_build_assign (ptr, + fold_build2 (MEM_REF, ptr_type_node, pptr, + build_int_cst (ptr_type_node, 0))); if (res == NULL_TREE) { res = create_tmp_reg (integer_type_node, NULL); @@ -846,19 +848,21 @@ lower_builtin_posix_memalign (gimple_stmt_iterator *gsi) } tree align_label = create_artificial_label (UNKNOWN_LOCATION); tree noalign_label = create_artificial_label (UNKNOWN_LOCATION); - gimple cond = gimple_build_cond (EQ_EXPR, res, integer_zero_node, + gcond *cond = gimple_build_cond (EQ_EXPR, res, integer_zero_node, align_label, noalign_label); gsi_insert_after (gsi, cond, GSI_NEW_STMT); gsi_insert_after (gsi, gimple_build_label (align_label), GSI_NEW_STMT); - gsi_insert_after (gsi, stmt, GSI_NEW_STMT); - stmt = gimple_build_call (builtin_decl_implicit (BUILT_IN_ASSUME_ALIGNED), - 2, ptr, align); - gimple_call_set_lhs (stmt, ptr); - gsi_insert_after (gsi, stmt, GSI_NEW_STMT); - stmt = gimple_build_assign (fold_build2 (MEM_REF, ptr_type_node, pptr, - build_int_cst (ptr_type_node, 0)), - ptr); - gsi_insert_after (gsi, stmt, GSI_NEW_STMT); + gsi_insert_after (gsi, assign_stmt1, GSI_NEW_STMT); + gcall *call_stmt = +gimple_build_call (builtin_decl_implicit (BUILT_IN_ASSUME_ALIGNED), + 2, ptr, align); + gimple_call_set_lhs (call_stmt, ptr); + gsi_insert_after (gsi, call_stmt, GSI_NEW_STMT); + gassign *assign_stmt2 = +gimple_build_assign (fold_build2 (MEM_REF, ptr_type_node, pptr, + build_int_cst (ptr_type_node, 0)), +ptr); + gsi_insert_after (gsi, assign_stmt2, GSI_NEW_STMT); gsi_insert_after (gsi, gimple_build_label (noalign_label), GSI_NEW_STMT); } -- 1.7.11.7
[gimple-classes, committed 07/44] Add casting variants of various gimple_assign_*_p functions
Use them to provide various gimple_assign_ accessors with gassign * rather than plain gimple. gcc/ChangeLog.gimple-classes: * gimple.h (is_a_helper const gassign *::test): New. (gimple_assign_copy_p): Update return type from bool to gassign *, returning GS if the predicate holds. (gimple_assign_ssa_name_copy_p): Likewise. (gimple_assign_single_p): Likewise for new non-const overload. (gimple_assign_load_p): Likewise. (gimple_assign_cast_p): Introduce local assign via dyn_cast, using it in place of s for typesafety. (gimple_clobber_p): Introduce local assign via call to gimple_assign_single_p, using it in place of s for typesafety. * asan.c (maybe_instrument_assignment): Strengthen local s from gimple to gassign * via a checked cast. * gimple-walk.c (walk_stmt_load_store_addr_ops): Introduce local assign via call to gimple_assign_single_p, using it in place of stmt for typesafety. * gimple.c (gimple_assign_copy_p): Update return type from bool to gassign *, returning GS if the predicate holds. (gimple_assign_ssa_name_copy_p): Likewise. * ipa-polymorphic-call.c (extr_type_from_vtbl_ptr_store): Likewise, replacing local stmt. * ipa-prop.c (extr_type_from_vtbl_ptr_store): Likewise. (load_from_unmodified_param): Likewise. (get_ancestor_addr_info): Rename gimple param assign to stmt, reintroducing name assign as a gassign * via a call to gimple_assign_single_p. (get_ssa_def_if_simple_copy): Introduce local assign via call to gimple_assign_single_p, using it in place of def_stmt for typesafety. (determine_locally_known_aggregate_parts): Likewise for stmt. (ipa_get_stmt_member_ptr_load_param): Likewise. (ipcp_modif_dom_walker::before_dom_children): Strengthen local stmt from gimple to gassign * via use of gimple_assign_load_p. * tree-if-conv.c (ifcvt_can_use_mask_load_store): Introduce local assign via call to gimple_assign_single_p, using it in place of stmt for typesafety. (predicate_mem_writes): Strengthen local stmt from gimple to gassign * via use of gimple_assign_single_p. * tree-inline.c (remap_gimple_stmt): Introduce local assign via call to gimple_assign_copy_p, using it in place of stmt for typesafety. * tree-nrv.c (pass_nrv::execute): Likewise. * tree-ssa-ccp.c (insert_clobber_before_stack_restore): Likewise via call to gimple_assign_ssa_name_copy_p. * tree-ssa-copyrename.c (pass_rename_ssa_copies::execute): Likewise. * tree-ssa-loop-niter.c (get_val_for): Likewise. * tree-vect-stmts.c (exist_non_indexing_operands_for_use_p): Likewise via call to gimple_assign_copy_p. --- gcc/ChangeLog.gimple-classes | 52 gcc/asan.c | 2 +- gcc/gimple-walk.c| 8 +++--- gcc/gimple.c | 20 +- gcc/gimple.h | 63 ++-- gcc/ipa-polymorphic-call.c | 7 ++--- gcc/ipa-prop.c | 38 +++--- gcc/tree-if-conv.c | 17 ++-- gcc/tree-inline.c| 9 --- gcc/tree-nrv.c | 12 + gcc/tree-ssa-ccp.c | 4 +-- gcc/tree-ssa-copyrename.c| 6 ++--- gcc/tree-ssa-loop-niter.c| 4 +-- gcc/tree-vect-stmts.c| 7 ++--- 14 files changed, 177 insertions(+), 72 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 5c3cbd5..a60a771 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,57 @@ 2014-10-31 David Malcolm dmalc...@redhat.com + * gimple.h (is_a_helper const gassign *::test): New. + (gimple_assign_copy_p): Update return type from bool to + gassign *, returning GS if the predicate holds. + (gimple_assign_ssa_name_copy_p): Likewise. + (gimple_assign_single_p): Likewise for new non-const overload. + (gimple_assign_load_p): Likewise. + (gimple_assign_cast_p): Introduce local assign via dyn_cast, + using it in place of s for typesafety. + (gimple_clobber_p): Introduce local assign via call to + gimple_assign_single_p, using it in place of s for typesafety. + + * asan.c (maybe_instrument_assignment): Strengthen local s from + gimple to gassign * via a checked cast. + * gimple-walk.c (walk_stmt_load_store_addr_ops): Introduce local + assign via call to gimple_assign_single_p, using it in place of + stmt for typesafety. + * gimple.c (gimple_assign_copy_p): Update return type from bool to + gassign *, returning GS if the predicate holds. + (gimple_assign_ssa_name_copy_p): Likewise. + * ipa-polymorphic-call.c
[gimple-classes, committed 01/44] Use gassign * rather than gimple in various places
Use gassign * everywhere that a stmt is built from a gimple_build_assign_* call, to ease making the gimple_assign_ accessors typesafe (and to better document the code). gcc/ChangeLog.gimple-classes: * asan.c (build_shadow_mem_access): Strengthen local g from gimple to gassign *. (maybe_create_ssa_name): Likewise. (maybe_cast_to_ptrmode): Likewise. (instrument_mem_region_access): Likewise. * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Likewise for local set_stmt. * cgraphunit.c (cgraph_node::expand_thunk): Likewise for locals stmt. * gimple-fold.c (gimplify_and_update_call_from_tree): Likewise for local new_stmt. (gimple_fold_builtin_memory_op): Likewise for both new_stmt and for locals repl. (gimple_fold_builtin_memset): Likewise for store. (gimple_fold_builtin_memset): Likewise for asgn. * gimple-match-head.c (maybe_push_res_to_seq): Likewise for new_stmt. * gimplify.c (gimplify_bind_expr): Likewise for clobber_stmt. * graphite-sese-to-poly.c (rewrite_cross_bb_scalar_dependence): Likewise for name_stmt. * ipa-prop.c (ipa_modify_call_arguments): Likewise. for tem. * ipa-split.c (split_function): Likewise for cpy. * predict.c (pass_strip_predict_hints::execute): Likewise for ass_stmt. * trans-mem.c (tm_log_emit_saves): Likewise for stmt. (tm_log_emit_restores): Likewise. (build_tm_load): Likewise for g. (build_tm_store): Likewise. * tree-call-cdce.c (gen_conditions_for_pow_int_base): Likewise for stmt1. Strengthen local stmt2 from gimple to gcond *. * tree-cfg.c (make_blocks): Strengthen local s from gimple to gassign *. (handle_abnormal_edges): Likewise for assignment. * tree-emutls.c (lower_emutls_1): Likewise for x. * tree-if-conv.c (ifc_temp_var): Likewise for stmt. (convert_scalar_cond_reduction): Likewise for new_assign. (predicate_scalar_phi): Likewise for new_stmt. * tree-inline.c (remap_ssa_name): Likewise for init_stmt. (copy_bb): Likewise for new_stmt. (setup_one_parameter): Likewise for init_stmt. * tree-loop-distribution.c (generate_memset_builtin): Likewise for cstmt. * tree-nested.c (init_tmp_var): Likewise for stmt. (save_tmp_var): Likewise. * tree-parloops.c (create_loads_for_reductions): Likewise. (create_final_loads_for_reduction): Likewise. (create_stores_for_reduction): Likewise. (create_loads_and_stores_for_name): Likewise. * tree-ssa-dse.c (dse_optimize_stmt): Likewise for new_stmt. * tree-ssa-forwprop.c (associate_pointerplus): Likewise for ostmt. * tree-ssa-loop-im.c (sm_set_flag_if_changed::operator): Likewise for stmt. * tree-ssa-math-opts.c (execute_cse_sincos_1): Eliminate local stmt, splitting its users into new local gcall * call_stmt and gassign * assign_stmt. (build_and_insert_ref): Strengthen local stmt from gimple to gassign *. (bswap_replace): Likewise for load_stmt, addr_stmt, convert_stmt. * tree-ssa-phiopt.c (neg_replacement): Likewise for new_stmt. * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise for stmt. * tree-ssa-reassoc.c (optimize_range_tests_to_bit_test): Likewise for g. * tree-ssa-strlen.c (get_string_length): ELiminate local lenstmt, splitting its users into new local gcall * call_stmt and gassign * assign_stmt. (handle_builtin_memset): Strengthen local assign from gimple to gassign *. * tree-switch-conversion.c (build_one_array): Likewise for load. (build_arrays): Likewise for stmt. * tree-vect-data-refs.c (vect_create_data_ref_ptr): Likewise for vec_stmt. (vect_permute_store_chain): Likewise for perm_stmt. (vect_permute_load_chain): Likewise. (vect_shift_permute_load_chain): Likewise. * tree-vect-generic.c (expand_vector_divmod): Likewise for stmt. (vector_element): Likewise for asgn. * tree-vect-loop-manip.c (vect_create_cond_for_align_checks): Likewise for and_stmt. (vect_create_cond_for_align_checks): Likewise for addr_stmt and or_stmt. * tree-vect-loop.c (vect_is_simple_reduction_1): Likewise for negate_stmt. (get_initial_def_for_induction): Likewise for init_stmt and new_stmt. (vectorizable_reduction): Likewise for new_stmt. * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Likewise for pattern_stmt. (vect_recog_sad_pattern): Likewise. (vect_recog_widen_mult_pattern): Likewise for new_stmt, pattern_stmt. (vect_recog_widen_sum_pattern): Likewise for pattern_stmt.
[gimple-classes, committed 12/44] gimple-fold.c: Use gassign
gcc/ChangeLog.gimple-classes: * gimple-fold.c (fold_gimple_assign): Strengthen local stmt from gimple to gassign * via a checked cast. (gsi_replace_with_seq_vops): Add a checked cast within region guarded by gimple_assign_single_p. (get_maxval_strlen): Within case GIMPLE_ASSIGN, introduce local gassign * def_assign via a checked cast, and use it in place of def_stmt for typesafety. (replace_stmt_with_simplification): Add a checked cast. (fold_stmt_1): In two switch statements, within case GIMPLE_ASSIGN, introduce locals gassign * assign_stmt via checked casts, and use them in place of stmt for typesafety. (same_bool_comparison_p): Replace is_gimple_assign with dyn_cast, introducing local assign_s and using it in place of s for typesafety. (and_var_with_comparison): Strengthen local stmt from gimple to gassign * by replacing an is_gimple_assign with a dyn_cast. (and_var_with_comparison_1): Strengthen param stmt and local s from gimple to gassign *, replacing is_gimple_assign calls with dyn_cast. (or_var_with_comparison): Strengthen local stmt from gimple to gassign * by replacing an is_gimple_assign with a dyn_cast. (or_var_with_comparison_1): Strengthen param stmt and local s from gimple to gassign *, replacing is_gimple_assign calls with dyn_cast. (gimple_fold_stmt_to_constant_1): Within case GIMPLE_ASSIGN, introduce local assign_stmt and use in place of stmt for typesafety. (gimple_val_nonnegative_real_p): Replace is_gimple_assign with a dyn_cast, introducing local def_assign and using it in place of def_stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 33 + gcc/gimple-fold.c| 166 +++ 2 files changed, 123 insertions(+), 76 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index dc1315e..be9aa76 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,38 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-fold.c (fold_gimple_assign): Strengthen local stmt from + gimple to gassign * via a checked cast. + (gsi_replace_with_seq_vops): Add a checked cast within region + guarded by gimple_assign_single_p. + (get_maxval_strlen): Within case GIMPLE_ASSIGN, introduce local + gassign * def_assign via a checked cast, and use it in place of + def_stmt for typesafety. + (replace_stmt_with_simplification): Add a checked cast. + (fold_stmt_1): In two switch statements, within case + GIMPLE_ASSIGN, introduce locals gassign * assign_stmt via + checked casts, and use them in place of stmt for typesafety. + (same_bool_comparison_p): Replace is_gimple_assign with + dyn_cast, introducing local assign_s and using it in place of + s for typesafety. + (and_var_with_comparison): Strengthen local stmt from gimple to + gassign * by replacing an is_gimple_assign with a dyn_cast. + (and_var_with_comparison_1): Strengthen param stmt and local s + from gimple to gassign *, replacing is_gimple_assign calls with + dyn_cast. + (or_var_with_comparison): Strengthen local stmt from gimple to + gassign * by replacing an is_gimple_assign with a dyn_cast. + (or_var_with_comparison_1): Strengthen param stmt and local s + from gimple to gassign *, replacing is_gimple_assign calls with + dyn_cast. + (gimple_fold_stmt_to_constant_1): Within case GIMPLE_ASSIGN, + introduce local assign_stmt and use in place of stmt for + typesafety. + (gimple_val_nonnegative_real_p): Replace is_gimple_assign with a + dyn_cast, introducing local def_assign and using it in place of + def_stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-ssa-isolate-paths.c (insert_trap_and_remove_trailing_statements): Replace a call to is_gimple_assign with a dyn_cast, introducing a local diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index c5f1e07..3b85686 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -302,7 +302,7 @@ maybe_fold_reference (tree expr, bool is_lhs) static tree fold_gimple_assign (gimple_stmt_iterator *si) { - gimple stmt = gsi_stmt (*si); + gassign *stmt = as_a gassign * (gsi_stmt (*si)); enum tree_code subcode = gimple_assign_rhs_code (stmt); location_t loc = gimple_location (stmt); @@ -600,7 +600,7 @@ gsi_replace_with_seq_vops (gimple_stmt_iterator *si_p, gimple_seq stmts) { gimple new_stmt = gsi_stmt (i); if ((gimple_assign_single_p (new_stmt) - !is_gimple_reg (gimple_assign_lhs (new_stmt))) + !is_gimple_reg (gimple_assign_lhs (as_a gassign * (new_stmt ||
[gimple-classes, committed 08/44] tree-ssa-forwprop.c: Use gassign * in various places
gcc/ChangeLog.gimple-classes: * tree-ssa-forwprop.c (get_prop_source_stmt): Strengthen return type and local def_stmt from gimple to gassign *, using a dyn_cast in place of an is_gimple_assign. (can_propagate_from): Strengthen param from gimple to gassign *. (forward_propagate_into_comparison_1): Likewise for locals named def_stmt. (forward_propagate_into_cond): Likewise. (simplify_bitwise_binary_1): Introduce local assign, using it in place of def for typesafety. (associate_plusminus): Strengthen local stmt from gimple to gassign *. Likewise for locals def_stmt, using dyn_casts in place of is_gimple_assign calls. Likewise for local def_stmt2. (associate_pointerplus): Likewise. (simplify_bitfield_ref): Strengthen local def_stmt from gimple to gassign *. (simplify_permutation): Likewise, also for local def_stmt2. (simplify_vector_constructor): Likewise. (pass_forwprop::execute): Strengthen local stmt from gimple to gassign *, using a dyn_cast in place of an is_gimple_assign. --- gcc/ChangeLog.gimple-classes | 22 gcc/tree-ssa-forwprop.c | 83 +++- 2 files changed, 65 insertions(+), 40 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index a60a771..5902705 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,27 @@ 2014-10-31 David Malcolm dmalc...@redhat.com + * tree-ssa-forwprop.c (get_prop_source_stmt): Strengthen return + type and local def_stmt from gimple to gassign *, using a + dyn_cast in place of an is_gimple_assign. + (can_propagate_from): Strengthen param from gimple to gassign *. + (forward_propagate_into_comparison_1): Likewise for locals named + def_stmt. + (forward_propagate_into_cond): Likewise. + (simplify_bitwise_binary_1): Introduce local assign, using it in + place of def for typesafety. + (associate_plusminus): Strengthen local stmt from gimple to + gassign *. Likewise for locals def_stmt, using dyn_casts in + place of is_gimple_assign calls. Likewise for local def_stmt2. + (associate_pointerplus): Likewise. + (simplify_bitfield_ref): Strengthen local def_stmt from gimple + to gassign *. + (simplify_permutation): Likewise, also for local def_stmt2. + (simplify_vector_constructor): Likewise. + (pass_forwprop::execute): Strengthen local stmt from gimple to + gassign *, using a dyn_cast in place of an is_gimple_assign. + +2014-10-31 David Malcolm dmalc...@redhat.com + * gimple.h (is_a_helper const gassign *::test): New. (gimple_assign_copy_p): Update return type from bool to gassign *, returning GS if the predicate holds. diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 3a03b9f..7a51516 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -241,14 +241,12 @@ get_prop_dest_stmt (tree name, tree *final_name_p) it is set to whether the chain to NAME is a single use chain or not. SINGLE_USE_P is not written to if SINGLE_USE_ONLY is set. */ -static gimple +static gassign * get_prop_source_stmt (tree name, bool single_use_only, bool *single_use_p) { bool single_use = true; do { -gimple def_stmt = SSA_NAME_DEF_STMT (name); - if (!has_single_use (name)) { single_use = false; @@ -257,7 +255,8 @@ get_prop_source_stmt (tree name, bool single_use_only, bool *single_use_p) } /* If name is defined by a PHI node or is the default def, bail out. */ -if (!is_gimple_assign (def_stmt)) +gassign *def_stmt = dyn_cast gassign * (SSA_NAME_DEF_STMT (name)); +if (!def_stmt) return NULL; /* If def_stmt is a simple copy, continue looking. */ @@ -277,7 +276,7 @@ get_prop_source_stmt (tree name, bool single_use_only, bool *single_use_p) propagation source. Returns true if so, otherwise false. */ static bool -can_propagate_from (gimple def_stmt) +can_propagate_from (gassign *def_stmt) { gcc_assert (is_gimple_assign (def_stmt)); @@ -438,7 +437,7 @@ forward_propagate_into_comparison_1 (gimple stmt, simplify comparisons against constants. */ if (TREE_CODE (op0) == SSA_NAME) { - gimple def_stmt = get_prop_source_stmt (op0, false, single_use0_p); + gassign *def_stmt = get_prop_source_stmt (op0, false, single_use0_p); if (def_stmt can_propagate_from (def_stmt)) { rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt); @@ -452,7 +451,7 @@ forward_propagate_into_comparison_1 (gimple stmt, /* If that wasn't successful, try the second operand. */ if (TREE_CODE (op1) == SSA_NAME) { - gimple def_stmt = get_prop_source_stmt (op1, false, single_use1_p); + gassign *def_stmt = get_prop_source_stmt (op1,
[gimple-classes, committed 05/44] More gcall *
gcc/ChangeLog.gimple-classes: * gimple.c (gimple_set_lhs): Add checked casts to gassign * and gcall * as appropriate. * tree-cfg.c (execute_fixup_cfg): Introduce local call_stmt via a dyn_cast and use it in place of stmt where appropriate * tree-cfgcleanup.c (split_bb_on_noreturn_calls): Strengthen local stmt from gimple to gcall *, replacing an is_gimple_call with a dyn_cast. * tree-cfgcleanup.h (fixup_noreturn_call): Strengthen param from gimple to gcall *. * tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace is_gimple_call with a dyn_cast, introducing local call_stmt and using it in place of stmt for typesafety. * tree-ssa-propagate.c (finish_update_gimple_call): Strengthen params new_stmt and stmt from gimple to gcall *. --- gcc/ChangeLog.gimple-classes | 17 + gcc/gimple.c | 4 ++-- gcc/tree-cfg.c | 9 + gcc/tree-cfgcleanup.c| 4 ++-- gcc/tree-cfgcleanup.h| 2 +- gcc/tree-ssa-dce.c | 10 +- gcc/tree-ssa-propagate.c | 4 ++-- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index e2fb3d2..33bd5bf 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,22 @@ 2014-10-31 David Malcolm dmalc...@redhat.com + * gimple.c (gimple_set_lhs): Add checked casts to gassign * and + gcall * as appropriate. + * tree-cfg.c (execute_fixup_cfg): Introduce local call_stmt + via a dyn_cast and use it in place of stmt where appropriate + * tree-cfgcleanup.c (split_bb_on_noreturn_calls): Strengthen + local stmt from gimple to gcall *, replacing an is_gimple_call + with a dyn_cast. + * tree-cfgcleanup.h (fixup_noreturn_call): Strengthen param from + gimple to gcall *. + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace + is_gimple_call with a dyn_cast, introducing local call_stmt and + using it in place of stmt for typesafety. + * tree-ssa-propagate.c (finish_update_gimple_call): Strengthen + params new_stmt and stmt from gimple to gcall *. + +2014-10-31 David Malcolm dmalc...@redhat.com + * config/i386/i386.c (add_condition_to_bb): Strengthen local call_cond_stmt from gimple to gcall *. * gimple-fold.c (gimple_build): Likewise for local stmt. diff --git a/gcc/gimple.c b/gcc/gimple.c index b58c9db..d86ca49 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1640,9 +1640,9 @@ gimple_set_lhs (gimple stmt, tree lhs) enum gimple_code code = gimple_code (stmt); if (code == GIMPLE_ASSIGN) -gimple_assign_set_lhs (stmt, lhs); +gimple_assign_set_lhs (as_a gassign * (stmt), lhs); else if (code == GIMPLE_CALL) -gimple_call_set_lhs (stmt, lhs); +gimple_call_set_lhs (as_a gcall * (stmt), lhs); else gcc_unreachable (); } diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 1d1aaef..1ec250b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8555,12 +8555,13 @@ execute_fixup_cfg (void) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) { gimple stmt = gsi_stmt (gsi); - tree decl = is_gimple_call (stmt) - ? gimple_call_fndecl (stmt) + gcall *call_stmt = dyn_cast gcall * (stmt); + tree decl = call_stmt + ? gimple_call_fndecl (call_stmt) : NULL; if (decl) { - int flags = gimple_call_flags (stmt); + int flags = gimple_call_flags (call_stmt); if (flags (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE)) { if (gimple_purge_dead_abnormal_call_edges (bb)) @@ -8574,7 +8575,7 @@ execute_fixup_cfg (void) } if (flags ECF_NORETURN - fixup_noreturn_call (stmt)) + fixup_noreturn_call (call_stmt)) todo |= TODO_cleanup_cfg; } diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 7383924..fc9f2af 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -645,9 +645,9 @@ split_bb_on_noreturn_calls (basic_block bb) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (gsi)) { - gimple stmt = gsi_stmt (gsi); + gcall *stmt = dyn_cast gcall * (gsi_stmt (gsi)); - if (!is_gimple_call (stmt)) + if (!stmt) continue; if (gimple_call_noreturn_p (stmt)) diff --git a/gcc/tree-cfgcleanup.h b/gcc/tree-cfgcleanup.h index 19ff170..9538ddd 100644 --- a/gcc/tree-cfgcleanup.h +++ b/gcc/tree-cfgcleanup.h @@ -23,6 +23,6 @@ along with GCC; see the file COPYING3. If not see /* In tree-cfgcleanup.c */ extern bitmap cfgcleanup_altered_bbs; extern bool cleanup_tree_cfg (void); -extern bool fixup_noreturn_call (gimple stmt); +extern bool
[gimple-classes, committed 21/44] tree-eh.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-eh.c (stmt_could_throw_1_p): Add checked casts. (sink_clobbers): Add checked cast. --- gcc/ChangeLog.gimple-classes | 5 + gcc/tree-eh.c| 8 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 7055011..7834eb0 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,10 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-eh.c (stmt_could_throw_1_p): Add checked casts. + (sink_clobbers): Add checked cast. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-if-conv.c (parse_predicate): Replace is_gimple_assign with a dyn_cast, strengthening local s from gimple to gassign *. (if_convertible_gimple_assign_stmt_p): Strengthen param stmt diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 4974051..f867142 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2760,7 +2760,7 @@ stmt_could_throw_1_p (gimple stmt) { if (is_gimple_assign (stmt) TREE_CODE_CLASS (code) == tcc_comparison) - t = TREE_TYPE (gimple_assign_rhs1 (stmt)); + t = TREE_TYPE (gimple_assign_rhs1 (as_a gassign * (stmt))); else if (gimple_code (stmt) == GIMPLE_COND) t = TREE_TYPE (gimple_cond_lhs (stmt)); else @@ -2776,7 +2776,9 @@ stmt_could_throw_1_p (gimple stmt) } /* Check if the main expression may trap. */ - t = is_gimple_assign (stmt) ? gimple_assign_rhs2 (stmt) : NULL; + t = (is_gimple_assign (stmt) + ? gimple_assign_rhs2 (as_a gassign * (stmt)) + : NULL); ret = operation_could_trap_helper_p (code, fp_operation, honor_trapv, honor_nans, honor_snans, t, handled); @@ -3514,7 +3516,7 @@ sink_clobbers (basic_block bb) continue; if (gimple_code (stmt) == GIMPLE_LABEL) break; - lhs = gimple_assign_lhs (stmt); + lhs = gimple_assign_lhs (as_a gassign * (stmt)); /* Unfortunately we don't have dominance info updated at this point, so checking if dominated_by_p (CDI_DOMINATORS, succbb, -- 1.7.11.7
[gimple-classes, committed 10/44] gimplify-me.c: Use gassign
gcc/ChangeLog.gimple-classes: * gimplify-me.c (gimple_regimplify_operands): Replace a couple of is_gimple_assign calls with dyn_cast, introducing locals assign_stmt and using them in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 6 ++ gcc/gimplify-me.c| 12 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index e8d2d6e..33911d3 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,11 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * gimplify-me.c (gimple_regimplify_operands): Replace a couple of + is_gimple_assign calls with dyn_cast, introducing locals + assign_stmt and using them in place of stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * auto-profile.c (afdo_propagate_circuit): Replace a check for GIMPLE_ASSIGN within the while loop with a dyn_cast, introducing a local def_assign, using it in place of stmt for typesafety. diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c index 9d969de..280d95c 100644 --- a/gcc/gimplify-me.c +++ b/gcc/gimplify-me.c @@ -240,17 +240,18 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p) for (i = num_ops; i 0; i--) { tree op = gimple_op (stmt, i - 1); + gassign *assign_stmt; if (op == NULL_TREE) continue; if (i == 1 (is_gimple_call (stmt) || is_gimple_assign (stmt))) gimplify_expr (op, pre, NULL, is_gimple_lvalue, fb_lvalue); else if (i == 2 - is_gimple_assign (stmt) + (assign_stmt = dyn_cast gassign * (stmt)) num_ops == 2 get_gimple_rhs_class (gimple_expr_code (stmt)) == GIMPLE_SINGLE_RHS) gimplify_expr (op, pre, NULL, - rhs_predicate_for (gimple_assign_lhs (stmt)), + rhs_predicate_for (gimple_assign_lhs (assign_stmt)), fb_rvalue); else if (i == 2 is_gimple_call (stmt)) { @@ -269,13 +270,14 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p) if (lhs !is_gimple_reg (lhs)) { bool need_temp = false; + gassign *assign_stmt; - if (is_gimple_assign (stmt) + if ((assign_stmt = dyn_cast gassign * (stmt)) num_ops == 2 get_gimple_rhs_class (gimple_expr_code (stmt)) == GIMPLE_SINGLE_RHS) - gimplify_expr (gimple_assign_rhs1_ptr (stmt), pre, NULL, - rhs_predicate_for (gimple_assign_lhs (stmt)), + gimplify_expr (gimple_assign_rhs1_ptr (assign_stmt), pre, NULL, + rhs_predicate_for (gimple_assign_lhs (assign_stmt)), fb_rvalue); else if (is_gimple_reg (lhs)) { -- 1.7.11.7
[gimple-classes, committed 04/44] Use gcall * in more places
gcc/ChangeLog.gimple-classes: * config/i386/i386.c (add_condition_to_bb): Strengthen local call_cond_stmt from gimple to gcall *. * gimple-fold.c (gimple_build): Likewise for local stmt. * gimple-match-head.c (maybe_push_res_to_seq): Likewise for local new_stmt. * tree-cfgcleanup.c (fixup_noreturn_call): Likewise for param stmt. * tree-ssa-math-opts.c (bswap_replace): Likewise for local call. * tree-ssa-propagate.c (update_call_from_tree): Likewise for local stmt, adding a checked cast. * ubsan.c (instrument_si_overflow): Likewise for local g. --- gcc/ChangeLog.gimple-classes | 14 ++ gcc/config/i386/i386.c | 2 +- gcc/gimple-fold.c| 2 +- gcc/gimple-match-head.c | 2 +- gcc/tree-cfgcleanup.c| 2 +- gcc/tree-ssa-math-opts.c | 2 +- gcc/tree-ssa-propagate.c | 2 +- gcc/ubsan.c | 2 +- 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 5b408e3..e2fb3d2 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,19 @@ 2014-10-31 David Malcolm dmalc...@redhat.com + * config/i386/i386.c (add_condition_to_bb): Strengthen local + call_cond_stmt from gimple to gcall *. + * gimple-fold.c (gimple_build): Likewise for local stmt. + * gimple-match-head.c (maybe_push_res_to_seq): Likewise for local + new_stmt. + * tree-cfgcleanup.c (fixup_noreturn_call): Likewise for param + stmt. + * tree-ssa-math-opts.c (bswap_replace): Likewise for local call. + * tree-ssa-propagate.c (update_call_from_tree): Likewise for local stmt, + adding a checked cast. + * ubsan.c (instrument_si_overflow): Likewise for local g. + +2014-10-31 David Malcolm dmalc...@redhat.com + * gimple-low.c (lower_builtin_setjmp): Strengthen local stmt from gimple to gcall *, via a checked cast. (lower_builtin_posix_memalign): Likewise for local call. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 5b48f6a..6b15088 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -31419,7 +31419,7 @@ add_condition_to_bb (tree function_decl, tree version_decl, gimple return_stmt; tree convert_expr, result_var; gimple convert_stmt; - gimple call_cond_stmt; + gcall *call_cond_stmt; gimple if_else_stmt; basic_block bb1, bb2, bb3; diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index e7456cd..c5f1e07 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -5629,7 +5629,7 @@ gimple_build (gimple_seq *seq, location_t loc, if (!res) { tree decl = builtin_decl_implicit (fn); - gimple stmt = gimple_build_call (decl, 1, arg0); + gcall *stmt = gimple_build_call (decl, 1, arg0); if (!VOID_TYPE_P (type)) { if (gimple_in_ssa_p (cfun)) diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c index 520e523..844f08a 100644 --- a/gcc/gimple-match-head.c +++ b/gcc/gimple-match-head.c @@ -360,7 +360,7 @@ maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops, return NULL_TREE; if (!res) res = make_ssa_name (type, NULL); - gimple new_stmt = gimple_build_call (decl, nargs, ops[0], ops[1], ops[2]); + gcall *new_stmt = gimple_build_call (decl, nargs, ops[0], ops[1], ops[2]); gimple_call_set_lhs (new_stmt, res); gimple_seq_add_stmt_without_update (seq, new_stmt); return res; diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index d0da8c0..7383924 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -566,7 +566,7 @@ remove_forwarder_block (basic_block bb) and remove LHS. Return true if something changed. */ bool -fixup_noreturn_call (gimple stmt) +fixup_noreturn_call (gcall *stmt) { basic_block bb = gimple_bb (stmt); bool changed = false; diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index b408b9f..be567e0 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2193,7 +2193,7 @@ bswap_replace (gimple cur_stmt, gimple_stmt_iterator gsi, gimple src_stmt, struct symbolic_number *n, bool bswap) { tree src, tmp, tgt; - gimple call; + gcall *call; src = gimple_assign_rhs1 (src_stmt); tgt = gimple_assign_lhs (cur_stmt); diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index c246ed6..6625000 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -773,7 +773,7 @@ update_gimple_call (gimple_stmt_iterator *si_p, tree fn, int nargs, ...) bool update_call_from_tree (gimple_stmt_iterator *si_p, tree expr) { - gimple stmt = gsi_stmt (*si_p); + gcall *stmt = as_a gcall * (gsi_stmt (*si_p)); if (valid_gimple_call_p (expr)) { diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 7a69000..9ee3783 100644 --- a/gcc/ubsan.c +++
[gimple-classes, committed 25/44] tree-ssa-coalesce.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-coalesce.c (build_ssa_conflict_graph): Replace is_gimple_assign with dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. (create_outofssa_var_map): Within case GIMPLE_ASSIGN introduce local assign_stmt, using it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 8 gcc/tree-ssa-coalesce.c | 15 --- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index ca6b1be..c7ca9fd 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,13 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-coalesce.c (build_ssa_conflict_graph): Replace + is_gimple_assign with dyn_cast, introducing local assign_stmt, + using it in place of stmt for typesafety. + (create_outofssa_var_map): Within case GIMPLE_ASSIGN introduce + local assign_stmt, using it in place of stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-ccp.c (get_default_value): Replace is_gimple_assign with a dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 7d1825d..74ea352 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -850,11 +850,11 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) This is handled by simply removing the SRC of the copy from the live list, and processing the stmt normally. */ - if (is_gimple_assign (stmt)) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { - tree lhs = gimple_assign_lhs (stmt); - tree rhs1 = gimple_assign_rhs1 (stmt); - if (gimple_assign_copy_p (stmt) + tree lhs = gimple_assign_lhs (assign_stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); + if (gimple_assign_copy_p (assign_stmt) TREE_CODE (lhs) == SSA_NAME TREE_CODE (rhs1) == SSA_NAME) live_track_clear_var (live, rhs1); @@ -1003,9 +1003,10 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) { case GIMPLE_ASSIGN: { - tree lhs = gimple_assign_lhs (stmt); - tree rhs1 = gimple_assign_rhs1 (stmt); - if (gimple_assign_ssa_name_copy_p (stmt) + gassign *assign_stmt = as_a gassign * (stmt); + tree lhs = gimple_assign_lhs (assign_stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); + if (gimple_assign_ssa_name_copy_p (assign_stmt) gimple_can_coalesce_p (lhs, rhs1)) { v1 = SSA_NAME_VERSION (lhs); -- 1.7.11.7
[gimple-classes, committed 24/44] tree-ssa-ccp.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-ccp.c (get_default_value): Replace is_gimple_assign with a dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. (likely_value): Add a checked cast. (evaluate_stmt): Replace checks against GIMPLE_ASSIGN with dyn_cast, introducing locals assign_stmt, using them in place of stmt for typesafety. (ccp_fold_stmt): Add checked cast within case GIMPLE_ASSIGN. (visit_assignment): Add checked casts. (pass_fold_builtins::execute): Add checked cast. --- gcc/ChangeLog.gimple-classes | 13 + gcc/tree-ssa-ccp.c | 35 ++- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 9233d8a..ca6b1be 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,18 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-ccp.c (get_default_value): Replace is_gimple_assign + with a dyn_cast, introducing local assign_stmt, using it in + place of stmt for typesafety. + (likely_value): Add a checked cast. + (evaluate_stmt): Replace checks against GIMPLE_ASSIGN with + dyn_cast, introducing locals assign_stmt, using them in place of + stmt for typesafety. + (ccp_fold_stmt): Add checked cast within case GIMPLE_ASSIGN. + (visit_assignment): Add checked casts. + (pass_fold_builtins::execute): Add checked cast. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-alias.c (stmt_may_clobber_global_p): Within case GIMPLE_ASSIGN, add a checked cast. (ao_ref_init_from_ptr_and_size): Both the gimple_assign_single_p diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index a331e5c..fb708d9 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -312,12 +312,13 @@ get_default_value (tree var) } } } - else if (is_gimple_assign (stmt)) + else if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { tree cst; - if (gimple_assign_single_p (stmt) - DECL_P (gimple_assign_rhs1 (stmt)) - (cst = get_symbol_constant_value (gimple_assign_rhs1 (stmt + if (gimple_assign_single_p (assign_stmt) + DECL_P (gimple_assign_rhs1 (assign_stmt)) + (cst = + get_symbol_constant_value (gimple_assign_rhs1 (assign_stmt { val.lattice_val = CONSTANT; val.value = cst; @@ -711,7 +712,7 @@ likely_value (gimple stmt) return UNDEFINED; else if (code == GIMPLE_ASSIGN has_undefined_operand) { - switch (gimple_assign_rhs_code (stmt)) + switch (gimple_assign_rhs_code (as_a gassign * (stmt))) { /* Unary operators are handled with all_undefined_operands. */ case PLUS_EXPR: @@ -1691,14 +1692,14 @@ evaluate_stmt (gimple stmt) else if (likelyvalue == VARYING) { enum gimple_code code = gimple_code (stmt); - if (code == GIMPLE_ASSIGN) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { - enum tree_code subcode = gimple_assign_rhs_code (stmt); + enum tree_code subcode = gimple_assign_rhs_code (assign_stmt); /* Other cases cannot satisfy is_gimple_min_invariant without folding. */ if (get_gimple_rhs_class (subcode) == GIMPLE_SINGLE_RHS) -simplified = gimple_assign_rhs1 (stmt); +simplified = gimple_assign_rhs1 (assign_stmt); } else if (code == GIMPLE_SWITCH) simplified = gimple_switch_index (as_a gswitch * (stmt)); @@ -1724,10 +1725,10 @@ evaluate_stmt (gimple stmt) val.lattice_val = VARYING; val.value = NULL_TREE; val.mask = -1; - if (code == GIMPLE_ASSIGN) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { - enum tree_code subcode = gimple_assign_rhs_code (stmt); - tree rhs1 = gimple_assign_rhs1 (stmt); + enum tree_code subcode = gimple_assign_rhs_code (assign_stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); switch (get_gimple_rhs_class (subcode)) { case GIMPLE_SINGLE_RHS: @@ -1748,8 +1749,8 @@ evaluate_stmt (gimple stmt) if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) || POINTER_TYPE_P (TREE_TYPE (rhs1))) { - tree lhs = gimple_assign_lhs (stmt); - tree rhs2 = gimple_assign_rhs2 (stmt); + tree lhs = gimple_assign_lhs (assign_stmt); + tree rhs2 = gimple_assign_rhs2 (assign_stmt); val = bit_value_binop (subcode, TREE_TYPE (lhs), rhs1, rhs2); } @@ -2172,7 +2173,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi) case GIMPLE_ASSIGN: { - tree lhs =
[gimple-classes, committed 26/44] tree-ssa-copy.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-copy.c (stmt_may_generate_copy): Replace check against GIMPLE_ASSIGN with a dyn_cast, introducing local gassign * assign_stmt, using it in place of stmt for typesafety. (copy_prop_visit_assignment): Strengthen param stmt from gimple to gassign *. (copy_prop_visit_stmt): Introduce local gassign * assign_stmt from resuilt of gimple_assign_single_p, using it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 11 +++ gcc/tree-ssa-copy.c | 26 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index c7ca9fd..19a8295 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,16 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-copy.c (stmt_may_generate_copy): Replace check against + GIMPLE_ASSIGN with a dyn_cast, introducing local gassign * + assign_stmt, using it in place of stmt for typesafety. + (copy_prop_visit_assignment): Strengthen param stmt from gimple + to gassign *. + (copy_prop_visit_stmt): Introduce local gassign * assign_stmt + from resuilt of gimple_assign_single_p, using it in place of + stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-coalesce.c (build_ssa_conflict_graph): Replace is_gimple_assign with dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 3833dff..c46a17e 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -102,24 +102,25 @@ stmt_may_generate_copy (gimple stmt) if (gimple_code (stmt) == GIMPLE_PHI) return !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (stmt)); - if (gimple_code (stmt) != GIMPLE_ASSIGN) + gassign *assign_stmt = dyn_cast gassign * (stmt); + if (!assign_stmt) return false; /* If the statement has volatile operands, it won't generate a useful copy. */ - if (gimple_has_volatile_ops (stmt)) + if (gimple_has_volatile_ops (assign_stmt)) return false; /* Statements with loads and/or stores will never generate a useful copy. */ - if (gimple_vuse (stmt)) + if (gimple_vuse (assign_stmt)) return false; /* Otherwise, the only statements that generate useful copies are assignments whose RHS is just an SSA name that doesn't flow through abnormal edges. */ - return ((gimple_assign_rhs_code (stmt) == SSA_NAME - !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_assign_rhs1 (stmt))) - || is_gimple_min_invariant (gimple_assign_rhs1 (stmt))); + return ((gimple_assign_rhs_code (assign_stmt) == SSA_NAME + !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_assign_rhs1 (assign_stmt))) + || is_gimple_min_invariant (gimple_assign_rhs1 (assign_stmt))); } @@ -210,7 +211,7 @@ dump_copy_of (FILE *file, tree var) value and store the LHS into *RESULT_P. */ static enum ssa_prop_result -copy_prop_visit_assignment (gimple stmt, tree *result_p) +copy_prop_visit_assignment (gassign *stmt, tree *result_p) { tree lhs, rhs; @@ -297,14 +298,15 @@ copy_prop_visit_stmt (gimple stmt, edge *taken_edge_p, tree *result_p) fprintf (dump_file, \n); } - if (gimple_assign_single_p (stmt) - TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME - (TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME - || is_gimple_min_invariant (gimple_assign_rhs1 (stmt + gassign *assign_stmt; + if ((assign_stmt = gimple_assign_single_p (stmt)) + TREE_CODE (gimple_assign_lhs (assign_stmt)) == SSA_NAME + (TREE_CODE (gimple_assign_rhs1 (assign_stmt)) == SSA_NAME + || is_gimple_min_invariant (gimple_assign_rhs1 (assign_stmt { /* If the statement is a copy assignment, evaluate its RHS to see if the lattice value of its output has changed. */ - retval = copy_prop_visit_assignment (stmt, result_p); + retval = copy_prop_visit_assignment (assign_stmt, result_p); } else if (gimple_code (stmt) == GIMPLE_COND) { -- 1.7.11.7
[gimple-classes, committed 14/44] gimple-match-head.c: Use gassign
gcc/ChangeLog.gimple-classes: * gimple-match-head.c (gimple_simplify): Within case GIMPLE_ASSIGN, introduce local assign_stmt via a checked cast and use it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 6 ++ gcc/gimple-match-head.c | 25 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index c766c36..baf8c76 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,11 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-match-head.c (gimple_simplify): Within + case GIMPLE_ASSIGN, introduce local assign_stmt via a checked + cast and use it in place of stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-fold.h (rewrite_to_defined_overflow): Strengthen from gimple to gassign *. * gimple-fold.c (rewrite_to_defined_overflow): Likewise. diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c index 844f08a..fd829a9 100644 --- a/gcc/gimple-match-head.c +++ b/gcc/gimple-match-head.c @@ -589,16 +589,17 @@ gimple_simplify (gimple stmt, { case GIMPLE_ASSIGN: { - enum tree_code code = gimple_assign_rhs_code (stmt); - tree type = TREE_TYPE (gimple_assign_lhs (stmt)); - switch (gimple_assign_rhs_class (stmt)) + gassign *assign_stmt = as_a gassign * (stmt); + enum tree_code code = gimple_assign_rhs_code (assign_stmt); + tree type = TREE_TYPE (gimple_assign_lhs (assign_stmt)); + switch (gimple_assign_rhs_class (assign_stmt)) { case GIMPLE_SINGLE_RHS: if (code == REALPART_EXPR || code == IMAGPART_EXPR || code == VIEW_CONVERT_EXPR) { - tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0); + tree op0 = TREE_OPERAND (gimple_assign_rhs1 (assign_stmt), 0); if (valueize TREE_CODE (op0) == SSA_NAME) { tree tem = valueize (op0); @@ -611,7 +612,7 @@ gimple_simplify (gimple stmt, } else if (code == BIT_FIELD_REF) { - tree rhs1 = gimple_assign_rhs1 (stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); tree op0 = TREE_OPERAND (rhs1, 0); if (valueize TREE_CODE (op0) == SSA_NAME) { @@ -628,7 +629,7 @@ gimple_simplify (gimple stmt, else if (code == SSA_NAME valueize) { - tree op0 = gimple_assign_rhs1 (stmt); + tree op0 = gimple_assign_rhs1 (assign_stmt); tree valueized = valueize (op0); if (!valueized || op0 == valueized) return false; @@ -639,7 +640,7 @@ gimple_simplify (gimple stmt, break; case GIMPLE_UNARY_RHS: { - tree rhs1 = gimple_assign_rhs1 (stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); if (valueize TREE_CODE (rhs1) == SSA_NAME) { tree tem = valueize (rhs1); @@ -652,14 +653,14 @@ gimple_simplify (gimple stmt, } case GIMPLE_BINARY_RHS: { - tree rhs1 = gimple_assign_rhs1 (stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); if (valueize TREE_CODE (rhs1) == SSA_NAME) { tree tem = valueize (rhs1); if (tem) rhs1 = tem; } - tree rhs2 = gimple_assign_rhs2 (stmt); + tree rhs2 = gimple_assign_rhs2 (assign_stmt); if (valueize TREE_CODE (rhs2) == SSA_NAME) { tree tem = valueize (rhs2); @@ -673,21 +674,21 @@ gimple_simplify (gimple stmt, } case GIMPLE_TERNARY_RHS: { - tree rhs1 = gimple_assign_rhs1 (stmt); + tree rhs1 = gimple_assign_rhs1 (assign_stmt); if (valueize TREE_CODE (rhs1) == SSA_NAME) { tree tem = valueize (rhs1); if (tem) rhs1 = tem; } - tree rhs2 = gimple_assign_rhs2 (stmt); + tree rhs2 = gimple_assign_rhs2 (assign_stmt); if (valueize TREE_CODE (rhs2) == SSA_NAME) { tree tem = valueize (rhs2); if (tem) rhs2 = tem; } - tree rhs3 = gimple_assign_rhs3 (stmt); + tree rhs3 = gimple_assign_rhs3 (assign_stmt); if (valueize TREE_CODE (rhs3) == SSA_NAME) { tree tem = valueize (rhs3); -- 1.7.11.7
[gimple-classes, committed 09/44] auto-profile.c: Use gassign
gcc/ChangeLog.gimple-classes: * auto-profile.c (afdo_propagate_circuit): Replace a check for GIMPLE_ASSIGN within the while loop with a dyn_cast, introducing a local def_assign, using it in place of stmt for typesafety. This involves replacing the series of while conditions in the head of the while into a list of conditionals within its body that break out of the loop, thus requiring the conditions to be negated. --- gcc/ChangeLog.gimple-classes | 10 ++ gcc/auto-profile.c | 15 +++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 5902705..e8d2d6e 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,3 +1,13 @@ +2014-11-03 David Malcolm dmalc...@redhat.com + + * auto-profile.c (afdo_propagate_circuit): Replace a check for + GIMPLE_ASSIGN within the while loop with a dyn_cast, introducing + a local def_assign, using it in place of stmt for typesafety. + This involves replacing the series of while conditions in the head + of the while into a list of conditionals within its body that + break out of the loop, thus requiring the conditions to be + negated. + 2014-10-31 David Malcolm dmalc...@redhat.com * tree-ssa-forwprop.c (get_prop_source_stmt): Strengthen return diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index ba4e567..320b2f6 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -1262,10 +1262,17 @@ afdo_propagate_circuit (const bb_set annotated_bb, edge_set *annotated_edge) if (!is_bb_annotated (bb, annotated_bb)) continue; def_stmt = SSA_NAME_DEF_STMT (cmp_lhs); -while (def_stmt gimple_code (def_stmt) == GIMPLE_ASSIGN -gimple_assign_single_p (def_stmt) -TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME) - def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt)); +while (def_stmt) + { + gassign *def_assign = dyn_cast gassign * (def_stmt); + if (!def_assign) + break; + if (!gimple_assign_single_p (def_assign)) + break; + if (TREE_CODE (gimple_assign_rhs1 (def_assign)) != SSA_NAME) + break; + def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_assign)); + } if (!def_stmt) continue; gphi *phi_stmt = dyn_cast gphi * (def_stmt); -- 1.7.11.7
[gimple-classes, committed 28/44] tree-ssa-dom.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-dom.c (initialize_hash_element): Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. (record_equivalences_from_incoming_edge): Replace is_gimple_assign with a dyn_cast, introducing local gassign * defassign, using it in place of defstmt for typesafety. (simple_iv_increment_p): Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. (eliminate_redundant_computations): Add checked cast. (record_equivalences_from_stmt): Strengthen param stmt from gimple to gassign *. (optimize_stmt): Add checked casts. Introduce local gassign * assign_stmt from result of gimple_assign_single_p and use it in place of stmt for typesafety. (get_rhs_or_phi_arg): Add checked cast. (get_lhs_or_phi_result): Likewise. (propagate_rhs_into_lhs): Introduce local gassign * assign_stmt from result of gimple_assign_single_p and use it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 23 gcc/tree-ssa-dom.c | 84 +++- 2 files changed, 66 insertions(+), 41 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 8230179..48942c1 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,28 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-dom.c (initialize_hash_element): Replace check for + GIMPLE_ASSIGN with a dyn_cast, introducing local assign_stmt, + using it in place of stmt for typesafety. + (record_equivalences_from_incoming_edge): Replace is_gimple_assign + with a dyn_cast, introducing local gassign * defassign, using it + in place of defstmt for typesafety. + (simple_iv_increment_p): Replace check for GIMPLE_ASSIGN with a + dyn_cast, introducing local assign_stmt, using it in place of + stmt for typesafety. + (eliminate_redundant_computations): Add checked cast. + (record_equivalences_from_stmt): Strengthen param stmt from + gimple to gassign *. + (optimize_stmt): Add checked casts. Introduce local gassign * + assign_stmt from result of gimple_assign_single_p and use it in + place of stmt for typesafety. + (get_rhs_or_phi_arg): Add checked cast. + (get_lhs_or_phi_result): Likewise. + (propagate_rhs_into_lhs): Introduce local gassign * assign_stmt + from result of gimple_assign_single_p and use it in place of + stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Within case GIMPLE_ASSIGN, introduce local assign_stmt and use in place of stmt for typesafety. diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index c1ed637..4f563bd 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -275,7 +275,7 @@ static void record_equality (tree, tree); static void record_equivalences_from_phis (basic_block); static void record_equivalences_from_incoming_edge (basic_block); static void eliminate_redundant_computations (gimple_stmt_iterator *); -static void record_equivalences_from_stmt (gimple, int); +static void record_equivalences_from_stmt (gassign *, int); static void remove_local_expressions_from_table (void); static void restore_vars_to_original_value (void); static edge single_incoming_edge_ignoring_loop_edges (basic_block); @@ -291,37 +291,37 @@ initialize_hash_element (gimple stmt, tree lhs, enum gimple_code code = gimple_code (stmt); struct hashable_expr *expr = element-expr; - if (code == GIMPLE_ASSIGN) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { - enum tree_code subcode = gimple_assign_rhs_code (stmt); + enum tree_code subcode = gimple_assign_rhs_code (assign_stmt); switch (get_gimple_rhs_class (subcode)) { case GIMPLE_SINGLE_RHS: expr-kind = EXPR_SINGLE; - expr-type = TREE_TYPE (gimple_assign_rhs1 (stmt)); - expr-ops.single.rhs = gimple_assign_rhs1 (stmt); + expr-type = TREE_TYPE (gimple_assign_rhs1 (assign_stmt)); + expr-ops.single.rhs = gimple_assign_rhs1 (assign_stmt); break; case GIMPLE_UNARY_RHS: expr-kind = EXPR_UNARY; - expr-type = TREE_TYPE (gimple_assign_lhs (stmt)); + expr-type = TREE_TYPE (gimple_assign_lhs (assign_stmt)); expr-ops.unary.op = subcode; - expr-ops.unary.opnd = gimple_assign_rhs1 (stmt); + expr-ops.unary.opnd = gimple_assign_rhs1 (assign_stmt); break; case GIMPLE_BINARY_RHS: expr-kind = EXPR_BINARY; - expr-type = TREE_TYPE (gimple_assign_lhs (stmt)); + expr-type =
[gimple-classes, committed 31/44] ipa-polymorphic-call.c: Use gassign
gcc/ChangeLog.gimple-classes: * ipa-polymorphic-call.c (walk_ssa_copies): Add checked cast. (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Introduce local gassign * def_assign from result of gimple_assign_single_p, using it in place of SSA_NAME_DEF_STMT (base_pointer) for typesafety. (noncall_stmt_may_be_vtbl_ptr_store): Replace is_gimple_assign with a dyn_cast, introducing local gassign * assign_stmt, using it in place of stmt for typesafety. (ipa_polymorphic_call_context::get_dynamic_type): Introduce local gassign * def_assign, setting it in two places from the result of gimple_assign_load_p, and using it in place of SSA_NAME_DEF_STMT (ref) for typesafety, noting that ref can change. --- gcc/ChangeLog.gimple-classes | 16 gcc/ipa-polymorphic-call.c | 27 ++- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 8e18adc..bfa2a15 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,21 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * ipa-polymorphic-call.c (walk_ssa_copies): Add checked cast. + (ipa_polymorphic_call_context::ipa_polymorphic_call_context): + Introduce local gassign * def_assign from result of + gimple_assign_single_p, using it in place of + SSA_NAME_DEF_STMT (base_pointer) for typesafety. + (noncall_stmt_may_be_vtbl_ptr_store): Replace is_gimple_assign + with a dyn_cast, introducing local gassign * assign_stmt, using + it in place of stmt for typesafety. + (ipa_polymorphic_call_context::get_dynamic_type): Introduce local + gassign * def_assign, setting it in two places from the result + of gimple_assign_load_p, and using it in place of + SSA_NAME_DEF_STMT (ref) for typesafety, noting that ref can + change. + +2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN, introduce local gassign * assign_stmt and use it in place of stmt for typesafety. diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 1bdbfb3..47eb7c8 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -818,7 +818,7 @@ walk_ssa_copies (tree op, hash_settree **global_visited = NULL) { if (gimple_assign_load_p (SSA_NAME_DEF_STMT (op))) goto done; - op = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (op)); + op = gimple_assign_rhs1 (as_a gassign * (SSA_NAME_DEF_STMT (op))); } STRIP_NOPS (op); } @@ -1039,11 +1039,12 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl, *instance = base_pointer; return; } + gassign *def_assign; if (TREE_CODE (base_pointer) == SSA_NAME SSA_NAME_DEF_STMT (base_pointer) - gimple_assign_single_p (SSA_NAME_DEF_STMT (base_pointer))) -base_type = TREE_TYPE (gimple_assign_rhs1 - (SSA_NAME_DEF_STMT (base_pointer))); + (def_assign = + gimple_assign_single_p (SSA_NAME_DEF_STMT (base_pointer +base_type = TREE_TYPE (gimple_assign_rhs1 (def_assign)); if (POINTER_TYPE_P (base_type)) combine_speculation_with (TYPE_MAIN_VARIANT (TREE_TYPE (base_type)), @@ -1094,9 +1095,9 @@ struct type_change_info static bool noncall_stmt_may_be_vtbl_ptr_store (gimple stmt) { - if (is_gimple_assign (stmt)) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (assign_stmt); if (gimple_clobber_p (stmt)) return false; @@ -1519,23 +1520,23 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance, ref = walk_ssa_copies (ref); /* Check if definition looks like vtable lookup. */ + gassign *def_assign; if (TREE_CODE (ref) == SSA_NAME !SSA_NAME_IS_DEFAULT_DEF (ref) - gimple_assign_load_p (SSA_NAME_DEF_STMT (ref)) - TREE_CODE (gimple_assign_rhs1 -(SSA_NAME_DEF_STMT (ref))) == MEM_REF) + (def_assign = gimple_assign_load_p (SSA_NAME_DEF_STMT (ref))) + TREE_CODE (gimple_assign_rhs1 (def_assign)) == MEM_REF) { ref = get_base_address -(TREE_OPERAND (gimple_assign_rhs1 -(SSA_NAME_DEF_STMT (ref)), 0)); + (TREE_OPERAND (gimple_assign_rhs1 (def_assign), 0)); ref = walk_ssa_copies (ref); /* Find base address of the lookup and see if it looks like vptr load. */ if (TREE_CODE (ref) == SSA_NAME !SSA_NAME_IS_DEFAULT_DEF (ref) - gimple_assign_load_p
[gimple-classes, committed 35/44] gimple_assign_rhs_to_tree takes a const gassign *
gcc/ChangeLog.gimple-classes: * cfgexpand.c (gimple_assign_rhs_to_tree): Strengthen param from gimple to const gassign *. (expand_debug_expr): Add checked cast. (expand_gimple_basic_block): Likewise. * cfgexpand.h (gimple_assign_rhs_to_tree): Strengthen param from gimple to const gassign *. * tree-ssa.c (insert_debug_temp_for_var_def): Add checked cast. --- gcc/ChangeLog.gimple-classes | 10 ++ gcc/cfgexpand.c | 8 +--- gcc/cfgexpand.h | 2 +- gcc/tree-ssa.c | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 631e0df..17a7c80 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,15 @@ 2014-11-04 David Malcolm dmalc...@redhat.com + * cfgexpand.c (gimple_assign_rhs_to_tree): Strengthen param from + gimple to const gassign *. + (expand_debug_expr): Add checked cast. + (expand_gimple_basic_block): Likewise. + * cfgexpand.h (gimple_assign_rhs_to_tree): Strengthen param from + gimple to const gassign *. + * tree-ssa.c (insert_debug_temp_for_var_def): Add checked cast. + +2014-11-04 David Malcolm dmalc...@redhat.com + * asan.c (asan_expand_check_ifn): Strengthen local shadow_test from gimple to gassign *. Introduce gassign * locals add_7, cast, t_ge_shadow, and_expr, using them in place of diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 73862eb..279202d 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -108,7 +108,7 @@ static rtx expand_debug_expr (tree); statement STMT. */ tree -gimple_assign_rhs_to_tree (gimple stmt) +gimple_assign_rhs_to_tree (const gassign *stmt) { tree t; enum gimple_rhs_class grhs_class; @@ -4558,7 +4558,8 @@ expand_debug_expr (tree exp) gimple g = get_gimple_for_ssa_name (exp); if (g) { - op0 = expand_debug_expr (gimple_assign_rhs_to_tree (g)); + op0 = expand_debug_expr (gimple_assign_rhs_to_tree ( + as_a gassign * (g))); if (!op0) return NULL; } @@ -5044,7 +5045,8 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) replace all uses of OP in debug insns with that temporary. */ gimple debugstmt; - tree value = gimple_assign_rhs_to_tree (def); + tree value = + gimple_assign_rhs_to_tree (as_a gassign * (def)); tree vexpr = make_node (DEBUG_EXPR_DECL); rtx val; enum machine_mode mode; diff --git a/gcc/cfgexpand.h b/gcc/cfgexpand.h index 6314b83..2b13996 100644 --- a/gcc/cfgexpand.h +++ b/gcc/cfgexpand.h @@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_CFGEXPAND_H #define GCC_CFGEXPAND_H -extern tree gimple_assign_rhs_to_tree (gimple); +extern tree gimple_assign_rhs_to_tree (const gassign *); extern HOST_WIDE_INT estimated_stack_frame_size (struct cgraph_node *); #endif /* GCC_CFGEXPAND_H */ diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index b893df9..f23107c 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -416,7 +416,7 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) } if (!no_value) - value = gimple_assign_rhs_to_tree (def_stmt); + value = gimple_assign_rhs_to_tree (as_a gassign * (def_stmt)); } if (value) -- 1.7.11.7
[gimple-classes, committed 40/44] ipa-icf-gimple.c: Use gassign
gcc/ChangeLog.gimple-classes: * ipa-icf-gimple.c (func_checker::compare_bb): Add checked casts. (func_checker::compare_gimple_assign): Strengthen params from gimple to const gassign *. * ipa-icf-gimple.h (func_checker::compare_gimple_assign): Likewise. --- gcc/ChangeLog.gimple-classes | 8 gcc/ipa-icf-gimple.c | 7 --- gcc/ipa-icf-gimple.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 07f4d6e..5f5d7c4 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,13 @@ 2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-icf-gimple.c (func_checker::compare_bb): Add checked casts. + (func_checker::compare_gimple_assign): Strengthen params from + gimple to const gassign *. + * ipa-icf-gimple.h (func_checker::compare_gimple_assign): + Likewise. + +2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-prop.c (stmt_may_be_vtbl_ptr_store): Replace is_gimple_assign with dyn_cast, introducing local gassign * assign_stmt and using it in place of stmt for typesafety. diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index c86e8c3..42ccdda 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -591,7 +591,8 @@ func_checker::compare_bb (sem_bb *bb1, sem_bb *bb2) return return_different_stmts (s1, s2, GIMPLE_CALL); break; case GIMPLE_ASSIGN: - if (!compare_gimple_assign (s1, s2)) + if (!compare_gimple_assign (as_a gassign * (s1), + as_a gassign * (s2))) return return_different_stmts (s1, s2, GIMPLE_ASSIGN); break; case GIMPLE_COND: @@ -682,11 +683,11 @@ func_checker::compare_gimple_call (gimple s1, gimple s2) } -/* Verifies for given GIMPLEs S1 and S2 that +/* Verifies for given GASSIGNs S1 and S2 that assignment statements are semantically equivalent. */ bool -func_checker::compare_gimple_assign (gimple s1, gimple s2) +func_checker::compare_gimple_assign (const gassign *s1, const gassign *s2) { tree arg1, arg2; tree_code code1, code2; diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h index 559df66..b54a14d 100644 --- a/gcc/ipa-icf-gimple.h +++ b/gcc/ipa-icf-gimple.h @@ -163,7 +163,7 @@ public: /* Verifies for given GIMPLEs S1 and S2 that assignment statements are semantically equivalent. */ - bool compare_gimple_assign (gimple s1, gimple s2); + bool compare_gimple_assign (const gassign *s1, const gassign *s2); /* Verifies for given GIMPLEs S1 and S2 that condition statements are semantically equivalent. */ -- 1.7.11.7
[gimple-classes, committed 43/44] sese.c: Use gassign
gcc/ChangeLog.gimple-classes: * sese.c (rename_uses): Add checked cast to gassign within region guarded by is_gimple_assign. (graphite_copy_stmts_from_block): Likewise. --- gcc/ChangeLog.gimple-classes | 6 ++ gcc/sese.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 9f85260..71bb31b 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,11 @@ 2014-11-05 David Malcolm dmalc...@redhat.com + * sese.c (rename_uses): Add checked cast to gassign within region + guarded by is_gimple_assign. + (graphite_copy_stmts_from_block): Likewise. + +2014-11-05 David Malcolm dmalc...@redhat.com + * predict.c (expr_expected_value_1): Replace is_gimple_assign with a dyn_cast, introducing local def_assign and using it in place of def for typesafety. diff --git a/gcc/sese.c b/gcc/sese.c index e0869e0..c702024 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -507,7 +507,7 @@ rename_uses (gimple copy, rename_map_type *rename_map, if (TREE_CODE (new_expr) == INTEGER_CST is_gimple_assign (copy)) { - tree rhs = gimple_assign_rhs1 (copy); + tree rhs = gimple_assign_rhs1 (as_a gassign * (copy)); if (TREE_CODE (rhs) == ADDR_EXPR) recompute_tree_invariant_for_addr_expr (rhs); @@ -548,7 +548,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, /* Do not copy induction variables. */ if (is_gimple_assign (stmt) - (lhs = gimple_assign_lhs (stmt)) + (lhs = gimple_assign_lhs (as_a gassign * (stmt))) TREE_CODE (lhs) == SSA_NAME is_gimple_reg (lhs) scev_analyzable_p (lhs, region)) -- 1.7.11.7
[gimple-classes, committed 39/44] ipa-prop.c: Use gassign
gcc/ChangeLog.gimple-classes: * ipa-prop.c (stmt_may_be_vtbl_ptr_store): Replace is_gimple_assign with dyn_cast, introducing local gassign * assign_stmt and using it in place of stmt for typesafety. (load_from_unmodified_param): Use assign rather than stmt for typesafety. (compute_complex_assign_jump_func): Strengthen param stmt from gimple to gassign *. (ipa_compute_jump_functions_for_edge): Add checked cast. (ipa_analyze_indirect_call_uses): Capture result of gimple_assign_single_p as new local def_assign, using it in place of def for typesafety. Similarly, replace is_gimple_assign with a dyn_cast, using it in place of def. --- gcc/ChangeLog.gimple-classes | 15 + gcc/ipa-prop.c | 50 +++- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index f428267..07f4d6e 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,20 @@ 2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-prop.c (stmt_may_be_vtbl_ptr_store): Replace + is_gimple_assign with dyn_cast, introducing local gassign * + assign_stmt and using it in place of stmt for typesafety. + (load_from_unmodified_param): Use assign rather than stmt for + typesafety. + (compute_complex_assign_jump_func): Strengthen param stmt from + gimple to gassign *. + (ipa_compute_jump_functions_for_edge): Add checked cast. + (ipa_analyze_indirect_call_uses): Capture result of + gimple_assign_single_p as new local def_assign, using it in place + of def for typesafety. Similarly, replace is_gimple_assign with + a dyn_cast, using it in place of def. + +2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-inline-analysis.c (unmodified_parm): Capture result of gimple_assign_single_p as a new local gassign * def_assign and use in place of SSA_NAME_DEF_STMT (op) for typesafety. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 334b2c3..d0f9702 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -669,9 +669,9 @@ stmt_may_be_vtbl_ptr_store (gimple stmt) return false; if (gimple_clobber_p (stmt)) return false; - else if (is_gimple_assign (stmt)) + else if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (assign_stmt); if (!AGGREGATE_TYPE_P (TREE_TYPE (lhs))) { @@ -1067,7 +1067,7 @@ load_from_unmodified_param (struct func_body_info *fbi, if (!assign) return -1; - op1 = gimple_assign_rhs1 (stmt); + op1 = gimple_assign_rhs1 (assign); if (TREE_CODE (op1) != PARM_DECL) return -1; @@ -1302,7 +1302,7 @@ static void compute_complex_assign_jump_func (struct func_body_info *fbi, struct ipa_node_params *info, struct ipa_jump_func *jfunc, - gcall *call, gimple stmt, tree name, + gcall *call, gassign *stmt, tree name, tree param_type) { HOST_WIDE_INT offset, size, max_size; @@ -1966,7 +1966,8 @@ ipa_compute_jump_functions_for_edge (struct func_body_info *fbi, gimple stmt = SSA_NAME_DEF_STMT (arg); if (is_gimple_assign (stmt)) compute_complex_assign_jump_func (fbi, info, jfunc, - call, stmt, arg, param_type); + call, as_a gassign * (stmt), + arg, param_type); else if (gimple_code (stmt) == GIMPLE_PHI) compute_complex_ancestor_jump_func (fbi, info, jfunc, call, @@ -2188,17 +2189,17 @@ ipa_analyze_indirect_call_uses (struct func_body_info *fbi, gcall *call, int index; gimple def = SSA_NAME_DEF_STMT (target); - if (gimple_assign_single_p (def) - ipa_load_from_parm_agg_1 (fbi, info-descriptors, def, - gimple_assign_rhs1 (def), index, offset, - NULL, by_ref)) -{ - struct cgraph_edge *cs = ipa_note_param_call (fbi-node, index, call); - cs-indirect_info-offset = offset; - cs-indirect_info-agg_contents = 1; - cs-indirect_info-by_ref = by_ref; - return; -} + if (gassign *def_assign = gimple_assign_single_p (def)) +if (ipa_load_from_parm_agg_1 (fbi, info-descriptors, def_assign, + gimple_assign_rhs1 (def_assign), index, + offset, NULL, by_ref)) + { + struct cgraph_edge *cs = ipa_note_param_call (fbi-node, index, call); + cs-indirect_info-offset = offset; +
[gimple-classes, committed 42/44] predict.c: Use gassign
gcc/ChangeLog.gimple-classes: * predict.c (expr_expected_value_1): Replace is_gimple_assign with a dyn_cast, introducing local def_assign and using it in place of def for typesafety. --- gcc/ChangeLog.gimple-classes | 6 ++ gcc/predict.c| 13 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 1ff615f..9f85260 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,11 @@ 2014-11-05 David Malcolm dmalc...@redhat.com + * predict.c (expr_expected_value_1): Replace is_gimple_assign with + a dyn_cast, introducing local def_assign and using it in place + of def for typesafety. + +2014-11-05 David Malcolm dmalc...@redhat.com + * omp-low.c (expand_omp_taskreg): Strengthen locals parcopy_stmt and stmt from gimple to gassign *, replacing a check against GIMPLE_ASSIGN with a dyn_cast. diff --git a/gcc/predict.c b/gcc/predict.c index ed8f352..ca6c7e0 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -1805,15 +1805,16 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code, } return val; } - if (is_gimple_assign (def)) + if (gassign *def_assign = dyn_cast gassign * (def)) { - if (gimple_assign_lhs (def) != op0) + if (gimple_assign_lhs (def_assign) != op0) return NULL; - return expr_expected_value_1 (TREE_TYPE (gimple_assign_lhs (def)), - gimple_assign_rhs1 (def), - gimple_assign_rhs_code (def), - gimple_assign_rhs2 (def), + return expr_expected_value_1 (TREE_TYPE ( + gimple_assign_lhs (def_assign)), + gimple_assign_rhs1 (def_assign), + gimple_assign_rhs_code (def_assign), + gimple_assign_rhs2 (def_assign), visited, predictor); } -- 1.7.11.7
[gimple-classes, committed 37/44] ipa-split.c: Use gassign
gcc/ChangeLog.gimple-classes: * ipa-split.c (find_return_bb): Eliminate check for GIMPLE_ASSIGN since this is covered by gimple_assign_single_p, using the latter to introduce local gassign * assign_stmt, using it in place of stmt for typesafety. (find_retval): Add a checked cast. (split_function): Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing local assign_stmt and using it in place of gsi_stmt (bsi) for typesafety. --- gcc/ChangeLog.gimple-classes | 11 +++ gcc/ipa-split.c | 28 +++- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index e4d85b2..08f045d 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,3 +1,14 @@ +2014-11-05 David Malcolm dmalc...@redhat.com + + * ipa-split.c (find_return_bb): Eliminate check for GIMPLE_ASSIGN + since this is covered by gimple_assign_single_p, using the latter + to introduce local gassign * assign_stmt, using it in place + of stmt for typesafety. + (find_retval): Add a checked cast. + (split_function): Replace check for GIMPLE_ASSIGN with a dyn_cast, + introducing local assign_stmt and using it in place of + gsi_stmt (bsi) for typesafety. + 2014-11-04 David Malcolm dmalc...@redhat.com * cfgexpand.c (add_scope_conflicts_1): Add checked cast. diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index ed5c1a7..4801d7f 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -704,6 +704,7 @@ find_return_bb (void) gimple_stmt_iterator bsi; bool found_return = false; tree retval = NULL_TREE; + gassign *assign_stmt; if (!single_pred_p (EXIT_BLOCK_PTR_FOR_FN (cfun))) return return_bb; @@ -716,13 +717,13 @@ find_return_bb (void) || is_gimple_debug (stmt) || gimple_clobber_p (stmt)) ; - else if (gimple_code (stmt) == GIMPLE_ASSIGN - found_return - gimple_assign_single_p (stmt) - (auto_var_in_fn_p (gimple_assign_rhs1 (stmt), + else if (found_return + (assign_stmt = gimple_assign_single_p (stmt)) + (auto_var_in_fn_p (gimple_assign_rhs1 (assign_stmt), current_function_decl) - || is_gimple_min_invariant (gimple_assign_rhs1 (stmt))) - retval == gimple_assign_lhs (stmt)) + || is_gimple_min_invariant ( + gimple_assign_rhs1 (assign_stmt))) + retval == gimple_assign_lhs (assign_stmt)) ; else if (greturn *return_stmt = dyn_cast greturn * (stmt)) { @@ -749,7 +750,7 @@ find_retval (basic_block return_bb) return gimple_return_retval (return_stmt); else if (gimple_code (gsi_stmt (bsi)) == GIMPLE_ASSIGN !gimple_clobber_p (gsi_stmt (bsi))) - return gimple_assign_rhs1 (gsi_stmt (bsi)); + return gimple_assign_rhs1 (as_a gassign * (gsi_stmt (bsi))); return NULL; } @@ -1471,12 +1472,13 @@ split_function (struct split_point *split_point) gimple_return_set_retval (return_stmt, retval); break; } - else if (gimple_code (gsi_stmt (bsi)) == GIMPLE_ASSIGN - !gimple_clobber_p (gsi_stmt (bsi))) - { - gimple_assign_set_rhs1 (gsi_stmt (bsi), retval); - break; - } + else if (gassign *assign_stmt = + dyn_cast gassign * (gsi_stmt (bsi))) + if (!gimple_clobber_p (assign_stmt)) + { + gimple_assign_set_rhs1 (assign_stmt, retval); + break; + } update_stmt (gsi_stmt (bsi)); } } -- 1.7.11.7
[gimple-classes, committed 32/44] Fix issues with gimple_assign_single_p and gimple_assign_load_p
gcc/ChangeLog.gimple-classes: * asan.c (get_mem_ref_of_assignment): Weaken param assignment from const gassign * to gassign *. * gimple.h (gimple_assign_single_p): Eliminate const_gimple variant, since this could call itself, leading to an infinite recursion. (gimple_assign_load_p): Likewise. --- gcc/ChangeLog.gimple-classes | 8 gcc/asan.c | 2 +- gcc/gimple.h | 28 ++-- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index bfa2a15..776073d 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,3 +1,11 @@ +2014-11-04 David Malcolm dmalc...@redhat.com + + * asan.c (get_mem_ref_of_assignment): Weaken param assignment + from const gassign * to gassign *. + * gimple.h (gimple_assign_single_p): Eliminate const_gimple variant, + since this could call itself, leading to an infinite recursion. + (gimple_assign_load_p): Likewise. + 2014-11-03 David Malcolm dmalc...@redhat.com * ipa-polymorphic-call.c (walk_ssa_copies): Add checked cast. diff --git a/gcc/asan.c b/gcc/asan.c index 1f65fe6..9b25f56 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -465,7 +465,7 @@ has_mem_ref_been_instrumented (const asan_mem_ref *ref, tree len) otherwise. */ static bool -get_mem_ref_of_assignment (const gassign *assignment, +get_mem_ref_of_assignment (gassign *assignment, asan_mem_ref *ref, bool *ref_is_store) { diff --git a/gcc/gimple.h b/gcc/gimple.h index 50e1555..b4782e8 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -2487,21 +2487,13 @@ gimple_assign_rhs_class (const_gimple gs) return get_gimple_rhs_class (gimple_assign_rhs_code (gs)); } -/* Return true if GS is an assignment with a singleton RHS, i.e., - there is no operator associated with the assignment itself. - Unlike gimple_assign_copy_p, this predicate returns true for +/* Return GS (as a gassign *) if GS is an assignment with a singleton + RHS, i.e., there is no operator associated with the assignment itself, + Otherwise, return NULL. + Unlike gimple_assign_copy_p, this predicate returns non-NULL for any RHS operand, including those that perform an operation and do not have the semantics of a copy, such as COND_EXPR. */ -static inline bool -gimple_assign_single_p (const_gimple gs) -{ - return gimple_assign_single_p (const_cast gimple (gs)); -} - -/* As above, but non-const, and return GS as a gassign * if - the predicate holds. */ - static inline gassign * gimple_assign_single_p (gimple gs) { @@ -2521,16 +2513,8 @@ gimple_store_p (const_gimple gs) return lhs !is_gimple_reg (lhs); } -/* Return true if GS is an assignment that loads from its rhs1. */ - -static inline bool -gimple_assign_load_p (const_gimple gs) -{ - return gimple_assign_load_p (const_cast gimple (gs)); -} - -/* As above, but non-const, and return GS as a gassign * if - the predicate holds. */ +/* Return GS (as a gassign *) if GS is an assignment that loads from its rhs1, + or NULL otherwise. */ static inline gassign * gimple_assign_load_p (gimple gs) -- 1.7.11.7
[gimple-classes, committed 38/44] ipa-inline-analysis.c: Use gassign
gcc/ChangeLog.gimple-classes: * ipa-inline-analysis.c (unmodified_parm): Capture result of gimple_assign_single_p as a new local gassign * def_assign and use in place of SSA_NAME_DEF_STMT (op) for typesafety. (unmodified_parm_or_parm_agg_item): Likewise. (eliminated_by_inlining_prob): Introduce local assign_stmt, using it within case GIMPLE_ASSIGN in place of stmt for typesafety. (will_be_nonconstant_predicate): Replace local bool is_load with new local gassign * load_stmt, using it in place of stmt for typesafety. Replace check against GIMPLE_ASSIGN with a dyn_cast, introducing new local assign_stmt, using it in place of stmt for typesafety. (find_foldable_builtin_expect): Replace is_gimple_assign with a dyn_cast, strengthening local stmt_tmp from gimple to gassign *. (estimate_function_body_sizes): Add a checked cast. --- gcc/ChangeLog.gimple-classes | 18 ++ gcc/ipa-inline-analysis.c| 56 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 08f045d..f428267 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,23 @@ 2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-inline-analysis.c (unmodified_parm): Capture result of + gimple_assign_single_p as a new local gassign * def_assign and + use in place of SSA_NAME_DEF_STMT (op) for typesafety. + (unmodified_parm_or_parm_agg_item): Likewise. + (eliminated_by_inlining_prob): Introduce local assign_stmt, + using it within case GIMPLE_ASSIGN in place of stmt for + typesafety. + (will_be_nonconstant_predicate): Replace local bool is_load with + new local gassign * load_stmt, using it in place of stmt for + typesafety. Replace check against GIMPLE_ASSIGN with a dyn_cast, + introducing new local assign_stmt, using it in place of stmt + for typesafety. + (find_foldable_builtin_expect): Replace is_gimple_assign with a + dyn_cast, strengthening local stmt_tmp from gimple to gassign *. + (estimate_function_body_sizes): Add a checked cast. + +2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-split.c (find_return_bb): Eliminate check for GIMPLE_ASSIGN since this is covered by gimple_assign_single_p, using the latter to introduce local gassign * assign_stmt, using it in place diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index aa8a596..c976e1f 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -1534,10 +1534,10 @@ unmodified_parm (gimple stmt, tree op) return res; if (TREE_CODE (op) == SSA_NAME - !SSA_NAME_IS_DEFAULT_DEF (op) - gimple_assign_single_p (SSA_NAME_DEF_STMT (op))) -return unmodified_parm (SSA_NAME_DEF_STMT (op), - gimple_assign_rhs1 (SSA_NAME_DEF_STMT (op))); + !SSA_NAME_IS_DEFAULT_DEF (op)) +if (gassign *def_assign = gimple_assign_single_p (SSA_NAME_DEF_STMT (op))) + return unmodified_parm (def_assign, + gimple_assign_rhs1 (def_assign)); return NULL_TREE; } @@ -1568,11 +1568,13 @@ unmodified_parm_or_parm_agg_item (struct ipa_node_params *info, if (TREE_CODE (op) == SSA_NAME) { - if (SSA_NAME_IS_DEFAULT_DEF (op) - || !gimple_assign_single_p (SSA_NAME_DEF_STMT (op))) + if (SSA_NAME_IS_DEFAULT_DEF (op)) + return false; + gassign *def_assign = gimple_assign_single_p (SSA_NAME_DEF_STMT (op)); + if (!def_assign) return false; - stmt = SSA_NAME_DEF_STMT (op); - op = gimple_assign_rhs1 (stmt); + stmt = def_assign; + op = gimple_assign_rhs1 (def_assign); if (!REFERENCE_CLASS_P (op)) return unmodified_parm_or_parm_agg_item (info, stmt, op, index_p, aggpos); @@ -1595,6 +1597,7 @@ eliminated_by_inlining_prob (gimple stmt) { enum gimple_code code = gimple_code (stmt); enum tree_code rhs_code; + gassign *assign_stmt; if (!optimize) return 0; @@ -1606,8 +1609,9 @@ eliminated_by_inlining_prob (gimple stmt) case GIMPLE_ASSIGN: if (gimple_num_ops (stmt) != 2) return 0; + assign_stmt = as_a gassign * (stmt); - rhs_code = gimple_assign_rhs_code (stmt); + rhs_code = gimple_assign_rhs_code (assign_stmt); /* Casts of parameters, loads from parameters passed by reference and stores to return value or parameters are often free after @@ -1617,10 +1621,10 @@ eliminated_by_inlining_prob (gimple stmt) || rhs_code == NOP_EXPR || rhs_code == VIEW_CONVERT_EXPR || rhs_code == ADDR_EXPR - || gimple_assign_rhs_class (stmt) == GIMPLE_SINGLE_RHS) + || gimple_assign_rhs_class
[gimple-classes, committed 41/44] omp-low.c: Use gassign
gcc/ChangeLog.gimple-classes: * omp-low.c (expand_omp_taskreg): Strengthen locals parcopy_stmt and stmt from gimple to gassign *, replacing a check against GIMPLE_ASSIGN with a dyn_cast. (expand_omp_atomic_fetch_op): Likewise for local stmt. (expand_omp_target): Split local stmt out, strengthening in one place from gimple to gassign *. Strengthen local tgtcopy_stmt from gimple to gassign *. Replace a check against GIMPLE_ASSIGN with a dyn_cast. (ipa_simd_modify_stmt_ops): Introduce local assign_stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 13 + gcc/omp-low.c| 35 ++- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 5f5d7c4..1ff615f 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,18 @@ 2014-11-05 David Malcolm dmalc...@redhat.com + * omp-low.c (expand_omp_taskreg): Strengthen locals parcopy_stmt + and stmt from gimple to gassign *, replacing a check against + GIMPLE_ASSIGN with a dyn_cast. + (expand_omp_atomic_fetch_op): Likewise for local stmt. + (expand_omp_target): Split local stmt out, strengthening in one + place from gimple to gassign *. Strengthen local tgtcopy_stmt + from gimple to gassign *. Replace a check against GIMPLE_ASSIGN + with a dyn_cast. + (ipa_simd_modify_stmt_ops): Introduce local assign_stmt for + typesafety. + +2014-11-05 David Malcolm dmalc...@redhat.com + * ipa-icf-gimple.c (func_checker::compare_bb): Add checked casts. (func_checker::compare_gimple_assign): Strengthen params from gimple to const gassign *. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index b411e64..a20c0c4 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -5000,15 +5000,15 @@ expand_omp_taskreg (struct omp_region *region) { basic_block entry_succ_bb = single_succ (entry_bb); tree arg, narg; - gimple parcopy_stmt = NULL; + gassign *parcopy_stmt = NULL; for (gsi = gsi_start_bb (entry_succ_bb); ; gsi_next (gsi)) { - gimple stmt; + gassign *stmt; gcc_assert (!gsi_end_p (gsi)); - stmt = gsi_stmt (gsi); - if (gimple_code (stmt) != GIMPLE_ASSIGN) + stmt = dyn_cast gassign * (gsi_stmt (gsi)); + if (!stmt) continue; if (gimple_num_ops (stmt) == 2) @@ -7871,7 +7871,7 @@ expand_omp_atomic_fetch_op (basic_block load_bb, tree lhs, rhs; basic_block store_bb = single_succ (load_bb); gimple_stmt_iterator gsi; - gimple stmt; + gassign *stmt; location_t loc; enum tree_code code; bool need_old, need_new; @@ -7893,10 +7893,10 @@ expand_omp_atomic_fetch_op (basic_block load_bb, */ gsi = gsi_after_labels (store_bb); - stmt = gsi_stmt (gsi); - loc = gimple_location (stmt); - if (!is_gimple_assign (stmt)) + stmt = dyn_cast gassign * (gsi_stmt (gsi)); + if (!stmt) return false; + loc = gimple_location (stmt); gsi_next (gsi); if (gimple_code (gsi_stmt (gsi)) != GIMPLE_OMP_ATOMIC_STORE) return false; @@ -8323,7 +8323,6 @@ expand_omp_target (struct omp_region *region) tree child_fn = NULL_TREE, block, t; gimple_stmt_iterator gsi; gomp_target *entry_stmt; - gimple stmt; edge e; entry_stmt = as_a gomp_target * (last_stmt (region-entry)); @@ -8360,15 +8359,15 @@ expand_omp_target (struct omp_region *region) basic_block entry_succ_bb = single_succ (entry_bb); gimple_stmt_iterator gsi; tree arg; - gimple tgtcopy_stmt = NULL; + gassign *tgtcopy_stmt = NULL; tree sender = TREE_VEC_ELT (gimple_omp_target_data_arg (entry_stmt), 0); for (gsi = gsi_start_bb (entry_succ_bb); ; gsi_next (gsi)) { gcc_assert (!gsi_end_p (gsi)); - stmt = gsi_stmt (gsi); - if (gimple_code (stmt) != GIMPLE_ASSIGN) + gassign *stmt = dyn_cast gassign * (gsi_stmt (gsi)); + if (!stmt) continue; if (gimple_num_ops (stmt) == 2) @@ -8417,7 +8416,7 @@ expand_omp_target (struct omp_region *region) /* Split ENTRY_BB at GIMPLE_OMP_TARGET, so that it can be moved to the child function. */ gsi = gsi_last_bb (entry_bb); - stmt = gsi_stmt (gsi); + gimple stmt = gsi_stmt (gsi); gcc_assert (stmt gimple_code (stmt) == GIMPLE_OMP_TARGET (gimple_omp_target_kind (as_a gomp_target * (stmt)) == GF_OMP_TARGET_KIND_REGION)); @@ -8553,7 +8552,7 @@ expand_omp_target (struct omp_region *region) set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb); set_immediate_dominator (CDI_DOMINATORS, else_bb, cond_bb);
[gimple-classes, committed 34/44] build_assign and build_type_cast take const gassign *
gcc/ChangeLog.gimple-classes: * asan.c (asan_expand_check_ifn): Strengthen local shadow_test from gimple to gassign *. Introduce gassign * locals add_7, cast, t_ge_shadow, and_expr, using them in place of gimple_seq_last_stmt (seq) for typesafety. * gimple-builder.c (build_assign): Strengthen param g from gimple to const gassign * for all overloads. (build_type_cast): Likewise for param op. * gimple-builder.h (build_assign): Strengthen param from gimple to const gassign * for all overloads. (build_type_cast): Strengthen param 2 from gimple to const gassign *. --- gcc/ChangeLog.gimple-classes | 14 ++ gcc/asan.c | 44 gcc/gimple-builder.c | 11 ++- gcc/gimple-builder.h | 14 +- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index d207213..631e0df 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,19 @@ 2014-11-04 David Malcolm dmalc...@redhat.com + * asan.c (asan_expand_check_ifn): Strengthen local shadow_test + from gimple to gassign *. Introduce gassign * locals add_7, + cast, t_ge_shadow, and_expr, using them in place of + gimple_seq_last_stmt (seq) for typesafety. + * gimple-builder.c (build_assign): Strengthen param g from + gimple to const gassign * for all overloads. + (build_type_cast): Likewise for param op. + * gimple-builder.h (build_assign): Strengthen param from gimple to + const gassign * for all overloads. + (build_type_cast): Strengthen param 2 from gimple to + const gassign *. + +2014-11-04 David Malcolm dmalc...@redhat.com + * gimple.h (gimple_expr_type): Split out if clause handling GIMPLE_ASSIGN and GIMPLE_CALL with an inner if GIMPLE_CALL into a pair of if clauses, first for GIMPLE_CALL, then for diff --git a/gcc/asan.c b/gcc/asan.c index 9b25f56..6808c30 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2633,7 +2633,7 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls) ((base_addr 7) + (real_size_in_bytes - 1)) = shadow). */ tree shadow = build_shadow_mem_access (gsi, loc, base_addr, shadow_ptr_type); - gimple shadow_test = build_assign (NE_EXPR, shadow, 0); + gassign *shadow_test = build_assign (NE_EXPR, shadow, 0); gimple_seq seq = NULL; gimple_seq_add_stmt (seq, shadow_test); /* Aligned (= 8 bytes) can test just @@ -2641,23 +2641,24 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls) to be 0. */ if (align 8) { - gimple_seq_add_stmt (seq, build_assign (BIT_AND_EXPR, - base_addr, 7)); - gimple_seq_add_stmt (seq, - build_type_cast (shadow_type, - gimple_seq_last (seq))); + gassign *and_7 = build_assign (BIT_AND_EXPR, +base_addr, 7); + gimple_seq_add_stmt (seq, and_7); + gassign *cast = build_type_cast (shadow_type, and_7); + gimple_seq_add_stmt (seq, cast); if (real_size_in_bytes 1) gimple_seq_add_stmt (seq, build_assign (PLUS_EXPR, - gimple_seq_last (seq), + cast, real_size_in_bytes - 1)); t = gimple_assign_lhs (gimple_seq_last_stmt (seq)); } else t = build_int_cst (shadow_type, real_size_in_bytes - 1); - gimple_seq_add_stmt (seq, build_assign (GE_EXPR, t, shadow)); + gassign *t_ge_shadow = build_assign (GE_EXPR, t, shadow); + gimple_seq_add_stmt (seq, t_ge_shadow); gimple_seq_add_stmt (seq, build_assign (BIT_AND_EXPR, shadow_test, - gimple_seq_last (seq))); + t_ge_shadow)); t = gimple_assign_lhs (gimple_seq_last (seq)); gimple_seq_set_location (seq, loc); gsi_insert_seq_after (gsi, seq, GSI_CONTINUE_LINKING); @@ -2684,21 +2685,24 @@ asan_expand_check_ifn (gimple_stmt_iterator *iter, bool use_calls) tree shadow = build_shadow_mem_access (gsi, loc, base_end_addr, shadow_ptr_type); - gimple shadow_test = build_assign (NE_EXPR, shadow, 0); + gassign *shadow_test = build_assign (NE_EXPR, shadow, 0); gimple_seq seq = NULL;
[gimple-classes, committed 30/44] gimple-walk.c: Use gassign
gcc/ChangeLog.gimple-classes: * gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN, introduce local gassign * assign_stmt and use it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 6 gcc/gimple-walk.c| 74 +++- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 9b455c3..8e18adc 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,11 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN, + introduce local gassign * assign_stmt and use it in place of + stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-dse.c (dse_optimize_stmt): Add checked cast. Replace is_gimple_assign with dyn_cast, introducing local gassign * assign_stmt, using it in place of stmt for typesafety. diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index 9a800e2..d74e66a 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -195,46 +195,50 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op, switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: - /* Walk the RHS operands. If the LHS is of a non-renamable type or - is a register variable, we may use a COMPONENT_REF on the RHS. */ - if (wi) - { - tree lhs = gimple_assign_lhs (stmt); - wi-val_only - = (is_gimple_reg_type (TREE_TYPE (lhs)) !is_gimple_reg (lhs)) - || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS; - } + { + gassign *assign_stmt = as_a gassign * (stmt); - for (i = 1; i gimple_num_ops (stmt); i++) - { - ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, - pset); - if (ret) - return ret; - } + /* Walk the RHS operands. If the LHS is of a non-renamable type or + is a register variable, we may use a COMPONENT_REF on the RHS. */ + if (wi) + { + tree lhs = gimple_assign_lhs (assign_stmt); + wi-val_only + = (is_gimple_reg_type (TREE_TYPE (lhs)) !is_gimple_reg (lhs)) + || gimple_assign_rhs_class (assign_stmt) != GIMPLE_SINGLE_RHS; + } - /* Walk the LHS. If the RHS is appropriate for a memory, we -may use a COMPONENT_REF on the LHS. */ - if (wi) - { - /* If the RHS is of a non-renamable type or is a register variable, -we may use a COMPONENT_REF on the LHS. */ - tree rhs1 = gimple_assign_rhs1 (stmt); - wi-val_only - = (is_gimple_reg_type (TREE_TYPE (rhs1)) !is_gimple_reg (rhs1)) - || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS; - wi-is_lhs = true; + for (i = 1; i gimple_num_ops (assign_stmt); i++) + { + ret = walk_tree (gimple_op_ptr (assign_stmt, i), callback_op, wi, +pset); + if (ret) + return ret; + } + + /* Walk the LHS. If the RHS is appropriate for a memory, we + may use a COMPONENT_REF on the LHS. */ + if (wi) + { + /* If the RHS is of a non-renamable type or is a register variable, + we may use a COMPONENT_REF on the LHS. */ + tree rhs1 = gimple_assign_rhs1 (assign_stmt); + wi-val_only + = (is_gimple_reg_type (TREE_TYPE (rhs1)) !is_gimple_reg (rhs1)) + || gimple_assign_rhs_class (assign_stmt) != GIMPLE_SINGLE_RHS; + wi-is_lhs = true; } - ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset); - if (ret) - return ret; + ret = walk_tree (gimple_op_ptr (assign_stmt, 0), callback_op, wi, pset); + if (ret) + return ret; - if (wi) - { - wi-val_only = true; - wi-is_lhs = false; - } + if (wi) + { + wi-val_only = true; + wi-is_lhs = false; + } + } break; case GIMPLE_CALL: -- 1.7.11.7
[gimple-classes, committed 36/44] cfgexpand.c: Use gassign *
gcc/ChangeLog.gimple-classes: * cfgexpand.c (add_scope_conflicts_1): Add checked cast. (expand_gimple_cond): Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing local second_assign, using it in place of assign for typesafety. (expand_call_stmt): Add checked casts. --- gcc/ChangeLog.gimple-classes | 8 gcc/cfgexpand.c | 24 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 17a7c80..e4d85b2 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,13 @@ 2014-11-04 David Malcolm dmalc...@redhat.com + * cfgexpand.c (add_scope_conflicts_1): Add checked cast. + (expand_gimple_cond): Replace check for GIMPLE_ASSIGN with a + dyn_cast, introducing local second_assign, using it in place of + assign for typesafety. + (expand_call_stmt): Add checked casts. + +2014-11-04 David Malcolm dmalc...@redhat.com + * cfgexpand.c (gimple_assign_rhs_to_tree): Strengthen param from gimple to const gassign *. (expand_debug_expr): Add checked cast. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 279202d..2c2ca14 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -449,7 +449,7 @@ add_scope_conflicts_1 (basic_block bb, bitmap work, bool for_conflict) if (gimple_clobber_p (stmt)) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (as_a gassign * (stmt)); size_t *v; /* Nested function lowering might introduce LHSs that are COMPONENT_REFs. */ @@ -2114,14 +2114,14 @@ expand_gimple_cond (basic_block bb, gcond *stmt) bitmap_bit_p (SA.values, SSA_NAME_VERSION (op0))) { gimple second = SSA_NAME_DEF_STMT (op0); - if (gimple_code (second) == GIMPLE_ASSIGN) + if (gassign *second_assign = dyn_cast gassign * (second)) { - enum tree_code code2 = gimple_assign_rhs_code (second); + enum tree_code code2 = gimple_assign_rhs_code (second_assign); if (TREE_CODE_CLASS (code2) == tcc_comparison) { code = code2; - op0 = gimple_assign_rhs1 (second); - op1 = gimple_assign_rhs2 (second); + op0 = gimple_assign_rhs1 (second_assign); + op1 = gimple_assign_rhs2 (second_assign); } /* If jumps are cheap turn some more codes into jumpy sequences. */ @@ -2129,18 +2129,18 @@ expand_gimple_cond (basic_block bb, gcond *stmt) { if ((code2 == BIT_AND_EXPR TYPE_PRECISION (TREE_TYPE (op0)) == 1 - TREE_CODE (gimple_assign_rhs2 (second)) != INTEGER_CST) + TREE_CODE (gimple_assign_rhs2 (second_assign)) != INTEGER_CST) || code2 == TRUTH_AND_EXPR) { code = TRUTH_ANDIF_EXPR; - op0 = gimple_assign_rhs1 (second); - op1 = gimple_assign_rhs2 (second); + op0 = gimple_assign_rhs1 (second_assign); + op1 = gimple_assign_rhs2 (second_assign); } else if (code2 == BIT_IOR_EXPR || code2 == TRUTH_OR_EXPR) { code = TRUTH_ORIF_EXPR; - op0 = gimple_assign_rhs1 (second); - op1 = gimple_assign_rhs2 (second); + op0 = gimple_assign_rhs1 (second_assign); + op1 = gimple_assign_rhs2 (second_assign); } } } @@ -2290,8 +2290,8 @@ expand_call_stmt (gcall *stmt) if (builtin_p TREE_CODE (arg) == SSA_NAME (def = get_gimple_for_ssa_name (arg)) - gimple_assign_rhs_code (def) == ADDR_EXPR) - arg = gimple_assign_rhs1 (def); + gimple_assign_rhs_code (as_a gassign * (def)) == ADDR_EXPR) + arg = gimple_assign_rhs1 (as_a gassign * (def)); CALL_EXPR_ARG (exp, i) = arg; } -- 1.7.11.7
Re: [PATCH][11/n] Merge from match-and-simplify, bit patterns from forwprop
On Thu, 6 Nov 2014, Richard Biener wrote: On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: On Thu, 6 Nov 2014, Marc Glisse wrote: On Thu, 6 Nov 2014, Richard Biener wrote: +/* Try simple folding for X op !X, and X op X with the help + of the truth_valued_p and logical_inverted_value predicates. */ +(match truth_valued_p + @0 + (if (INTEGRAL_TYPE_P (type) TYPE_PRECISION (type) == 1))) +(for op (lt le eq ne ge gt truth_and truth_andif truth_or truth_orif truth_xor) + (match truth_valued_p + (op @0 @1))) +(match truth_valued_p + (truth_not @0)) + +(match (logical_inverted_value @0) + (bit_not truth_valued_p@0)) +(match (logical_inverted_value @0) + (eq @0 integer_zerop) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (ne truth_valued_p@0 integer_onep) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0) +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) + +/* X !X - 0. */ +(simplify + (bit_and:c @0 (logical_inverted_value @0)) + { build_zero_cst (type); }) +/* X | !X and X ^ !X - 1, , if X is truth-valued. */ +(for op (bit_ior bit_xor) + (simplify + (op:c truth_valued_p@0 (logical_inverted_value @0)) + { build_one_cst (type); })) Shouldn't that be build_true_cst (type) so it is -1 for vectors? It seems that it could match: vec a, b; vec c=ab; vec d=~c; vec e=c|d; Probably. Note that I copied this from tree-ssa-forwprop.c. Generally I try to avoid fixing bugs or improving things at this point to make the transition more obvious. But truth_valued_ssa_name starts with: if (!INTEGRAL_TYPE_P (type)) return false; so it does not match vectors. lookup_logical_inverted_value has a similar test. But truth_valued_p doesn't catch vector types, no? IIUC it catches ab, whether this is a vector or not. That said, the +(match (logical_inverted_value @0) + (bit_xor truth_valued_p@0 integer_onep)) would have a similar issue for vectors? Probably, yes. integer_truep maybe, to match a new build_true_cst... I'll happily approve a patch that makes it work correctly for vectors (with a testcase)! I'd like to wait until you are mostly done merging, so I can make just one pass on the .pd file. -- Marc Glisse
[gimple-classes, committed 11/44] gimple-ssa-isolate-paths.c: Use gassign
gcc/ChangeLog.gimple-classes: * gimple-ssa-isolate-paths.c (insert_trap_and_remove_trailing_statements): Replace a call to is_gimple_assign with a dyn_cast, introducing a local assign_stmt, and using it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 7 +++ gcc/gimple-ssa-isolate-paths.c | 12 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 33911d3..dc1315e 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,12 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-ssa-isolate-paths.c + (insert_trap_and_remove_trailing_statements): Replace a call to + is_gimple_assign with a dyn_cast, introducing a local + assign_stmt, and using it in place of stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * gimplify-me.c (gimple_regimplify_operands): Replace a couple of is_gimple_assign calls with dyn_cast, introducing locals assign_stmt and using them in place of stmt for typesafety. diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index ea8ead0..885f392 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -95,15 +95,17 @@ insert_trap_and_remove_trailing_statements (gimple_stmt_iterator *si_p, tree op) then simplify the RHS to enable more DCE. Note that we require the statement to be a GIMPLE_ASSIGN which filters out calls on the RHS. */ gimple stmt = gsi_stmt (*si_p); + gassign *assign_stmt; if (walk_stmt_load_store_ops (stmt, (void *)op, NULL, check_loadstore) - is_gimple_assign (stmt) - INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt + (assign_stmt = dyn_cast gassign * (stmt)) + INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_lhs (assign_stmt { /* We just need to turn the RHS into zero converted to the proper type. */ - tree type = TREE_TYPE (gimple_assign_lhs (stmt)); - gimple_assign_set_rhs_code (stmt, INTEGER_CST); - gimple_assign_set_rhs1 (stmt, fold_convert (type, integer_zero_node)); + tree type = TREE_TYPE (gimple_assign_lhs (assign_stmt)); + gimple_assign_set_rhs_code (assign_stmt, INTEGER_CST); + gimple_assign_set_rhs1 (assign_stmt, + fold_convert (type, integer_zero_node)); update_stmt (stmt); } -- 1.7.11.7
[gimple-classes, committed 23/44] tree-ssa-alias.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-alias.c (stmt_may_clobber_global_p): Within case GIMPLE_ASSIGN, add a checked cast. (ao_ref_init_from_ptr_and_size): Both the gimple_assign_single_p and is_gimple_assign conditionals require a GIMPLE_ASSIGN, so begin with a dyn_cast gassign * and check for NULL, strengthening local stmt from gimple to gassign *. (ref_maybe_used_by_stmt_p): Replace is_gimple_assign with a dyn_cast, introducing local assign_stmt and using it in place of stmt for typesafety. (stmt_may_clobber_ref_p_1): Add a checked cast. --- gcc/ChangeLog.gimple-classes | 13 + gcc/tree-ssa-alias.c | 34 ++ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 6b0d704..9233d8a 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,18 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-alias.c (stmt_may_clobber_global_p): Within + case GIMPLE_ASSIGN, add a checked cast. + (ao_ref_init_from_ptr_and_size): Both the gimple_assign_single_p + and is_gimple_assign conditionals require a GIMPLE_ASSIGN, so + begin with a dyn_cast gassign * and check for NULL, + strengthening local stmt from gimple to gassign *. + (ref_maybe_used_by_stmt_p): Replace is_gimple_assign with a + dyn_cast, introducing local assign_stmt and using it in place of + stmt for typesafety. + (stmt_may_clobber_ref_p_1): Add a checked cast. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-nested.c (convert_local_reference_stmt): Add a checked cast within case GIMPLE_ASSIGN. diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 9b55e0d..f9bf939 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -387,7 +387,7 @@ stmt_may_clobber_global_p (gimple stmt) switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: - lhs = gimple_assign_lhs (stmt); + lhs = gimple_assign_lhs (as_a gassign * (stmt)); return (TREE_CODE (lhs) != SSA_NAME ref_may_alias_global_p (lhs)); case GIMPLE_CALL: @@ -605,17 +605,19 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) ref-ref = NULL_TREE; if (TREE_CODE (ptr) == SSA_NAME) { - gimple stmt = SSA_NAME_DEF_STMT (ptr); - if (gimple_assign_single_p (stmt) - gimple_assign_rhs_code (stmt) == ADDR_EXPR) - ptr = gimple_assign_rhs1 (stmt); - else if (is_gimple_assign (stmt) - gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR - TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) + gassign *stmt = dyn_cast gassign * (SSA_NAME_DEF_STMT (ptr)); + if (stmt) { - ptr = gimple_assign_rhs1 (stmt); - extra_offset = BITS_PER_UNIT -* int_cst_value (gimple_assign_rhs2 (stmt)); + if (gimple_assign_single_p (stmt) + gimple_assign_rhs_code (stmt) == ADDR_EXPR) + ptr = gimple_assign_rhs1 (stmt); + else if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR + TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) + { + ptr = gimple_assign_rhs1 (stmt); + extra_offset = (BITS_PER_UNIT + * int_cst_value (gimple_assign_rhs2 (stmt))); + } } } @@ -1816,18 +1818,18 @@ ref_maybe_used_by_call_p (gcall *call, ao_ref *ref) bool ref_maybe_used_by_stmt_p (gimple stmt, ao_ref *ref) { - if (is_gimple_assign (stmt)) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { tree rhs; /* All memory assign statements are single. */ - if (!gimple_assign_single_p (stmt)) + if (!gimple_assign_single_p (assign_stmt)) return false; - rhs = gimple_assign_rhs1 (stmt); + rhs = gimple_assign_rhs1 (assign_stmt); if (is_gimple_reg (rhs) || is_gimple_min_invariant (rhs) - || gimple_assign_rhs_code (stmt) == CONSTRUCTOR) + || gimple_assign_rhs_code (assign_stmt) == CONSTRUCTOR) return false; return refs_may_alias_p (rhs, ref); @@ -2178,7 +2180,7 @@ stmt_may_clobber_ref_p_1 (gimple stmt, ao_ref *ref) } else if (gimple_assign_single_p (stmt)) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (as_a gassign * (stmt)); if (TREE_CODE (lhs) != SSA_NAME) { ao_ref r; -- 1.7.11.7
[gimple-classes, committed 15/44] graphite-sese-to-poly.c: Use gasssign
gcc/ChangeLog.gimple-classes: * graphite-sese-to-poly.c (rewrite_cross_bb_scalar_deps): Add checked cast. (is_reduction_operation_p): Strengthen param from gimple to gassign *. (follow_ssa_with_commutative_ops): Replace is_gimple_assign with a dyn_cast, introducing local assign_stmt and using it in place of stmt for typesafety. (detect_commutative_reduction_assign): Strengthen param stmt from gimple to gassign *. (detect_commutative_reduction): Add checked cast. (translate_scalar_reduction_to_array_for_stmt): Strengthen param stmt from gimple to gassign *. (close_phi_written_to_memory): Add checked cast. (translate_scalar_reduction_to_array): Likewise. --- gcc/ChangeLog.gimple-classes | 17 + gcc/graphite-sese-to-poly.c | 39 +++ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index baf8c76..5133c46 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,22 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * graphite-sese-to-poly.c (rewrite_cross_bb_scalar_deps): Add + checked cast. + (is_reduction_operation_p): Strengthen param from gimple to + gassign *. + (follow_ssa_with_commutative_ops): Replace is_gimple_assign with + a dyn_cast, introducing local assign_stmt and using it in place + of stmt for typesafety. + (detect_commutative_reduction_assign): Strengthen param stmt from + gimple to gassign *. + (detect_commutative_reduction): Add checked cast. + (translate_scalar_reduction_to_array_for_stmt): Strengthen param + stmt from gimple to gassign *. + (close_phi_written_to_memory): Add checked cast. + (translate_scalar_reduction_to_array): Likewise. + +2014-11-03 David Malcolm dmalc...@redhat.com + * gimple-match-head.c (gimple_simplify): Within case GIMPLE_ASSIGN, introduce local assign_stmt via a checked cast and use it in place of stmt for typesafety. diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index c994fa6..4d4da60 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -2425,7 +2425,7 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi) switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: - def = gimple_assign_lhs (stmt); + def = gimple_assign_lhs (as_a gassign * (stmt)); break; case GIMPLE_CALL: @@ -2614,11 +2614,10 @@ split_reduction_stmt (scop_p scop, gimple stmt) /* Return true when stmt is a reduction operation. */ static inline bool -is_reduction_operation_p (gimple stmt) +is_reduction_operation_p (gassign *stmt) { enum tree_code code; - gcc_assert (is_gimple_assign (stmt)); code = gimple_assign_rhs_code (stmt); return flag_associative_math @@ -2663,19 +2662,23 @@ follow_ssa_with_commutative_ops (tree arg, tree lhs) return NULL; } - if (!is_gimple_assign (stmt)) + gassign *assign_stmt = dyn_cast gassign * (stmt); + if (!assign_stmt) return NULL; - if (gimple_num_ops (stmt) == 2) -return follow_ssa_with_commutative_ops (gimple_assign_rhs1 (stmt), lhs); + if (gimple_num_ops (assign_stmt) == 2) +return follow_ssa_with_commutative_ops (gimple_assign_rhs1 (assign_stmt), + lhs); - if (is_reduction_operation_p (stmt)) + if (is_reduction_operation_p (assign_stmt)) { gphi *res = - follow_ssa_with_commutative_ops (gimple_assign_rhs1 (stmt), lhs); + follow_ssa_with_commutative_ops (gimple_assign_rhs1 (assign_stmt), +lhs); return res ? res : - follow_ssa_with_commutative_ops (gimple_assign_rhs2 (stmt), lhs); + follow_ssa_with_commutative_ops (gimple_assign_rhs2 (assign_stmt), +lhs); } return NULL; @@ -2703,7 +2706,7 @@ detect_commutative_reduction_arg (tree lhs, gimple stmt, tree arg, STMT. Return the phi node of the reduction cycle, or NULL. */ static gphi * -detect_commutative_reduction_assign (gimple stmt, vecgimple *in, +detect_commutative_reduction_assign (gassign *stmt, vecgimple *in, vecgimple *out) { tree lhs = gimple_assign_lhs (stmt); @@ -2853,7 +2856,8 @@ detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in, } if (gimple_code (stmt) == GIMPLE_ASSIGN) -return detect_commutative_reduction_assign (stmt, in, out); +return detect_commutative_reduction_assign (as_a gassign * (stmt), + in, out); return NULL; } @@ -2863,7 +2867,7 @@ detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in, static void
[gimple-classes, committed 27/44] tree-ssa-dce.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Within case GIMPLE_ASSIGN, introduce local assign_stmt and use in place of stmt for typesafety. (mark_all_reaching_defs_necessary_1): Add a checked cast. (propagate_necessity): Likewise. (remove_dead_stmt): Introduce local gassign * assign_stmt from result of gimple_assign_single_p and use it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 11 +++ gcc/tree-ssa-dce.c | 22 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 19a8295..8230179 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,16 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Within + case GIMPLE_ASSIGN, introduce local assign_stmt and use in place + of stmt for typesafety. + (mark_all_reaching_defs_necessary_1): Add a checked cast. + (propagate_necessity): Likewise. + (remove_dead_stmt): Introduce local gassign * assign_stmt from + result of gimple_assign_single_p and use it in place of stmt for + typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-copy.c (stmt_may_generate_copy): Replace check against GIMPLE_ASSIGN with a dyn_cast, introducing local gassign * assign_stmt, using it in place of stmt for typesafety. diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 20a4e40..bf2cae6 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -289,9 +289,12 @@ mark_stmt_if_obviously_necessary (gimple stmt, bool aggressive) break; case GIMPLE_ASSIGN: - if (TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME - TREE_CLOBBER_P (gimple_assign_rhs1 (stmt))) - return; + { + gassign *assign_stmt = as_a gassign * (stmt); + if (TREE_CODE (gimple_assign_lhs (assign_stmt)) == SSA_NAME +TREE_CLOBBER_P (gimple_assign_rhs1 (assign_stmt))) + return; + } break; default: @@ -570,7 +573,7 @@ mark_all_reaching_defs_necessary_1 (ao_ref *ref ATTRIBUTE_UNUSED, if (!chain_ovfl gimple_assign_single_p (def_stmt)) { - tree lhs = gimple_assign_lhs (def_stmt); + tree lhs = gimple_assign_lhs (as_a gassign * (def_stmt)); if (!ref_may_be_aliased (lhs)) return false; } @@ -868,7 +871,7 @@ propagate_necessity (bool aggressive) { tree rhs; /* If this is a load mark things necessary. */ - rhs = gimple_assign_rhs1 (stmt); + rhs = gimple_assign_rhs1 (as_a gassign * (stmt)); if (TREE_CODE (rhs) != SSA_NAME !is_gimple_min_invariant (rhs) TREE_CODE (rhs) != CONSTRUCTOR) @@ -1125,18 +1128,19 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb) /* If this is a store into a variable that is being optimized away, add a debug bind stmt if possible. */ + gassign *assign_stmt; if (MAY_HAVE_DEBUG_STMTS - gimple_assign_single_p (stmt) - is_gimple_val (gimple_assign_rhs1 (stmt))) + (assign_stmt = gimple_assign_single_p (stmt)) + is_gimple_val (gimple_assign_rhs1 (assign_stmt))) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (assign_stmt); if ((TREE_CODE (lhs) == VAR_DECL || TREE_CODE (lhs) == PARM_DECL) !DECL_IGNORED_P (lhs) is_gimple_reg_type (TREE_TYPE (lhs)) !is_global_var (lhs) !DECL_HAS_VALUE_EXPR_P (lhs)) { - tree rhs = gimple_assign_rhs1 (stmt); + tree rhs = gimple_assign_rhs1 (assign_stmt); gdebug *note = gimple_build_debug_bind (lhs, unshare_expr (rhs), stmt); gsi_insert_after (i, note, GSI_SAME_STMT); -- 1.7.11.7
[gimple-classes, committed 29/44] tree-ssa-dse.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-ssa-dse.c (dse_optimize_stmt): Add checked cast. Replace is_gimple_assign with dyn_cast, introducing local gassign * assign_stmt, using it in place of stmt for typesafety. --- gcc/ChangeLog.gimple-classes | 6 ++ gcc/tree-ssa-dse.c | 11 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 48942c1..9b455c3 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,11 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-dse.c (dse_optimize_stmt): Add checked cast. Replace + is_gimple_assign with dyn_cast, introducing local gassign * + assign_stmt, using it in place of stmt for typesafety. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-ssa-dom.c (initialize_hash_element): Replace check for GIMPLE_ASSIGN with a dyn_cast, introducing local assign_stmt, using it in place of stmt for typesafety. diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 3434a80..efffa16 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -233,7 +233,8 @@ dse_optimize_stmt (gimple_stmt_iterator *gsi) /* Don't return early on *this_2(D) ={v} {CLOBBER}. */ if (gimple_has_volatile_ops (stmt) (!gimple_clobber_p (stmt) - || TREE_CODE (gimple_assign_lhs (stmt)) != MEM_REF)) + || (TREE_CODE (gimple_assign_lhs (as_a gassign * (stmt))) + != MEM_REF))) return; /* We know we have virtual definitions. We can handle assignments and @@ -287,18 +288,18 @@ dse_optimize_stmt (gimple_stmt_iterator *gsi) } } - if (is_gimple_assign (stmt)) + if (gassign *assign_stmt = dyn_cast gassign * (stmt)) { gimple use_stmt; /* Self-assignments are zombies. */ - if (operand_equal_p (gimple_assign_rhs1 (stmt), - gimple_assign_lhs (stmt), 0)) + if (operand_equal_p (gimple_assign_rhs1 (assign_stmt), + gimple_assign_lhs (assign_stmt), 0)) use_stmt = stmt; else { ao_ref ref; - ao_ref_init (ref, gimple_assign_lhs (stmt)); + ao_ref_init (ref, gimple_assign_lhs (assign_stmt)); if (!dse_possible_dead_store_p (ref, stmt, use_stmt)) return; } -- 1.7.11.7
[gimple-classes, committed 18/44] tree-call-cdce.c: Use gassign
gcc/ChangeLog.gimple-classes: * tree-call-cdce.c (check_pow): Replace check against GIMPLE_ASSIGN with a dyn_cast, strengthening local base_def from gimple to gassign *. (gen_conditions_for_pow_int_base): Add a checked cast. --- gcc/ChangeLog.gimple-classes | 7 +++ gcc/tree-call-cdce.c | 8 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 719ca6b..f7921d6 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,12 @@ 2014-11-03 David Malcolm dmalc...@redhat.com + * tree-call-cdce.c (check_pow): Replace check against + GIMPLE_ASSIGN with a dyn_cast, strengthening local base_def from + gimple to gassign *. + (gen_conditions_for_pow_int_base): Add a checked cast. + +2014-11-03 David Malcolm dmalc...@redhat.com + * tree-affine.c (aff_combination_expand): Replace is_gimple_assign with a dyn_cast, strengthening local def from gimple to gassign *. diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c index 86b3df9..459b6db 100644 --- a/gcc/tree-call-cdce.c +++ b/gcc/tree-call-cdce.c @@ -223,13 +223,13 @@ check_pow (gcall *pow_call) else if (bc == SSA_NAME) { tree base_val0, type; - gimple base_def; + gassign *base_def; int bit_sz; /* Only handles cases where base value is converted from integer values. */ - base_def = SSA_NAME_DEF_STMT (base); - if (gimple_code (base_def) != GIMPLE_ASSIGN) + base_def = dyn_cast gassign * (SSA_NAME_DEF_STMT (base)); + if (!base_def) return false; if (gimple_assign_rhs_code (base_def) != FLOAT_EXPR) @@ -474,7 +474,7 @@ gen_conditions_for_pow_int_base (tree base, tree expn, inp_domain exp_domain; base_def = SSA_NAME_DEF_STMT (base); - base_val0 = gimple_assign_rhs1 (base_def); + base_val0 = gimple_assign_rhs1 (as_a gassign * (base_def)); int_type = TREE_TYPE (base_val0); bit_sz = TYPE_PRECISION (int_type); gcc_assert (bit_sz 0 -- 1.7.11.7
[gimple-classes, committed 33/44] Use gassign within gimple_expr_type
gcc/ChangeLog.gimple-classes: * gimple.h (gimple_expr_type): Split out if clause handling GIMPLE_ASSIGN and GIMPLE_CALL with an inner if GIMPLE_CALL into a pair of if clauses, first for GIMPLE_CALL, then for GIMPLE_ASSIGN. Replace them with dyn_casts, introducing local assign_stmt, using it in place of stmt for typesafety. Eliminate local type in favor of directly returning. --- gcc/ChangeLog.gimple-classes | 9 + gcc/gimple.h | 46 +++- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 776073d..d207213 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,14 @@ 2014-11-04 David Malcolm dmalc...@redhat.com + * gimple.h (gimple_expr_type): Split out if clause handling + GIMPLE_ASSIGN and GIMPLE_CALL with an inner if GIMPLE_CALL + into a pair of if clauses, first for GIMPLE_CALL, then for + GIMPLE_ASSIGN. Replace them with dyn_casts, introducing local + assign_stmt, using it in place of stmt for typesafety. + Eliminate local type in favor of directly returning. + +2014-11-04 David Malcolm dmalc...@redhat.com + * asan.c (get_mem_ref_of_assignment): Weaken param assignment from const gassign * to gassign *. * gimple.h (gimple_assign_single_p): Eliminate const_gimple variant, diff --git a/gcc/gimple.h b/gcc/gimple.h index b4782e8..a42ec11 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -5521,35 +5521,29 @@ gimple_expr_type (const_gimple stmt) { enum gimple_code code = gimple_code (stmt); - if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL) + /* In general we want to pass out a type that can be substituted + for both the RHS and the LHS types if there is a possibly + useless conversion involved. That means returning the + original RHS type as far as we can reconstruct it. */ + if (const gcall *call_stmt = dyn_cast const gcall * (stmt)) { - tree type; - /* In general we want to pass out a type that can be substituted - for both the RHS and the LHS types if there is a possibly -useless conversion involved. That means returning the -original RHS type as far as we can reconstruct it. */ - if (code == GIMPLE_CALL) + if (gimple_call_internal_p (call_stmt) + gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE) + return TREE_TYPE (gimple_call_arg (call_stmt, 3)); + else + return gimple_call_return_type (call_stmt); +} + else if (const gassign *assign_stmt = dyn_cast const gassign * (stmt)) +{ + switch (gimple_assign_rhs_code (assign_stmt)) { - const gcall *call_stmt = as_a const gcall * (stmt); - if (gimple_call_internal_p (call_stmt) - gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE) - type = TREE_TYPE (gimple_call_arg (call_stmt, 3)); - else - type = gimple_call_return_type (call_stmt); + case POINTER_PLUS_EXPR: + return TREE_TYPE (gimple_assign_rhs1 (assign_stmt)); + + default: + /* As fallback use the type of the LHS. */ + return TREE_TYPE (gimple_get_lhs (assign_stmt)); } - else - switch (gimple_assign_rhs_code (stmt)) - { - case POINTER_PLUS_EXPR: - type = TREE_TYPE (gimple_assign_rhs1 (stmt)); - break; - - default: - /* As fallback use the type of the LHS. */ - type = TREE_TYPE (gimple_get_lhs (stmt)); - break; - } - return type; } else if (code == GIMPLE_COND) return boolean_type_node; -- 1.7.11.7