Plug loophole in string store merging
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 20 Nov 2020 11:21:12 +0000 (12:21 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 20 Nov 2020 11:24:08 +0000 (12:24 +0100)
commit1b3c9813675dc8e3ca03aa6c1624c668ac7fea1d
treed8a03ef598966b995f46708c34c190214fe35b7d
parentcd287abe8cd11cfe9b230b0c9f28e86ecd7859e6
Plug loophole in string store merging

There is a loophole in new string store merging support added recently:
it does not check that the stores are consecutive, which is obviously
required if you want to concatenate them...  Simple fix attached, the
nice thing being that it can fall back to the regular processing if
any hole is detected in the series of stores, thanks to the handling
of STRING_CST by native_encode_expr.

gcc/ChangeLog:
* gimple-ssa-store-merging.c (struct merged_store_group): Add
new 'consecutive' field.
(merged_store_group): Set it to true.
(do_merge): Set it to false if the store is not consecutive and
set string_concatenation to false in this case.
(merge_into): Call do_merge on entry.
(merge_overlapping): Likewise.

gcc/testsuite/ChangeLog:
* gnat.dg/opt90a.adb: New test.
* gnat.dg/opt90b.adb: Likewise.
* gnat.dg/opt90c.adb: Likewise.
* gnat.dg/opt90d.adb: Likewise.
* gnat.dg/opt90e.adb: Likewise.
* gnat.dg/opt90a_pkg.ads: New helper.
* gnat.dg/opt90b_pkg.ads: Likewise.
* gnat.dg/opt90c_pkg.ads: Likewise.
* gnat.dg/opt90d_pkg.ads: Likewise.
* gnat.dg/opt90e_pkg.ads: Likewise.
gcc/gimple-ssa-store-merging.c
gcc/testsuite/gnat.dg/opt90a.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90a_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90b.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90b_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90c.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90c_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90d.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90d_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90e.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt90e_pkg.ads [new file with mode: 0644]