From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 9CEBE39DD7DD; Mon, 12 Dec 2022 11:20:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CEBE39DD7DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670844052; bh=KrR3c9QUtiCf/imh+HJo89hkzVEey2+eiElC4AC21Bo=; h=From:To:Subject:Date:From; b=it1l8wPJCKLtLhUOcNQ0HAGTb7Eq8/sJAb5bp6T19Qry84Q+OnvBiDmibO+zXr5AF bJ029q07woCVvryoQ7lZVYAYWkoKlIILKRLhNrBRo3FJ81PpJ+oB0iO3suxDKUokVI w5Nb5bNMCoFdR6VnDVscepgjHITjB0JPaN9r36Wk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8976] tree-optimization/107686 - fix bitfield ref through vec_unpack optimization X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 9e242f8a2d5987ddaa74696e5ad809303ddc8dd0 X-Git-Newrev: 232305bd0c8dd37b17b815864e730aa630714606 Message-Id: <20221212112052.9CEBE39DD7DD@sourceware.org> Date: Mon, 12 Dec 2022 11:20:52 +0000 (GMT) List-Id: https://gcc.gnu.org/g:232305bd0c8dd37b17b815864e730aa630714606 commit r12-8976-g232305bd0c8dd37b17b815864e730aa630714606 Author: Richard Biener Date: Wed Nov 16 15:27:13 2022 +0100 tree-optimization/107686 - fix bitfield ref through vec_unpack optimization The following propely restricts the bitfield access to integral types when we look through VEC_UNPACK with the intent to emit a widening conversion. PR tree-optimization/107686 * tree-ssa-forwprop.cc (optimize_vector_load): Restrict VEC_UNPACK support to integral typed bitfield refs. * gcc.dg/pr107686.c: New testcase. (cherry picked from commit 246bbdaa5f536b7a199dda9860c473137f40d622) Diff: --- gcc/testsuite/gcc.dg/pr107686.c | 16 ++++++++++++++++ gcc/tree-ssa-forwprop.cc | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr107686.c b/gcc/testsuite/gcc.dg/pr107686.c new file mode 100644 index 00000000000..2378103c555 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr107686.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target { dfp && longlong64 } } } */ +/* { dg-options "-O" } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ + +typedef _Decimal64 __attribute__((__vector_size__ (64))) D; +typedef __INT32_TYPE__ __attribute__((__vector_size__ (32))) U; +typedef __INT64_TYPE__ __attribute__((__vector_size__ (64))) V; + +U u; +D d; + +void +foo (void) +{ + d = d < (D) __builtin_convertvector (u, V); +} diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 484491fa1c5..260d5dac83b 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3118,7 +3118,11 @@ optimize_vector_load (gimple_stmt_iterator *gsi) && (def == lhs || (known_eq (bit_field_size (use_rhs), def_eltsize) && constant_multiple_p (bit_field_offset (use_rhs), - def_eltsize)))) + def_eltsize) + /* We can simulate the VEC_UNPACK_{HI,LO}_EXPR + via a NOP_EXPR only for integral types. + ??? Support VEC_UNPACK_FLOAT_{HI,LO}_EXPR. */ + && INTEGRAL_TYPE_P (TREE_TYPE (use_rhs))))) { bf_stmts.safe_push (use_stmt); continue;