diff options
author | Richard Biener <rguenther@suse.de> | 2025-07-16 14:07:48 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2025-07-16 15:34:16 +0200 |
commit | 39ba01fe70c77e70a00ed65a1e6bac8350479f4d (patch) | |
tree | 7e9f8ab6f4a944b5a60bbc21b167067b56d3c0df /gcc | |
parent | 7c3081960922d9bd3ea81a9f8ca6e00c23170a2b (diff) | |
download | gcc-39ba01fe70c77e70a00ed65a1e6bac8350479f4d.zip gcc-39ba01fe70c77e70a00ed65a1e6bac8350479f4d.tar.gz gcc-39ba01fe70c77e70a00ed65a1e6bac8350479f4d.tar.bz2 |
tree-optimization/121116 - avoid _BitInt for vector element init
When having a _BitInt induction we should make sure to not create
the step vector elements as _BitInts but as vector element typed.
PR tree-optimization/121116
* tree-vect-loop.cc (vectorizable_induction): Use the
step vector element type for further processing.
* gcc.dg/torture/pr121116.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr121116.c | 21 | ||||
-rw-r--r-- | gcc/tree-vect-loop.cc | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr121116.c b/gcc/testsuite/gcc.dg/torture/pr121116.c new file mode 100644 index 0000000..637324f --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr121116.c @@ -0,0 +1,21 @@ +/* { dg-do run { target bitint } } */ + +#include <stdlib.h> +#include <stdckdint.h> +#include <string.h> +typedef _BitInt(16) bit16; +[[nodiscard]] static bit16 process_data(bit16 input) { + _Static_assert(sizeof(bit16) == 2, "Unexpected size of bit16"); + return (input << 5) | (input >> 9); +} +int main(void) { + const bit16 data = 0b101'0101'0000'0000; + bit16 result = 0; + for (bit16 i = 0; i < 0b1000; ++i) { + result ^= process_data(data ^ i); + } + if (ckd_add(&result, result, 0x1234)) { + return EXIT_FAILURE; + } + return (result & 0xFF00) ? 0 : 1; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 734b7ef..edad40c 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -9831,6 +9831,7 @@ vectorizable_induction (loop_vec_info loop_vinfo, } tree stept = TREE_TYPE (step_expr); tree step_vectype = get_same_sized_vectype (stept, vectype); + stept = TREE_TYPE (step_vectype); /* Check for target support of the vectorized arithmetic used here. */ if (!target_supports_op_p (step_vectype, PLUS_EXPR, optab_default) |