summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-store-merging.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-11-01 13:31:45 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-11-01 13:31:45 +0100
commit444cda74708a494cc814951fe29d4904cec4f7e2 (patch)
tree87a889af7f57b2997af0c48d68fb490e0ae00400 /gcc/gimple-ssa-store-merging.c
parent86ba9ce62614375784f5ce92d711e00db391d81e (diff)
re PR tree-optimization/87826 (ubsan: gimple-ssa-store-merging.c:281)
PR tree-optimization/87826 * gimple-ssa-store-merging.c (do_shift_rotate): Punt if count is negative or larger or equal to type's precision. * gcc.dg/pr87826.c: New test. From-SVN: r265720
Diffstat (limited to 'gcc/gimple-ssa-store-merging.c')
-rw-r--r--gcc/gimple-ssa-store-merging.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index e1ddcb5e558..5e5823c44a0 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -262,7 +262,9 @@ do_shift_rotate (enum tree_code code,
int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
unsigned head_marker;
- if (count % BITS_PER_UNIT != 0)
+ if (count < 0
+ || count >= TYPE_PRECISION (n->type)
+ || count % BITS_PER_UNIT != 0)
return false;
count = (count / BITS_PER_UNIT) * BITS_PER_MARKER;