* [PATCH] tree-optimization/98221 - fix wrong unpack operation used for big-endian
@ 2021-01-11 10:02 Andreas Krebbel
2021-01-11 19:15 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Krebbel @ 2021-01-11 10:02 UTC (permalink / raw)
To: gcc-patches
The vec-abi-varargs-1.c testcase on IBM Z currently fails.
While adding an SI mode vector to a DI mode vector the first is unpacked using:
_28 = BIT_INSERT_EXPR <{ 0, 0, 0, 0 }, _2, 0>;
_34 = [vec_unpack_lo_expr] _28;
However, on big endian targets lo refers to the right hand side of the vector - in this case the zeroes.
Bootstrap & regtest running on x86_64-unknown-linux-gnu.
2021-01-11 Andreas Krebbel <krebbel@linux.ibm.com>
* tree-ssa-forwprop.c (simplify_vector_constructor): For
big-endian, use UNPACK[_FLOAT]_HI.
---
gcc/tree-ssa-forwprop.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 8a1a1237647..0706fd862de 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -2392,6 +2392,17 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
some simple special cases via VEC_[UN]PACK[_FLOAT]_LO_EXPR. */
optab optab;
tree halfvectype, dblvectype;
+ enum tree_code unpack_op;
+
+ if (!BYTES_BIG_ENDIAN)
+ unpack_op = (FLOAT_TYPE_P (TREE_TYPE (type))
+ ? VEC_UNPACK_FLOAT_LO_EXPR
+ : VEC_UNPACK_LO_EXPR);
+ else
+ unpack_op = (FLOAT_TYPE_P (TREE_TYPE (type))
+ ? VEC_UNPACK_FLOAT_HI_EXPR
+ : VEC_UNPACK_HI_EXPR);
+
if (CONVERT_EXPR_CODE_P (conv_code)
&& (2 * TYPE_PRECISION (TREE_TYPE (TREE_TYPE (orig[0])))
== TYPE_PRECISION (TREE_TYPE (type)))
@@ -2405,9 +2416,7 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
represented as scalar bitmasks. See PR95528. */
&& (VECTOR_MODE_P (TYPE_MODE (dblvectype))
|| VECTOR_BOOLEAN_TYPE_P (dblvectype))
- && (optab = optab_for_tree_code (FLOAT_TYPE_P (TREE_TYPE (type))
- ? VEC_UNPACK_FLOAT_LO_EXPR
- : VEC_UNPACK_LO_EXPR,
+ && (optab = optab_for_tree_code (unpack_op,
dblvectype,
optab_default))
&& (optab_handler (optab, TYPE_MODE (dblvectype))
@@ -2430,11 +2439,7 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
orig[0], TYPE_SIZE (dblvectype),
bitsize_zero_node);
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
- gimple_assign_set_rhs_with_ops (gsi,
- FLOAT_TYPE_P (TREE_TYPE (type))
- ? VEC_UNPACK_FLOAT_LO_EXPR
- : VEC_UNPACK_LO_EXPR,
- dbl);
+ gimple_assign_set_rhs_with_ops (gsi, unpack_op, dbl);
}
else if (CONVERT_EXPR_CODE_P (conv_code)
&& (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (orig[0])))
--
2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tree-optimization/98221 - fix wrong unpack operation used for big-endian
2021-01-11 10:02 [PATCH] tree-optimization/98221 - fix wrong unpack operation used for big-endian Andreas Krebbel
@ 2021-01-11 19:15 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-01-11 19:15 UTC (permalink / raw)
To: Andreas Krebbel, gcc-patches
On 1/11/21 3:02 AM, Andreas Krebbel via Gcc-patches wrote:
> The vec-abi-varargs-1.c testcase on IBM Z currently fails.
>
> While adding an SI mode vector to a DI mode vector the first is unpacked using:
>
> _28 = BIT_INSERT_EXPR <{ 0, 0, 0, 0 }, _2, 0>;
> _34 = [vec_unpack_lo_expr] _28;
>
> However, on big endian targets lo refers to the right hand side of the vector - in this case the zeroes.
>
> Bootstrap & regtest running on x86_64-unknown-linux-gnu.
>
> 2021-01-11 Andreas Krebbel <krebbel@linux.ibm.com>
>
> * tree-ssa-forwprop.c (simplify_vector_constructor): For
> big-endian, use UNPACK[_FLOAT]_HI.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-11 19:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 10:02 [PATCH] tree-optimization/98221 - fix wrong unpack operation used for big-endian Andreas Krebbel
2021-01-11 19:15 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).