diff options
author | Kaipeng Zhou <zhoukaipeng3@huawei.com> | 2020-06-24 22:48:45 +0800 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-06-29 12:58:10 +0200 |
commit | 35cf3c55165efe8226cb9e5397ab0620130396ea (patch) | |
tree | 6404e7a6bc193240061ded0cc903a996b4fb9cb8 /gcc | |
parent | ceac3edb42e1090be8cee895a5659fe847a4050a (diff) | |
download | gcc-35cf3c55165efe8226cb9e5397ab0620130396ea.zip gcc-35cf3c55165efe8226cb9e5397ab0620130396ea.tar.gz gcc-35cf3c55165efe8226cb9e5397ab0620130396ea.tar.bz2 |
store-merging: ICE in find_bswap_or_nop_1 PR95854.
The patch add a judgement in find_bswap_or_nop_1 to make sure both
operand1 and operand2 cannot be converted to unsigned HOST_WIDE_INT.
If not, return NULL.
gcc/ChangeLog:
2020-06-24 Kaipeng Zhou <zhoukaipeng3@huawei.com>
PR tree-optimization/95854
* gimple-ssa-store-merging.c (find_bswap_or_nop_1): Return NULL
if operand 1 or 2 of a BIT_FIELD_REF cannot be converted to
unsigned HOST_WIDE_INT.
gcc/testsuite/ChangeLog:
2020-06-24 Kaipeng Zhou <zhoukaipeng3@huawei.com>
PR tree-optimization/95854
* gcc.dg/pr95854.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-ssa-store-merging.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr95854.c | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 3ab6141..5cb7101 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -598,6 +598,10 @@ find_bswap_or_nop_1 (gimple *stmt, struct symbolic_number *n, int limit) if (TREE_CODE (rhs1) == BIT_FIELD_REF && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME) { + if (!tree_fits_uhwi_p (TREE_OPERAND (rhs1, 1)) + || !tree_fits_uhwi_p (TREE_OPERAND (rhs1, 2))) + return NULL; + unsigned HOST_WIDE_INT bitsize = tree_to_uhwi (TREE_OPERAND (rhs1, 1)); unsigned HOST_WIDE_INT bitpos = tree_to_uhwi (TREE_OPERAND (rhs1, 2)); if (bitpos % BITS_PER_UNIT == 0 diff --git a/gcc/testsuite/gcc.dg/pr95854.c b/gcc/testsuite/gcc.dg/pr95854.c new file mode 100644 index 0000000..db45d6a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr95854.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-vect-cost-model -fno-tree-scev-cprop -ftracer" } */ +/* { dg-additional-options "-march=armv8.5-a+sve2" { target aarch64*-*-* } } */ + +extern void abort (void); +int c, d; +int main() +{ + int e[] = {4, 4, 4, 4, 4, 4, 4, 4, 4}; + d = 8; + for (; d; d--) + for (int a = 0; a <= 8; a++) + { + c = e[1]; + e[d] = 0; + } + if (c != 0) + abort (); + return 0; +} |