]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expr: catch more `a*bool` while expanding [PR 112935]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sat, 9 Dec 2023 21:43:23 +0000 (13:43 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 11 Dec 2023 15:42:57 +0000 (07:42 -0800)
After r14-1655-g52c92fb3f40050 (and the other commits
which touch zero_one_valued_p), we end up with a with
`bool * a` but where the bool is an SSA name that might not
have non-zero bits set on it (to 0x1) even though it
does the non-zero bits would be 0x1.
The case of coremarks, it is only phiopt4 which adds the new
ssa name and nothing afterwards updates the nonzero bits on it.
This fixes the regression by using gimple_zero_one_valued_p
rather than tree_nonzero_bits to match the cases where the
SSA_NAME didn't have the non-zero bits set.
gimple_zero_one_valued_p handles one level of cast and also
and an `&`.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR middle-end/112935
* expr.cc (expand_expr_real_2): Use
gimple_zero_one_valued_p instead of tree_nonzero_bits
to find boolean defined expressions.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/expr.cc

index 6da51f2aca296450848000ed7dc957fd28ebf55f..4686cacd22fe3c8d4d1c71fec8795dc744a1d439 100644 (file)
@@ -10209,8 +10209,9 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
       /* Expand X*Y as X&-Y when Y must be zero or one.  */
       if (SCALAR_INT_MODE_P (mode))
        {
-         bool bit0_p = tree_nonzero_bits (treeop0) == 1;
-         bool bit1_p = tree_nonzero_bits (treeop1) == 1;
+         bool gimple_zero_one_valued_p (tree, tree (*)(tree));
+         bool bit0_p = gimple_zero_one_valued_p (treeop0, nullptr);
+         bool bit1_p = gimple_zero_one_valued_p (treeop1, nullptr);
 
          /* Expand X*Y as X&Y when both X and Y must be zero or one.  */
          if (bit0_p && bit1_p)