From 3e1b80ff33f3a854e757fad185ee86dc30fb3e6f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 8 Jan 2018 08:24:51 +0000 Subject: [PATCH] re PR tree-optimization/83580 (Wrong code caused by vectorization) 2018-01-08 Richard Biener PR middle-end/83580 * tree-data-ref.c (split_constant_offset): Remove STRIP_NOPS. * gcc.dg/torture/pr83580.c: New testcase. From-SVN: r256329 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr83580.c | 16 ++++++++++++++++ gcc/tree-data-ref.c | 8 +++----- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr83580.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5de2348dd21..1d7796ae306 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-01-08 Richard Biener + + PR middle-end/83580 + * tree-data-ref.c (split_constant_offset): Remove STRIP_NOPS. + 2018-01-08 Richard Biener PR middle-end/83517 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9ec2e81dc56..de940033386 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-08 Richard Biener + + PR middle-end/83580 + * gcc.dg/torture/pr83580.c: New testcase. + 2018-01-08 Richard Biener PR middle-end/83517 diff --git a/gcc/testsuite/gcc.dg/torture/pr83580.c b/gcc/testsuite/gcc.dg/torture/pr83580.c new file mode 100644 index 00000000000..e8030b481f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr83580.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +int a[2] = { 0, 1 }; +int x = 129; + +int +main () +{ + volatile int v = 0; + int t = x, i; + for (i = 0; i < 1 + v + v + v + v + v + v + v + v + a[a[0]]; i++) + t = a[(signed char) (130 - x)]; + if (t != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index fc503c7cfb7..3b15b5dc2c1 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -723,23 +723,21 @@ split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1, void split_constant_offset (tree exp, tree *var, tree *off) { - tree type = TREE_TYPE (exp), otype, op0, op1, e, o; + tree type = TREE_TYPE (exp), op0, op1, e, o; enum tree_code code; *var = exp; *off = ssize_int (0); - STRIP_NOPS (exp); if (tree_is_chrec (exp) || get_gimple_rhs_class (TREE_CODE (exp)) == GIMPLE_TERNARY_RHS) return; - otype = TREE_TYPE (exp); code = TREE_CODE (exp); extract_ops_from_tree (exp, &code, &op0, &op1); - if (split_constant_offset_1 (otype, op0, code, op1, &e, &o)) + if (split_constant_offset_1 (type, op0, code, op1, &e, &o)) { - *var = fold_convert (type, e); + *var = e; *off = o; } } -- 2.30.2