middle-end/98807 - more vector_element_bits fixes

This simplifies vector_element_bits further, avoiding any mode
dependence and instead relying on boolean vector construction
to populate element precision accordingly.

2021-01-25  Richard Biener  <rguenther@suse.de>

	PR middle-end/98807
	* tree.c (vector_element_bits): Always use precision of
	the element type for boolean vectors.

	* gcc.dg/pr98807.c: New testcase.
This commit is contained in:
Richard Biener 2021-01-25 11:22:28 +01:00
parent 0433fc2d7d
commit defc40db9e
2 changed files with 36 additions and 7 deletions

View file

@ -0,0 +1,35 @@
/* { dg-do run } */
/* { dg-require-effective-target stdint_types } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-mno-sse2" { target x86_64-*-* i?86-*-* } } */
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef u64 __attribute__((__vector_size__ (16))) v128u64;
u16 foo0_u16_0;
v128u64 foo0_v64u32_0;
u64 foo0_u64_0;
v128u64 foo0_v128u64_2;
v128u64
foo0 (u8 u8_0, v128u64 v128u64_0)
{
u32 u32_1 = u8_0 || (0, 0);
foo0_v128u64_2 - u8_0;
foo0_u16_0 |= foo0_u64_0 && u8_0 > foo0_u64_0 <= u32_1;
v128u64 v128u64_4 = v128u64_0 >= u8_0;
return v128u64_4 + foo0_v64u32_0;
}
int
main ()
{
v128u64 x = foo0 (3, (v128u64) { 0, 12 });
if (x[0] != 0) __builtin_abort();
if (x[1] != 0xffffffffffffffff) __builtin_abort();
return 0;
}

View file

@ -14027,13 +14027,7 @@ vector_element_bits (const_tree type)
{
gcc_checking_assert (VECTOR_TYPE_P (type));
if (VECTOR_BOOLEAN_TYPE_P (type))
{
if (SCALAR_INT_MODE_P (TYPE_MODE (type)))
return 1;
else
return vector_element_size (tree_to_poly_uint64 (TYPE_SIZE (type)),
TYPE_VECTOR_SUBPARTS (type));
}
return TYPE_PRECISION (TREE_TYPE (type));
return tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type)));
}