From patchwork Wed Nov 16 15:34:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 60706 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9CF7395B47A for ; Wed, 16 Nov 2022 15:35:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9CF7395B47A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668612901; bh=HKa10xD6BXqBZxqeAXOpig0PxafVMMuas45sUp5Hc5w=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=LvlhS7kBzG8d9G0z0gr+YyaLdidDw4AnlzHDPt97sexDwfmKsl0pH/MI59eioQG7D +t81vdgbpWSZ5SAbImwotJoBN57UyWQHsRAzxUaMx9z5E2VuTcIh7AXRHLA+kqSjrp k2nd/v0pqG8jW5McQZAME8OiOlAA8iCmuePJUsBk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id E8727395BC70 for ; Wed, 16 Nov 2022 15:34:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E8727395BC70 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2F60C2209A for ; Wed, 16 Nov 2022 15:34:21 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1EE2513480 for ; Wed, 16 Nov 2022 15:34:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id s5yZBv0CdWNqcQAAMHmgww (envelope-from ) for ; Wed, 16 Nov 2022 15:34:21 +0000 Date: Wed, 16 Nov 2022 16:34:20 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/107686 - fix bitfield ref through vec_unpack optimization MIME-Version: 1.0 Message-Id: <20221116153421.1EE2513480@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The following propely restricts the bitfield access to integral types when we look through VEC_UNPACK with the intent to emit a widening conversion. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. 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. --- gcc/testsuite/gcc.dg/pr107686.c | 16 ++++++++++++++++ gcc/tree-ssa-forwprop.cc | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr107686.c 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 7c7942600ef..429f77f199c 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3162,7 +3162,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;