diff options
author | Paul Koning <ni1d@arrl.net> | 2018-06-07 13:55:05 -0400 |
---|---|---|
committer | Paul Koning <pkoning@gcc.gnu.org> | 2018-06-07 13:55:05 -0400 |
commit | a3e87f07f3dc36bd42ed82853429d64a4b5b9703 (patch) | |
tree | 2d3ec078e149f926309b09d57d900fb27c257a8d /gcc | |
parent | 75d1c00452b12b51121236930d09578bc01f6306 (diff) | |
download | gcc-a3e87f07f3dc36bd42ed82853429d64a4b5b9703.zip gcc-a3e87f07f3dc36bd42ed82853429d64a4b5b9703.tar.gz gcc-a3e87f07f3dc36bd42ed82853429d64a4b5b9703.tar.bz2 |
compare-elim.c (try_merge_compare): Don't merge compare if address contains a side effect.
2018-06-07 Paul Koning <ni1d@arrl.net>
gcc/
* compare-elim.c (try_merge_compare): Don't merge compare if
address contains a side effect.
(try_eliminate_compare): Likewise.
gcc/testsuite/
* gcc.c-torture/compile/20180605-1.c: New test.
From-SVN: r261287
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/compare-elim.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20180605-1.c | 9 |
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 81eec65..ee56a21 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-07 Paul Koning <ni1d@arrl.net> + + * compare-elim.c (try_merge_compare): Don't merge compare if + address contains a side effect. + (try_eliminate_compare): Likewise. + 2018-06-07 Olga Makhotina <olga.makhotina@intel.com> * config.gcc: Support "tremont". diff --git a/gcc/compare-elim.c b/gcc/compare-elim.c index 16576c4..50bbaa8 100644 --- a/gcc/compare-elim.c +++ b/gcc/compare-elim.c @@ -690,6 +690,13 @@ try_merge_compare (struct comparison *cmp) return false; rtx src = SET_SRC (set); + + /* If the source uses addressing modes with side effects, we can't + do the merge because we'd end up with a PARALLEL that has two + instances of that side effect in it. */ + if (side_effects_p (src)) + return false; + rtx flags = maybe_select_cc_mode (cmp, src, CONST0_RTX (GET_MODE (src))); if (!flags) { @@ -809,6 +816,12 @@ try_eliminate_compare (struct comparison *cmp) else return false; + /* If the source uses addressing modes with side effects, we can't + do the merge because we'd end up with a PARALLEL that has two + instances of that side effect in it. */ + if (side_effects_p (cmp_src)) + return false; + /* Determine if we ought to use a different CC_MODE here. */ flags = maybe_select_cc_mode (cmp, cmp_src, in_b); if (flags == NULL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f26dd5b..272cb03 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-06-07 Paul Koning <ni1d@arrl.net> + + * gcc.c-torture/compile/20180605-1.c: New test. + 2018-06-07 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/86045 diff --git a/gcc/testsuite/gcc.c-torture/compile/20180605-1.c b/gcc/testsuite/gcc.c-torture/compile/20180605-1.c new file mode 100644 index 0000000..915dafd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20180605-1.c @@ -0,0 +1,9 @@ +void f (int *p, int n) +{ + int j = 0, k; + + for (int i = 0; i < n; i++) + if ((k = *p++) > 0) + j += k; + return j; +} |