diff options
author | Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> | 2015-11-12 05:34:54 +0000 |
---|---|---|
committer | Naveen H.S <naveenh@gcc.gnu.org> | 2015-11-12 05:34:54 +0000 |
commit | 5711ac884b3d7992b44aa848e980cebe5b4b93d0 (patch) | |
tree | 6d95b42299d95761df6ad4dfed0acf92443db35e /gcc/fold-const.c | |
parent | ab68f865629684815e987810a3842ce98b1122c3 (diff) | |
download | gcc-5711ac884b3d7992b44aa848e980cebe5b4b93d0.zip gcc-5711ac884b3d7992b44aa848e980cebe5b4b93d0.tar.gz gcc-5711ac884b3d7992b44aa848e980cebe5b4b93d0.tar.bz2 |
fold-const.c (fold_binary_loc): Move Convert A/B/C to A/(B*C) to match.pd.
2015-11-12 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
* fold-const.c (fold_binary_loc) : Move Convert A/B/C to A/(B*C)
to match.pd.
Move Convert A/(B/C) to (A/B)*C to match.pd.
Move Convert C1/(X*C2) into (C1/C2)/X to match.pd.
Move Optimize (X & (-A)) / A where A is a power of 2, to
X >> log2(A) to match.pd.
* match.pd (rdiv (rdiv:s @0 @1) @2): New simplifier.
(rdiv @0 (rdiv:s @1 @2)): New simplifier.
(div (convert? (bit_and @0 INTEGER_CST@1)) INTEGER_CST@2):
New simplifier.
(rdiv REAL_CST@0 (mult @1 REAL_CST@2)): New simplifier.
From-SVN: r230204
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8dc849c..9114dec 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10195,54 +10195,9 @@ fold_binary_loc (location_t loc, return fold_build2_loc (loc, RDIV_EXPR, type, negate_expr (arg0), TREE_OPERAND (arg1, 0)); - - /* Convert A/B/C to A/(B*C). */ - if (flag_reciprocal_math - && TREE_CODE (arg0) == RDIV_EXPR) - return fold_build2_loc (loc, RDIV_EXPR, type, TREE_OPERAND (arg0, 0), - fold_build2_loc (loc, MULT_EXPR, type, - TREE_OPERAND (arg0, 1), arg1)); - - /* Convert A/(B/C) to (A/B)*C. */ - if (flag_reciprocal_math - && TREE_CODE (arg1) == RDIV_EXPR) - return fold_build2_loc (loc, MULT_EXPR, type, - fold_build2_loc (loc, RDIV_EXPR, type, arg0, - TREE_OPERAND (arg1, 0)), - TREE_OPERAND (arg1, 1)); - - /* Convert C1/(X*C2) into (C1/C2)/X. */ - if (flag_reciprocal_math - && TREE_CODE (arg1) == MULT_EXPR - && TREE_CODE (arg0) == REAL_CST - && TREE_CODE (TREE_OPERAND (arg1, 1)) == REAL_CST) - { - tree tem = const_binop (RDIV_EXPR, arg0, - TREE_OPERAND (arg1, 1)); - if (tem) - return fold_build2_loc (loc, RDIV_EXPR, type, tem, - TREE_OPERAND (arg1, 0)); - } - return NULL_TREE; case TRUNC_DIV_EXPR: - /* Optimize (X & (-A)) / A where A is a power of 2, - to X >> log2(A) */ - if (TREE_CODE (arg0) == BIT_AND_EXPR - && !TYPE_UNSIGNED (type) && TREE_CODE (arg1) == INTEGER_CST - && integer_pow2p (arg1) && tree_int_cst_sgn (arg1) > 0) - { - tree sum = fold_binary_loc (loc, PLUS_EXPR, TREE_TYPE (arg1), - arg1, TREE_OPERAND (arg0, 1)); - if (sum && integer_zerop (sum)) { - tree pow2 = build_int_cst (integer_type_node, - wi::exact_log2 (arg1)); - return fold_build2_loc (loc, RSHIFT_EXPR, type, - TREE_OPERAND (arg0, 0), pow2); - } - } - /* Fall through */ case FLOOR_DIV_EXPR: |