From: Torbjorn Granlund Date: Wed, 15 Jun 1994 02:29:07 +0000 (+0000) Subject: Revert last patch: (fold, case *_DIV_EXPR): Optimize (x / C << y)... X-Git-Tag: misc/cutover-egcs-0~6468 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e627f0b601f1fbc0e28a3dea3c145efc884c4972;p=thirdparty%2Fgcc.git Revert last patch: (fold, case *_DIV_EXPR): Optimize (x / C << y)... From-SVN: r7475 --- diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 90d5c057659b..becfb4a964ab 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3994,53 +3994,6 @@ fold (expr) } } - /* Note that this transformation might sometimes cause division-by-zero - to pass unnoticed. For example when C=2 and y=31. If that is unacceptable, - we could restrict the optimization to the case when log == 0. */ - - if ((code == FLOOR_DIV_EXPR || code == TRUNC_DIV_EXPR) - && TREE_CODE (arg1) == LSHIFT_EXPR) - { - int log; - if (TREE_CODE (TREE_OPERAND (arg1, 0)) == INTEGER_CST - && (log = exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (arg1, 0)))) >= 0 - && TREE_INT_CST_HIGH (TREE_OPERAND (arg1, 0)) == 0) - { - tree cnt; - cnt = log == 0 ? TREE_OPERAND (arg1, 1) - : fold (build (PLUS_EXPR, TREE_TYPE (TREE_OPERAND (arg1, 1)), - TREE_OPERAND (arg1, 1), - build_int_2 (log, 0))); - - if (TREE_UNSIGNED (type) || code == FLOOR_DIV_EXPR) - { - /* (x / (C << y)) where C = 1 << log => x >> (y + log) */ - /* BUG: First TYPE here should always be unsigned to get logical - shift. How do we do that? */ - return fold (build (RSHIFT_EXPR, type, arg0, cnt)); - } - - /* (x / (C << y)) when C = 1 << log => - => (ashiftrt (plus x (and (ashiftrt x 31) - (not (lshift -1 cnt)))) cnt), - where cnt is y + log */ - /* BUG: Several TYPE arguments here might be wrong. */ - return - fold (build (RSHIFT_EXPR, type, - fold (build (PLUS_EXPR, type, - arg0, - fold (build (BIT_AND_EXPR, type, - fold (build (RSHIFT_EXPR, type, - arg0, - build_int_2 (TYPE_PRECISION (type) - 1, 0))), - fold (build1 (BIT_NOT_EXPR, type, - fold (build (LSHIFT_EXPR, type, - build_int_2 (~0, ~0), - cnt)))))))), - cnt)); - } - } - goto binary; case CEIL_MOD_EXPR: