From 0247298c2882ee01793b82644d3d7ea32feace68 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Sat, 29 May 2010 17:14:31 +0000 Subject: Don't use unshare_expr when not necessary. 2010-05-29 Sebastian Pop PR middle-end/44306 * gcc.dg/tree-ssa/pr44306.c: New. * tree-if-conv.c (is_true_predicate): New. (is_predicated): Use is_true_predicate. (add_to_predicate_list): Same. Do not use unshare_expr. (add_to_dst_predicate_list): Same. From-SVN: r160031 --- gcc/ChangeLog | 8 +++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/tree-ssa/pr44306.c | 30 ++++++++++++++++ gcc/tree-if-conv.c | 63 ++++++++++++++++----------------- 4 files changed, 73 insertions(+), 33 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr44306.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a01622a..463eff5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2010-05-29 Sebastian Pop + PR middle-end/44306 + * tree-if-conv.c (is_true_predicate): New. + (is_predicated): Use is_true_predicate. + (add_to_predicate_list): Same. Do not use unshare_expr. + (add_to_dst_predicate_list): Same. + +2010-05-29 Sebastian Pop + * tree-if-conv.c (add_to_dst_predicate_list): Do not use the ->aux field on edges. (predicate_bbs): Same. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1dc4528..6b9c4c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-29 Sebastian Pop + + PR middle-end/44306 + * gcc.dg/tree-ssa/pr44306.c: New. + 2010-05-29 Jan Hubicka * gcc.dg/tree-ssa/ipa-cp-1.c: Update testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr44306.c b/gcc/testsuite/gcc.dg/tree-ssa/pr44306.c new file mode 100644 index 0000000..1ea04ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr44306.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-c -O3 -ftree-vectorize" { target *-*-* } } */ + +extern const int quant_coef8[6][8][8]; +extern const int dequant_coef8[6][8][8]; +int LevelScale8x8Luma_Intra[6][8][8]; +int LevelScale8x8Luma_Inter[6][8][8]; +int InvLevelScale8x8Luma_Intra[6][8][8]; +int InvLevelScale8x8Luma_Inter[6][8][8]; +short UseDefaultScalingMatrix8x8Flag[2]; +void CalculateQuant8Param() +{ + int i, j, k, temp; + int present[2]; + for(k=0; j<8; j++) + for(i=0; i<8; i++) + { + temp = (i<<3)+j; + if((!present[0]) || UseDefaultScalingMatrix8x8Flag[0]) + { + LevelScale8x8Luma_Intra[k][j][i] = (quant_coef8[k][j][i]<<4); + InvLevelScale8x8Luma_Intra[k][j][i] = dequant_coef8[k][j][i]; + } + if((!present[1]) || UseDefaultScalingMatrix8x8Flag[1]) + { + LevelScale8x8Luma_Inter[k][j][i] = (quant_coef8[k][j][i]<<4); + InvLevelScale8x8Luma_Inter[k][j][i] = dequant_coef8[k][j][i]; + } + } +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 45ce388..268c171 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -130,44 +130,54 @@ ifc_temp_var (tree type, tree exp) return stmt; } +/* Return true when COND is a true predicate. */ + +static inline bool +is_true_predicate (tree cond) +{ + return (cond == NULL_TREE + || cond == boolean_true_node + || integer_onep (cond)); +} + +/* Returns true when BB has a predicate that is not trivial: true or + NULL_TREE. */ + +static inline bool +is_predicated (basic_block bb) +{ + return !is_true_predicate ((tree) bb->aux); +} + /* Add condition NEW_COND to the predicate list of basic block BB. */ -static void +static inline void add_to_predicate_list (basic_block bb, tree new_cond) { tree cond = (tree) bb->aux; - if (cond) - cond = fold_build2_loc (EXPR_LOCATION (cond), - TRUTH_OR_EXPR, boolean_type_node, - unshare_expr (cond), new_cond); - else - cond = new_cond; - - bb->aux = cond; + bb->aux = is_true_predicate (cond) ? new_cond : + fold_build2_loc (EXPR_LOCATION (cond), + TRUTH_OR_EXPR, boolean_type_node, + cond, new_cond); } /* Add the condition COND to the previous condition PREV_COND, and add this to the predicate list of the destination of edge E. LOOP is the loop to be if-converted. */ -static tree +static void add_to_dst_predicate_list (struct loop *loop, edge e, tree prev_cond, tree cond) { - tree new_cond = NULL_TREE; - if (!flow_bb_inside_loop_p (loop, e->dest)) - return NULL_TREE; + return; - if (prev_cond == boolean_true_node || !prev_cond) - new_cond = unshare_expr (cond); - else - new_cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, - unshare_expr (prev_cond), cond); + if (!is_true_predicate (prev_cond)) + cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, + prev_cond, cond); - add_to_predicate_list (e->dest, new_cond); - return new_cond; + add_to_predicate_list (e->dest, cond); } /* Return true if one of the successor edges of BB exits LOOP. */ @@ -568,19 +578,6 @@ predicate_bbs (loop_p loop) return true; } -/* Returns true when BB has a predicate that is not trivial: true or - NULL_TREE. */ - -static bool -is_predicated (basic_block bb) -{ - tree cond = (tree) bb->aux; - - return (cond != NULL_TREE - && cond != boolean_true_node - && !integer_onep (cond)); -} - /* Return true when LOOP is if-convertible. LOOP is if-convertible if: - it is innermost, -- cgit v1.1