tree-optimization/115646 - ICE with pow shrink-wrapping from bitfield

The following makes analysis and transform agree on constraints.

	PR tree-optimization/115646
	* tree-call-cdce.cc (check_pow): Check for bit_sz values
	as allowed by transform.

	* gcc.dg/pr115646.c: New testcase.

(cherry picked from commit 453b1d291d1a0f89087ad91cf6b1bed1ec68eff3)
This commit is contained in:
Richard Biener 2024-06-25 16:13:02 +02:00 committed by Richard Biener
parent c36acfea1a
commit 078cdccc84
2 changed files with 14 additions and 1 deletions

View file

@ -0,0 +1,13 @@
/* { dg-do compile } */
/* { dg-options "-O2" } */
extern double pow(double x, double y);
struct S {
unsigned int a : 3, b : 8, c : 21;
};
void foo (struct S *p)
{
pow (p->c, 42);
}

View file

@ -260,7 +260,7 @@ check_pow (gcall *pow_call)
/* If the type of the base is too wide,
the resulting shrink wrapping condition
will be too conservative. */
if (bit_sz > MAX_BASE_INT_BIT_SIZE)
if (bit_sz != 8 && bit_sz != 16 && bit_sz != MAX_BASE_INT_BIT_SIZE)
return false;
return true;