From: Richard Biener Date: Mon, 25 Jan 2021 10:22:28 +0000 (+0100) Subject: middle-end/98807 - more vector_element_bits fixes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=defc40db9e09ecceb2d71727031fe9579bce1b11;p=gcc.git 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 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. --- diff --git a/gcc/testsuite/gcc.dg/pr98807.c b/gcc/testsuite/gcc.dg/pr98807.c new file mode 100644 index 00000000000..eb8a8d1c23d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98807.c @@ -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 + +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; +} diff --git a/gcc/tree.c b/gcc/tree.c index 87862be9273..287e5001dc3 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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))); }