From 63e523d6f0853765adc332c7a68a8e6b16971d6b Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Wed, 2 Nov 2016 09:25:22 +0000 Subject: [PATCH] PR tree-optimization/78162: Reject negative offsets in store merging early PR tree-optimization/78162 * gimple-ssa-store-merging.c (execute): Mark stores with bitpos < 0 as invalid. * gcc.c-torture/compile/pr78162.c: New test. From-SVN: r241778 --- gcc/ChangeLog | 6 ++++++ gcc/gimple-ssa-store-merging.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr78162.c | 10 ++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr78162.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 52215f6eebf..aee2b83f8b3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-02 Kyrylo Tkachov + + PR tree-optimization/78162 + * gimple-ssa-store-merging.c (execute): Mark stores with bitpos < 0 + as invalid. + 2016-11-02 Kyrylo Tkachov * config/aarch64/aarch64.c (aarch64_register_saved_on_entry): Add diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 97af1418c97..feba907559f 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -1361,7 +1361,7 @@ pass_store_merging::execute (function *fun) &unsignedp, &reversep, &volatilep); /* As a future enhancement we could handle stores with the same base and offset. */ - bool invalid = offset || reversep + bool invalid = offset || reversep || bitpos < 0 || ((bitsize > MAX_BITSIZE_MODE_ANY_INT) && (TREE_CODE (rhs) != INTEGER_CST)) || !rhs_valid_for_store_merging_p (rhs) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6827c0090bc..d979a56fcf7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-02 Kyrylo Tkachov + + PR tree-optimization/78162 + * gcc.c-torture/compile/pr78162.c: New test. + 2016-11-02 Richard Biener PR tree-optimization/78035 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78162.c b/gcc/testsuite/gcc.c-torture/compile/pr78162.c new file mode 100644 index 00000000000..743d4e678b5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr78162.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/78162. + Handle negative offsets in store merging gracefully. */ + +int a, b[1][2]; + +void fn1() +{ + for (a = 0; a < 2; a++) + b[-1][a] = 0; +} -- 2.30.2