Commit 2efa10d5 by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/93098 (ICE with negative shifter)

	PR tree-optimization/93098
	* match.pd (popcount): For shift amounts, use integer_onep
	or wi::to_widest () == cst instead of tree_to_uhwi () == cst
	tests.  Make sure that precision is power of two larger than or equal
	to 16.  Ensure shift is never negative.  Use HOST_WIDE_INT_UC macro
	instead of ULL suffixed constants.  Formatting fixes.

	* gcc.c-torture/compile/pr93098.c: New test.

From-SVN: r279809
parent b3b13bf1
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5795,31 +5795,38 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ...@@ -5795,31 +5795,38 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(bit_and @6 INTEGER_CST@7) (bit_and @6 INTEGER_CST@7)
(bit_and (bit_and
(rshift (rshift
(minus@6 (minus@6 @0
@0 (bit_and (rshift @0 INTEGER_CST@4) INTEGER_CST@11))
(bit_and
(rshift @0 INTEGER_CST@4)
INTEGER_CST@11))
INTEGER_CST@10) INTEGER_CST@10)
INTEGER_CST@9))) INTEGER_CST@9)))
INTEGER_CST@3) INTEGER_CST@3)
INTEGER_CST@2) INTEGER_CST@2)
INTEGER_CST@1) INTEGER_CST@1)
/* Check constants and optab. */ /* Check constants and optab. */
(with (with { unsigned prec = TYPE_PRECISION (type);
{ int shift = (64 - prec) & 63;
unsigned prec = TYPE_PRECISION (type); unsigned HOST_WIDE_INT c1
int shift = 64 - prec; = HOST_WIDE_INT_UC (0x0101010101010101) >> shift;
const unsigned HOST_WIDE_INT c1 = 0x0101010101010101ULL >> shift, unsigned HOST_WIDE_INT c2
c2 = 0x0F0F0F0F0F0F0F0FULL >> shift, = HOST_WIDE_INT_UC (0x0F0F0F0F0F0F0F0F) >> shift;
c3 = 0x3333333333333333ULL >> shift, unsigned HOST_WIDE_INT c3
c4 = 0x5555555555555555ULL >> shift; = HOST_WIDE_INT_UC (0x3333333333333333) >> shift;
unsigned HOST_WIDE_INT c4
= HOST_WIDE_INT_UC (0x5555555555555555) >> shift;
} }
(if (prec <= 64 && TYPE_UNSIGNED (type) && tree_to_uhwi (@4) == 1 (if (prec >= 16
&& tree_to_uhwi (@10) == 2 && tree_to_uhwi (@5) == 4 && prec <= 64
&& tree_to_uhwi (@1) == prec - 8 && tree_to_uhwi (@2) == c1 && pow2p_hwi (prec)
&& tree_to_uhwi (@3) == c2 && tree_to_uhwi (@9) == c3 && TYPE_UNSIGNED (type)
&& tree_to_uhwi (@7) == c3 && tree_to_uhwi (@11) == c4 && integer_onep (@4)
&& wi::to_widest (@10) == 2
&& wi::to_widest (@5) == 4
&& wi::to_widest (@1) == prec - 8
&& tree_to_uhwi (@2) == c1
&& tree_to_uhwi (@3) == c2
&& tree_to_uhwi (@9) == c3
&& tree_to_uhwi (@7) == c3
&& tree_to_uhwi (@11) == c4
&& direct_internal_fn_supported_p (IFN_POPCOUNT, type, && direct_internal_fn_supported_p (IFN_POPCOUNT, type,
OPTIMIZE_FOR_BOTH)) OPTIMIZE_FOR_BOTH))
(convert (IFN_POPCOUNT:type @0))))) (convert (IFN_POPCOUNT:type @0)))))
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/* PR tree-optimization/93098 */
int
foo (unsigned long long x)
{
x -= (x >> -1) & 0x5555555555555555ULL;
x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
return (x * 0x0101010101010101ULL) >> 56;
}
int
bar (unsigned long long x)
{
x -= (x >> 1) & 0x5555555555555555ULL;
x = (x & 0x3333333333333333ULL) + ((x >> -2) & 0x3333333333333333ULL);
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
return (x * 0x0101010101010101ULL) >> 56;
}
int
baz (unsigned long long x)
{
x -= (x >> 1) & 0x5555555555555555ULL;
x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
x = (x + (x >> -4)) & 0x0f0f0f0f0f0f0f0fULL;
return (x * 0x0101010101010101ULL) >> 56;
}
int
qux (unsigned long long x)
{
x -= (x >> 1) & 0x5555555555555555ULL;
x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
return (x * 0x0101010101010101ULL) >> -56;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment