diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-01-12 11:20:40 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-01-12 11:20:40 +0100 |
commit | a2d66158541c0923620b044098bf66a73b51c463 (patch) | |
tree | 2aa224150011a488f0742eb786e9fa9e1234aeee | |
parent | c1680bd2df187e06089b06ffe211c4abe4c440b0 (diff) | |
download | gcc-a2d66158541c0923620b044098bf66a73b51c463.zip gcc-a2d66158541c0923620b044098bf66a73b51c463.tar.gz gcc-a2d66158541c0923620b044098bf66a73b51c463.tar.bz2 |
lower-bitint: Fix a typo in a condition [PR113323]
The following testcase revealed a typo in condition, as the comment
says the intent is
/* If lhs of stmt is large/huge _BitInt SSA_NAME not in m_names
it means it will be handled in a loop or straight line code
at the location of its (ultimate) immediate use, so for
vop checking purposes check these only at the ultimate
immediate use. */
but the condition was using != BITINT_TYPE rather than == BITINT_TYPE,
so e.g. it used bitint_precision_kind on non-BITINT_TYPEs (e.g. on vector
types it will crash because TYPE_PRECISION means something different there,
or on say INTEGER_TYPEs the precision will never be large enough to be >=
bitint_prec_large).
The following patch fixes that.
2024-01-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/113323
* gimple-lower-bitint.cc (bitint_dom_walker::before_dom_children): Fix
check for lhs being large/huge _BitInt not in m_names.
* gcc.dg/bitint-68.c: New test.
-rw-r--r-- | gcc/gimple-lower-bitint.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/bitint-68.c | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index ea616ea..f1e4cd0 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -5513,7 +5513,7 @@ bitint_dom_walker::before_dom_children (basic_block bb) tree lhs = gimple_get_lhs (stmt); if (lhs && TREE_CODE (lhs) == SSA_NAME - && TREE_CODE (TREE_TYPE (lhs)) != BITINT_TYPE + && TREE_CODE (TREE_TYPE (lhs)) == BITINT_TYPE && bitint_precision_kind (TREE_TYPE (lhs)) >= bitint_prec_large && !bitmap_bit_p (m_names, SSA_NAME_VERSION (lhs))) /* If lhs of stmt is large/huge _BitInt SSA_NAME not in m_names, diff --git a/gcc/testsuite/gcc.dg/bitint-68.c b/gcc/testsuite/gcc.dg/bitint-68.c new file mode 100644 index 0000000..092f31a --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitint-68.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/113323 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-std=c23 -O2" } */ + +typedef long __attribute__((__vector_size__ (16))) V; +V u, v; +_BitInt(535) i; + +void +foo (void) +{ + while (i) + u = v; +} |