[v2] match.pd: (A << N) >> N -> A [PR126644]

Message ID 20261011111209.3214394-1-daniel.barboza@oss.qualcomm.com
State New
Headers
Series [v2] match.pd: (A << N) >> N -> A [PR126644] |

Commit Message

Daniel Barboza Oct. 11, 2026, 11:12 a.m. UTC
  This is done during RTL.  Do it earlier in Gimple to potentially allow
more optimizations opportunities.

The same pattern have two distinct handlings depending on whether A is
unsigned or not.  For unsigned types we'll check if there will be any
upper bits being lost during the lshift step, e.g. if A = 0x001.. we can
do the simplication for N=1,2 only.  N = 3 and above would waste original
A bits and the end result wouldn't be the same as A anymore.

For signed types we need to consider that the rshift will preserve the
original sign of its operand, thus if there's a sign change in A during
the lshift we can no longer do the simplfication since the end result is
no longer equal to A.  E.g:

- for signed type A = 0x001.. and N = 2:
  (0x001.. << 2) >> 2 --> 0x1.. >> 2 --> 0x111.., which is not A;

- Likewise, for signed type A = 0x110.. and N = 2:
  (0x110.. << 2) >> 2 --> 0x0.. >> 2 --> 0x000.., also not A.

Bootstrapped and regression tested in x86_64, aarch64 and riscv64.

	PR tree-optimization/126644

gcc/ChangeLog:

	* match.pd(`((A << N) >> N) -> N`): New pattern.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr126644.c: New test.
---

Changes from v1:
- document match.pd changes properly in commit msg;
- remove unneeded INTEGRAL_TYPE_P check;
- handle signed cases by checking if the lshift will
  cause a signal change in the original SSA_NAME.
- v1 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/733787.html

 gcc/match.pd                             | 58 ++++++++++++++++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/pr126644.c | 55 ++++++++++++++++++++++
 2 files changed, 113 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr126644.c
  

Comments

Jeff Law Oct. 22, 2026, 5:37 p.m. UTC | #1
On 10/11/26 5:12 AM, Daniel Barboza wrote:
> This is done during RTL.  Do it earlier in Gimple to potentially allow
> more optimizations opportunities.
>
> The same pattern have two distinct handlings depending on whether A is
> unsigned or not.  For unsigned types we'll check if there will be any
> upper bits being lost during the lshift step, e.g. if A = 0x001.. we can
> do the simplication for N=1,2 only.  N = 3 and above would waste original
> A bits and the end result wouldn't be the same as A anymore.
>
> For signed types we need to consider that the rshift will preserve the
> original sign of its operand, thus if there's a sign change in A during
> the lshift we can no longer do the simplfication since the end result is
> no longer equal to A.  E.g:
>
> - for signed type A = 0x001.. and N = 2:
>    (0x001.. << 2) >> 2 --> 0x1.. >> 2 --> 0x111.., which is not A;
>
> - Likewise, for signed type A = 0x110.. and N = 2:
>    (0x110.. << 2) >> 2 --> 0x0.. >> 2 --> 0x000.., also not A.
>
> Bootstrapped and regression tested in x86_64, aarch64 and riscv64.
>
> 	PR tree-optimization/126644
>
> gcc/ChangeLog:
>
> 	* match.pd(`((A << N) >> N) -> N`): New pattern.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.dg/tree-ssa/pr126644.c: New test.
> ---
>
> Changes from v1:
> - document match.pd changes properly in commit msg;
> - remove unneeded INTEGRAL_TYPE_P check;
> - handle signed cases by checking if the lshift will
>    cause a signal change in the original SSA_NAME.
> - v1 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/733787.html
Thanks.  This looks pretty good.  No issues raised by GCC Sashiko.

Note that you could use the same approach for (A >> N) << N.  For that 
case I don't think you need to worry about signedness issues since any 
sign bit copies from an arithmetic right shift get thrown away by the 
final left shift.  That might be a useful follow-up.

