bswap: Fix up bswap_view_convert handling [PR102141]
bswap_view_convert is used twice in spots where gsi_insert_before is the
right thing, but in the last one it wants to insert preparation stmts
for the VIEW_CONVERT_EXPR emitted with gsi_insert_after, where at the
gsi we still need to insert bswap_stmt and maybe mask_stmt whose lhs
the preparation stmts will use.
So, this patch adds a BEFORE argument to the function and emits the
preparation statements before or after depending on that.
2021-09-01 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/102141
* gimple-ssa-store-merging.c (bswap_view_convert): Add BEFORE
argument. If false, emit stmts after gsi instead of before, and
with GSI_NEW_STMT.
(bswap_replace): Adjust callers. When converting output of bswap,
emit VIEW_CONVERT prepratation stmts after a copy of gsi instead
of before it.
* gcc.dg/pr102141.c: New test.