summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-20 21:49:12 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-20 21:49:12 +0000
commitc9c81ef3c667aaa14c498a5449ec6d134b4b66ff (patch)
tree0ac440db6513ee01deb5e5dc6142769d1e5b7b2d /gcc/fold-const.c
parent12cdcb9d74f55c165366ca1b1eeec013a0ce72ef (diff)
parent891196d7325e4c55d92d5ac5cfe7161c4f36c0ce (diff)
downloadgcc-fortran-dev.tar.gz
Merge from trunk (r239915 to r240230)fortran-dev
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/fortran-dev@240290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index bf177b609e5..e040b2a279b 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -837,15 +837,16 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code,
var = negate_expr (var);
}
}
+ else if (TREE_CONSTANT (in))
+ *conp = in;
else if (TREE_CODE (in) == BIT_NOT_EXPR
&& code == PLUS_EXPR)
{
- /* -X - 1 is folded to ~X, undo that here. */
+ /* -X - 1 is folded to ~X, undo that here. Do _not_ do this
+ when IN is constant. */
*minus_litp = build_one_cst (TREE_TYPE (in));
var = negate_expr (TREE_OPERAND (in, 0));
}
- else if (TREE_CONSTANT (in))
- *conp = in;
else
var = in;
@@ -10005,7 +10006,7 @@ fold_binary_loc (location_t loc,
mode which allows further optimizations. */
int pop = wi::popcount (warg1);
if (!(pop >= BITS_PER_UNIT
- && exact_log2 (pop) != -1
+ && pow2p_hwi (pop)
&& wi::mask (pop, false, warg1.get_precision ()) == warg1))
return fold_build2_loc (loc, code, type, op0,
wide_int_to_tree (type, masked));
@@ -14251,7 +14252,7 @@ round_up_loc (location_t loc, tree value, unsigned int divisor)
}
/* If divisor is a power of two, simplify this to bit manipulation. */
- if (divisor == (divisor & -divisor))
+ if (pow2_or_zerop (divisor))
{
if (TREE_CODE (value) == INTEGER_CST)
{
@@ -14314,7 +14315,7 @@ round_down_loc (location_t loc, tree value, int divisor)
}
/* If divisor is a power of two, simplify this to bit manipulation. */
- if (divisor == (divisor & -divisor))
+ if (pow2_or_zerop (divisor))
{
tree t;