Closely related for the (A << N) >> N case, if you can't apply (say 
because you don't have useful nonzero-bits status on A), you could 
instead transform into a BIT_AND against an adjusted constant since this 
case is just clearing N high bits when A is unsigned.  When A is signed 
what you have is sign extension from an arbitrary bit position, but the 
alternate formulations are no better than shift pairs from gimple's cost 
model standpoint.  That might be another useful followup.


> +    (if (!TYPE_UNSIGNED (type))
> +     (with {
> +	bool no_sign_bit_change = true;
> +	int_range_max vr;
> +
> +	if (gimple_match_range_of_expr (vr, @A)
> +	    && !vr.varying_p ()
> +	    && !vr.undefined_p ()
> +	    && vr.num_pairs () > 0)
> +	  {
> +	    int shift_amount = tree_to_uhwi (@N);
> +	    for (unsigned int i = 0; i < vr.num_pairs (); i++)
> +	      {
> +		wide_int lb = vr.lower_bound (i);
> +		wide_int ub = vr.upper_bound (i);
> +
> +		if (wi::clrsb (lb) < shift_amount
> +		    || wi::clrsb (ub) < shift_amount)
> +		  {
> +		    no_sign_bit_change = false;
> +		    break;
> +		  }
> +	      }
> +	  }
> +	else
> +	  no_sign_bit_change = false;
Is there some reason the tree_nonzero_bits test didn't help here? It 
would seem that if we have reasonable range information, then Ranger 
would also be giving us nonzero bit information and we just need to know 
if bit precision - N - 1 is potentially nonzero, right?

Jeff
  
Daniel Barboza Oct. 26, 2026, 12:35 p.m. UTC | #2
On 10/22/2026 2:37 PM, Jeff Law wrote:
> 
> 
> On 10/11/26 5:12 AM, Daniel Barboza wrote:
>> This is done during RTL.  Do it earlier in Gimple to potentially allow
>> more optimizations opportunities.
>>
>> The same pattern have two distinct handlings depending on whether A is
>> unsigned or not.  For unsigned types we'll check if there will be any
>> upper bits being lost during the lshift step, e.g. if A = 0x001.. we can
>> do the simplication for N=1,2 only.  N = 3 and above would waste original
>> A bits and the end result wouldn't be the same as A anymore.
>>
>> For signed types we need to consider that the rshift will preserve the
>> original sign of its operand, thus if there's a sign change in A during
>> the lshift we can no longer do the simplfication since the end result is
>> no longer equal to A.  E.g:
>>
>> - for signed type A = 0x001.. and N = 2:
>>    (0x001.. << 2) >> 2 --> 0x1.. >> 2 --> 0x111.., which is not A;
>>
>> - Likewise, for signed type A = 0x110.. and N = 2:
>>    (0x110.. << 2) >> 2 --> 0x0.. >> 2 --> 0x000.., also not A.
>>
>> Bootstrapped and regression tested in x86_64, aarch64 and riscv64.
>>
>>     PR tree-optimization/126644
>>
>> gcc/ChangeLog:
>>
>>     * match.pd(`((A << N) >> N) -> N`): New pattern.
>>
>> gcc/testsuite/ChangeLog:
>>
>>     * gcc.dg/tree-ssa/pr126644.c: New test.
>> ---
>>
>> Changes from v1:
>> - document match.pd changes properly in commit msg;
>> - remove unneeded INTEGRAL_TYPE_P check;
>> - handle signed cases by checking if the lshift will
>>    cause a signal change in the original SSA_NAME.
>> - v1 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/733787.html
> Thanks.  This looks pretty good.  No issues raised by GCC Sashiko.
> 
> Note that you could use the same approach for (A >> N) << N.  For that case I don't think you need to worry about signedness issues since any sign bit copies from an arithmetic right shift get thrown away by the final left shift.  That might be a useful follow-up.

Good point.  I'll do a follow-up.

> 
> Closely related for the (A << N) >> N case, if you can't apply (say because you don't have useful nonzero-bits status on A), you could instead transform into a BIT_AND against an adjusted constant since this case is just clearing N high bits when A is unsigned.  When A is signed what you have is sign extension from an arbitrary bit position, but the alternate formulations are no better than shift pairs from gimple's cost model standpoint.  That might be another useful followup.
> 
> 
>> +    (if (!TYPE_UNSIGNED (type))
>> +     (with {
>> +    bool no_sign_bit_change = true;
>> +    int_range_max vr;
>> +
>> +    if (gimple_match_range_of_expr (vr, @A)
>> +        && !vr.varying_p ()
>> +        && !vr.undefined_p ()
>> +        && vr.num_pairs () > 0)
>> +      {
>> +        int shift_amount = tree_to_uhwi (@N);
>> +        for (unsigned int i = 0; i < vr.num_pairs (); i++)
>> +          {
>> +        wide_int lb = vr.lower_bound (i);
>> +        wide_int ub = vr.upper_bound (i);
>> +
>> +        if (wi::clrsb (lb) < shift_amount
>> +            || wi::clrsb (ub) < shift_amount)
>> +          {
>> +            no_sign_bit_change = false;
>> +            break;
>> +          }
>> +          }
>> +      }
>> +    else
>> +      no_sign_bit_change = false;
> Is there some reason the tree_nonzero_bits test didn't help here? It would seem that if we have reasonable range information, then Ranger would also be giving us nonzero bit information and we just need to know if bit precision - N - 1 is potentially nonzero, right?

Good point again.  I didn't even consider using tree_nonzero_bits() for the signed
case.  I got way too focused in the discussions in v1 about using ranger and
checking lower and upper bounds and haven't considered it.  In reality the same
principle applies with tree_nonzero_bits(): we need to make sure that the shift
won't change signs.  I'll see if I can pull it off and send a v3.


Cheers,
Daniel


> 
> Jeff
  
Andrea Pinski Oct. 26, 2026, 9:18 p.m. UTC | #3
On Thu, Oct 22, 2026 at 10:38 AM Jeff Law <jeffrey.law@oss.qualcomm.com> wrote:
>
>
>
> On 10/11/26 5:12 AM, Daniel Barboza wrote:
> > This is done during RTL.  Do it earlier in Gimple to potentially allow
> > more optimizations opportunities.
> >
> > The same pattern have two distinct handlings depending on whether A is
> > unsigned or not.  For unsigned types we'll check if there will be any
> > upper bits being lost during the lshift step, e.g. if A = 0x001.. we can
> > do the simplication for N=1,2 only.  N = 3 and above would waste original
> > A bits and the end result wouldn't be the same as A anymore.
> >
> > For signed types we need to consider that the rshift will preserve the
> > original sign of its operand, thus if there's a sign change in A during
> > the lshift we can no longer do the simplfication since the end result is
> > no longer equal to A.  E.g:
> >
> > - for signed type A = 0x001.. and N = 2:
> >    (0x001.. << 2) >> 2 --> 0x1.. >> 2 --> 0x111.., which is not A;
> >
> > - Likewise, for signed type A = 0x110.. and N = 2:
> >    (0x110.. << 2) >> 2 --> 0x0.. >> 2 --> 0x000.., also not A.
> >
> > Bootstrapped and regression tested in x86_64, aarch64 and riscv64.
> >
> >       PR tree-optimization/126644
> >
> > gcc/ChangeLog:
> >
> >       * match.pd(`((A << N) >> N) -> N`): New pattern.
> >
> > gcc/testsuite/ChangeLog:
> >
> >       * gcc.dg/tree-ssa/pr126644.c: New test.
> > ---
> >
> > Changes from v1:
> > - document match.pd changes properly in commit msg;
> > - remove unneeded INTEGRAL_TYPE_P check;
> > - handle signed cases by checking if the lshift will
> >    cause a signal change in the original SSA_NAME.
> > - v1 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/733787.html
> Thanks.  This looks pretty good.  No issues raised by GCC Sashiko.
>
> Note that you could use the same approach for (A >> N) << N.  For that
> case I don't think you need to worry about signedness issues since any
> sign bit copies from an arithmetic right shift get thrown away by the
> final left shift.  That might be a useful follow-up.
>
> Closely related for the (A << N) >> N case, if you can't apply (say
> because you don't have useful nonzero-bits status on A), you could
> instead transform into a BIT_AND against an adjusted constant since this
> case is just clearing N high bits when A is unsigned.  When A is signed
> what you have is sign extension from an arbitrary bit position, but the
> alternate formulations are no better than shift pairs from gimple's cost
> model standpoint.  That might be another useful followup.

The function naming is part of the problem here which I think is
confusing too; I don't know how to resolve it though.
tree_nonzero_bits returns a mask where the bits are unknown (or always
set).  That is 0b0100 says bit 2 is unknown (or maybe even known to be
set) while bits 0, 1 and 3 are known to be unset.
There is another function which returns a mask for the bits that are
known to be set, `get_known_nonzero_bits`.  This function returns a
mask which where the bits are known to be set.  For an example 0b0110,
bits 2 and 3 are known to be set while bits 0 and 3 are not known to
be set or unset.

Hope this helps.  We most likely rename these functions but the whole
GCC uses nonzero bits this way including on the RTL level.
Plus there being like 2 different APIs to get the nonzero bits from a
tree is another issue which should be resolved; but someone needs to
sit down and figure out which one should be kept.
There is also 2 different ways of handling boolean range
(zero_one_valued) too in match which is another cleanup that needs to
be done too.


Thanks,
Andrea

>
>
> > +    (if (!TYPE_UNSIGNED (type))
> > +     (with {
> > +     bool no_sign_bit_change = true;
> > +     int_range_max vr;
> > +
> > +     if (gimple_match_range_of_expr (vr, @A)
> > +         && !vr.varying_p ()
> > +         && !vr.undefined_p ()
> > +         && vr.num_pairs () > 0)
> > +       {
> > +         int shift_amount = tree_to_uhwi (@N);
> > +         for (unsigned int i = 0; i < vr.num_pairs (); i++)
> > +           {
> > +             wide_int lb = vr.lower_bound (i);
> > +             wide_int ub = vr.upper_bound (i);
> > +
> > +             if (wi::clrsb (lb) < shift_amount
> > +                 || wi::clrsb (ub) < shift_amount)
> > +               {
> > +                 no_sign_bit_change = false;
> > +                 break;
> > +               }
> > +           }
> > +       }
> > +     else
> > +       no_sign_bit_change = false;
> Is there some reason the tree_nonzero_bits test didn't help here? It
> would seem that if we have reasonable range information, then Ranger
> would also be giving us nonzero bit information and we just need to know
> if bit precision - N - 1 is potentially nonzero, right?
>
> Jeff
  
Daniel Barboza Oct. 27, 2026, 8:08 p.m. UTC | #4
On 10/22/2026 2:37 PM, Jeff Law wrote:
> 
> 
> On 10/11/26 5:12 AM, Daniel Barboza wrote:
>> This is done during RTL.  Do it earlier in Gimple to potentially allow
>> more optimizations opportunities.
>>
>> The same pattern have two distinct handlings depending on whether A is
>> unsigned or not.  For unsigned types we'll check if there will be any
>> upper bits being lost during the lshift step, e.g. if A = 0x001.. we can
>> do the simplication for N=1,2 only.  N = 3 and above would waste original
>> A bits and the end result wouldn't be the same as A anymore.
>>
>> For signed types we need to consider that the rshift will preserve the
>> original sign of its operand, thus if there's a sign change in A during
>> the lshift we can no longer do the simplfication since the end result is
>> no longer equal to A.  E.g:
>>
>> - for signed type A = 0x001.. and N = 2:
>>    (0x001.. << 2) >> 2 --> 0x1.. >> 2 --> 0x111.., which is not A;
>>
>> - Likewise, for signed type A = 0x110.. and N = 2:
>>    (0x110.. << 2) >> 2 --> 0x0.. >> 2 --> 0x000.., also not A.
>>
>> Bootstrapped and regression tested in x86_64, aarch64 and riscv64.
>>
>>     PR tree-optimization/126644
>>
>> gcc/ChangeLog:
>>
>>     * match.pd(`((A << N) >> N) -> N`): New pattern.
>>
>> gcc/testsuite/ChangeLog:
>>
>>     * gcc.dg/tree-ssa/pr126644.c: New test.
>> ---
>>
>> Changes from v1:
>> - document match.pd changes properly in commit msg;
>> - remove unneeded INTEGRAL_TYPE_P check;
>> - handle signed cases by checking if the lshift will
>>    cause a signal change in the original SSA_NAME.
>> - v1 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/733787.html
> Thanks.  This looks pretty good.  No issues raised by GCC Sashiko.
> 
> Note that you could use the same approach for (A >> N) << N.  For that case I don't think you need to worry about signedness issues since any sign bit copies from an arithmetic right shift get thrown away by the final left shift.  That might be a useful follow-up.
> 
> Closely related for the (A << N) >> N case, if you can't apply (say because you don't have useful nonzero-bits status on A), you could instead transform into a BIT_AND against an adjusted constant since this case is just clearing N high bits when A is unsigned.  When A is signed what you have is sign extension from an arbitrary bit position, but the alternate formulations are no better than shift pairs from gimple's cost model standpoint.  That might be another useful followup.

Seems like we already have this implemented in match.pd:

/* Optimize (x >> c) << c into x & (-1<<c).  */
(simplify
  (lshift (nop_convert? (rshift @0 INTEGER_CST@1)) @1)
  (if (wi::ltu_p (wi::to_wide (@1), element_precision (type)))
   /* It doesn't matter if the right shift is arithmetic or logical.  */
   (bit_and (view_convert @0) (lshift { build_minus_one_cst (type); } @1))))



It'll turn that into a bit_and and, if the lower 'C' bit are proven to be zero, it'll reduce to just 'X'.


And, as a matter of fact, we also have this:

/* For (x << c) >> c, optimize into x & ((unsigned)-1 >> c) for
    unsigned x OR truncate into the precision(type) - c lowest bits
    of signed x (if they have mode precision or a precision of 1).  */
(simplify
  (rshift (nop_convert? (lshift @0 INTEGER_CST@1)) @@1)
  (if (wi::ltu_p (wi::to_wide (@1), element_precision (type)))
   (if (TYPE_UNSIGNED (type))
    (bit_and (convert @0) (rshift { build_minus_one_cst (type); } @1))
(....)


Note that this simplification is the same I'm trying to add here but it's acting
on 'original', before the new pattern can do anything about it.  And, similar to the
previous, if it's proven that there's no bits being lost, it'll also reduce to "X".

In short, we don't need to handle TYPE_UNSIGNED() in this patch.  I'll send a v3
with signed types only.



> 
> 
>> +    (if (!TYPE_UNSIGNED (type))
>> +     (with {
>> +    bool no_sign_bit_change = true;
>> +    int_range_max vr;
>> +
>> +    if (gimple_match_range_of_expr (vr, @A)
>> +        && !vr.varying_p ()
>> +        && !vr.undefined_p ()
>> +        && vr.num_pairs () > 0)
>> +      {
>> +        int shift_amount = tree_to_uhwi (@N);
>> +        for (unsigned int i = 0; i < vr.num_pairs (); i++)
>> +          {
>> +        wide_int lb = vr.lower_bound (i);
>> +        wide_int ub = vr.upper_bound (i);
>> +
>> +        if (wi::clrsb (lb) < shift_amount
>> +            || wi::clrsb (ub) < shift_amount)
>> +          {
>> +            no_sign_bit_change = false;
>> +            break;
>> +          }
>> +          }
>> +      }
>> +    else
>> +      no_sign_bit_change = false;
> Is there some reason the tree_nonzero_bits test didn't help here? It would seem that if we have reasonable range information, then Ranger would also be giving us nonzero bit information and we just need to know if bit precision - N - 1 is potentially nonzero, right?


As Andrea said we can use a combo with get_nonzero_bits() to check for clear
bits, along with get_known_nonzero_bits() to check for set bits.  It's clearer
than all the jazz I did with lower and upper bounds.  If no bootstrap/regression
problems I'll send a v3 using that.


Thanks,
Daniel

> 
> Jeff
  

Patch

diff --git a/gcc/match.pd b/gcc/match.pd
index 2d1161b860b..62e982cb9c2 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1561,6 +1561,64 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
             { wide_int_to_tree (type,
 				wi::lshift (wone, wi::to_wide (@2))); }))))
 
+#if GIMPLE
+/* PR126644: A << N >> N -> A
+   As long as the upper CST bits of A are known to be zero.  */
+(simplify
+ (rshift (lshift@0 @A INTEGER_CST@N) @N)
+  (if (INTEGRAL_TYPE_P (type)
+       && tree_fits_uhwi_p (@N)
+       && tree_to_uhwi (@N) < TYPE_PRECISION (type)
+       && single_use (@0))
+   (switch
+    /* For unsigned types it's a matter of checking if we'll
+       lose any of the upper N bits during A << N.  */
+    (if (TYPE_UNSIGNED (type))
+     (with {
+	unsigned int prec = TYPE_PRECISION (type);
+	wide_int mask = wi::mask (prec - tree_to_uhwi (@N),
+				  true, prec);
+      }
+      (if ((tree_nonzero_bits (@A) & mask) == 0)
+       @A)))
+
+    /* For signed types we need to preserve the existing sign bit for
+       all possible values A might have.  Otherwise we can have an
+       originally positive A (no sign bit), A << N ends up setting
+       the sign bit (i.e. it's a negative number now) and now
+       (A << N) >> N becomes an arithmetic shift that will preserve
+       the sign bit.  */
+    (if (!TYPE_UNSIGNED (type))
+     (with {
+	bool no_sign_bit_change = true;
+	int_range_max vr;
+
+	if (gimple_match_range_of_expr (vr, @A)
+	    && !vr.varying_p ()
+	    && !vr.undefined_p ()
+	    && vr.num_pairs () > 0)
+	  {
+	    int shift_amount = tree_to_uhwi (@N);
+	    for (unsigned int i = 0; i < vr.num_pairs (); i++)
+	      {
+		wide_int lb = vr.lower_bound (i);
+		wide_int ub = vr.upper_bound (i);
+
+		if (wi::clrsb (lb) < shift_amount
+		    || wi::clrsb (ub) < shift_amount)
+		  {
+		    no_sign_bit_change = false;
+		    break;
+		  }
+	      }
+	  }
+	else
+	  no_sign_bit_change = false;
+      }
+      (if (no_sign_bit_change)
+       @A))))))
+#endif
+
 /* Fold (-x >> C) into -(x > 0) where C = precision(type) - 1.  */
 (for cst (INTEGER_CST VECTOR_CST)
  (simplify
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr126644.c b/gcc/testsuite/gcc.dg/tree-ssa/pr126644.c
new file mode 100644
index 00000000000..b14fe905fa5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr126644.c
@@ -0,0 +1,55 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+
+int f1 (int a)
+{
+  if ((a & 0xF0000000) != 0xF0000000)
+    __builtin_unreachable ();
+
+  return a << 3 >> 3;
+}
+
+/* Can't be optimized (not enough 1s to preserve sign).  */
+int g1 (int a)
+{
+  if ((a & 0xF0000000) != 0xE0000000)
+    __builtin_unreachable ();
+
+  return a << 3 >> 3;
+}
+
+int f2 (int a)
+{
+  if ((a & 0xF0000000) != 0) __builtin_unreachable ();
+
+  return a << 3 >> 3;
+}
+
+/* Can't be optimized (not enough 0s to preserve sign).  */
+int g2 (int a)
+{
+  if ((a & 0x10000000) != 0x10000000)
+    __builtin_unreachable ();
+
+  return a << 3 >> 3;
+}
+
+unsigned int f3 (unsigned int a)
+{
+  if ((a & 0xE0000000) != 0)  __builtin_unreachable ();
+
+  return a << 3 >> 3;
+}
+
+/* Can't be optimized (will lose a bit during lshift).
+   This simplifies into a bit_and.  */
+unsigned int g3 (unsigned int a)
+{
+  if ((a & 0xA0000000) != 0)  __builtin_unreachable ();
+
+  return a << 3 >> 3;
+}
+
+/* { dg-final { scan-tree-dump-times " << " 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " >> " 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " & " 1 "optimized" } } */