https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122541
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |middle-end
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>From fold-const.cc:
```
/* Canonicalize (X & C1) | C2. */
...
/* Minimize the number of bits set in C1, i.e. C1 := C1 & ~C2,
unless (C1 & ~C2) | (C2 & C3) for some C3 is a mask of some
mode which allows further optimizations. */
c1 &= msk;
c2 &= msk;
wide_int c3 = wi::bit_and_not (c1, c2);
for (w = BITS_PER_UNIT; w <= width; w <<= 1)
{
wide_int mask = wi::mask (w, false,
TYPE_PRECISION (type));
if (((c1 | c2) & mask) == mask
&& wi::bit_and_not (c1, mask) == 0)
{
c3 = mask;
break;
}
}
if (c3 != c1)
{
tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
tem = fold_build2_loc (loc, BIT_AND_EXPR, type, tem,
wide_int_to_tree (type, c3));
return fold_build2_loc (loc, BIT_IOR_EXPR, type, tem, arg1);
}
```