diff options
author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-21 22:27:49 +0000 |
---|---|---|
committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-21 22:27:49 +0000 |
commit | f2fa15105280d37e237bd90468cb3ce3f842df9f (patch) | |
tree | 8803e48d6a16fc156a2200fed524226c44db7828 /gcc/fold-const.c | |
parent | aff3d9b24cc90684693d346bac15f5fbbbc020c2 (diff) | |
download | gcc-f2fa15105280d37e237bd90468cb3ce3f842df9f.tar.gz |
* fold-const.c (fold, case PLUS_EXPR and case MULT_EXPR): Restore
a number of conversions required for type consistency and previously
stripped off by STRIP_NOPS.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65913 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fa64fd2b956..146f40f97ac 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4182,8 +4182,12 @@ extract_muldiv_1 (t, c, code, wide_type) /* Pass the constant down and see if we can make a simplification. If we can, replace this expression with the inner simplification for possible later conversion to our or some other type. */ - if (0 != (t1 = extract_muldiv (op0, convert (TREE_TYPE (op0), c), code, - code == MULT_EXPR ? ctype : NULL_TREE))) + if ((t2 = convert (TREE_TYPE (op0), c)) != 0 + && TREE_CODE (t2) == INTEGER_CST + && ! TREE_CONSTANT_OVERFLOW (t2) + && (0 != (t1 = extract_muldiv (op0, t2, code, + code == MULT_EXPR + ? ctype : NULL_TREE)))) return t1; break; @@ -5478,13 +5482,17 @@ fold (expr) if (TREE_CODE (parg0) == MULT_EXPR && TREE_CODE (parg1) != MULT_EXPR) return fold (build (PLUS_EXPR, type, - fold (build (PLUS_EXPR, type, parg0, marg)), - parg1)); + fold (build (PLUS_EXPR, type, + convert (type, parg0), + convert (type, marg))), + convert (type, parg1))); if (TREE_CODE (parg0) != MULT_EXPR && TREE_CODE (parg1) == MULT_EXPR) return fold (build (PLUS_EXPR, type, - fold (build (PLUS_EXPR, type, parg1, marg)), - parg0)); + fold (build (PLUS_EXPR, type, + convert (type, parg1), + convert (type, marg))), + convert (type, parg0))); } if (TREE_CODE (arg0) == MULT_EXPR && TREE_CODE (arg1) == MULT_EXPR) @@ -5816,7 +5824,8 @@ fold (expr) TREE_OPERAND (arg0, 1))); if (TREE_CODE (arg1) == INTEGER_CST - && 0 != (tem = extract_muldiv (TREE_OPERAND (t, 0), arg1, + && 0 != (tem = extract_muldiv (TREE_OPERAND (t, 0), + convert (type, arg1), code, NULL_TREE))) return convert (type, tem); |