aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/expr.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 6027e7f..58f5fe7 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -13159,12 +13159,15 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
than an scc insn even if we have it. */
if ((code == NE || code == EQ)
- && integer_zerop (arg1)
+ && (integer_zerop (arg1)
+ || integer_pow2p (arg1))
&& (TYPE_PRECISION (ops->type) != 1 || TYPE_UNSIGNED (ops->type)))
{
wide_int nz = tree_nonzero_bits (arg0);
- if (wi::popcount (nz) == 1)
+ if (wi::popcount (nz) == 1
+ && (integer_zerop (arg1)
+ || wi::to_wide (arg1) == nz))
{
tree op0;
int bitnum;
@@ -13182,7 +13185,9 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
op0 = arg0;
bitnum = wi::exact_log2 (nz);
}
- enum tree_code tcode = code == NE ? NE_EXPR : EQ_EXPR;
+ enum tree_code tcode = EQ_EXPR;
+ if ((code == NE) ^ !integer_zerop (arg1))
+ tcode = NE_EXPR;
type = lang_hooks.types.type_for_mode (mode, unsignedp);
return expand_single_bit_test (loc, tcode,