mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
analyzer: fix ICE on (X + (-X)) for vectors [PR124188]
gcc/analyzer/ChangeLog: PR analyzer/124188 * region-model-manager.cc (region_model_manager::maybe_fold_binop): Don't attempt to fold X + (-X) to zero for vector types. gcc/testsuite/ChangeLog: PR analyzer/124188 * c-c++-common/analyzer/vector-ice-pr124188.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
@@ -683,7 +683,8 @@ region_model_manager::maybe_fold_binop (tree type, enum tree_code op,
|
||||
/* X + (-X) -> 0. */
|
||||
if (const unaryop_svalue *unary_op = arg1->dyn_cast_unaryop_svalue ())
|
||||
if (unary_op->get_op () == NEGATE_EXPR
|
||||
&& unary_op->get_arg () == arg0)
|
||||
&& unary_op->get_arg () == arg0
|
||||
&& type && (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)))
|
||||
return get_or_create_int_cst (type, 0);
|
||||
/* X + (Y - X) -> Y. */
|
||||
if (const binop_svalue *bin_op = arg1->dyn_cast_binop_svalue ())
|
||||
|
||||
12
gcc/testsuite/c-c++-common/analyzer/vector-ice-pr124188.c
Normal file
12
gcc/testsuite/c-c++-common/analyzer/vector-ice-pr124188.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/* { dg-additional-options "-Wno-psabi" } */
|
||||
|
||||
typedef __attribute__((__vector_size__(64))) char V;
|
||||
|
||||
V g;
|
||||
|
||||
void
|
||||
foo(V a)
|
||||
{
|
||||
V v = -a;
|
||||
a + v + g;
|
||||
}
|
||||
Reference in New Issue
Block a user