From patchwork Sat Apr 3 07:57:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1461963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VgIZs57R; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FC8Qx6xW2z9sPf for ; Sat, 3 Apr 2021 18:57:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55A4D385782C; Sat, 3 Apr 2021 07:57:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55A4D385782C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1617436647; bh=XUX7NWFmU2iZulA4ZCsGhWQYUWQlpx7XK5GNFk4ZZUs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=VgIZs57ROCG8VA7JkDdjHONqUVL7jc3+Fa+PHhTSSwb78dmX5V/8MYpfTqXhdvF6G FCWGv6l6FVuBQxfmXkgetHaIcyMt3fsc1bV7PlkpZc7CF3ZGWFkCVAqL5TY24w76lL 9zf2WZWBTSlEZOmIHNiOcvuNqO4l4B08EEV5pLc8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 8DB24385781B for ; Sat, 3 Apr 2021 07:57:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8DB24385781B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-BH7JALiYNdC6TEOHohPRPg-1; Sat, 03 Apr 2021 03:57:22 -0400 X-MC-Unique: BH7JALiYNdC6TEOHohPRPg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED6051853020; Sat, 3 Apr 2021 07:57:21 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-95.ams2.redhat.com [10.36.112.95]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96BF16C353; Sat, 3 Apr 2021 07:57:21 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1337vJ4K1716371 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 3 Apr 2021 09:57:19 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1337vIFY1716370; Sat, 3 Apr 2021 09:57:18 +0200 Date: Sat, 3 Apr 2021 09:57:18 +0200 To: Richard Biener Subject: [PATCH] bswap: Fix up bswap_view_convert after the recent change [PR99882] Message-ID: <20210403075718.GI1179226@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! Martin reported that my recent change to allow pointer types in bswap broke valgrind. The bswap_view_convert function used for the initialization of vector CONSTRUCTOR from the identity or byte-swapped pieces unfortunately didn't handle pointer types. The following patch handles it there. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-04-03 Jakub Jelinek PR tree-optimization/99882 * gimple-ssa-store-merging.c (bswap_view_convert): Handle val with pointer type. * gcc.dg/pr99882.c: New test. Jakub --- gcc/gimple-ssa-store-merging.c.jj 2021-04-01 10:50:56.238629197 +0200 +++ gcc/gimple-ssa-store-merging.c 2021-04-02 16:52:38.763803716 +0200 @@ -985,10 +985,19 @@ public: static tree bswap_view_convert (gimple_stmt_iterator *gsi, tree type, tree val) { - gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (val))); + gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (val)) + || POINTER_TYPE_P (TREE_TYPE (val))); if (TYPE_SIZE (type) != TYPE_SIZE (TREE_TYPE (val))) { HOST_WIDE_INT prec = TREE_INT_CST_LOW (TYPE_SIZE (type)); + if (POINTER_TYPE_P (TREE_TYPE (val))) + { + gimple *g + = gimple_build_assign (make_ssa_name (pointer_sized_int_node), + NOP_EXPR, val); + gsi_insert_before (gsi, g, GSI_SAME_STMT); + val = gimple_assign_lhs (g); + } tree itype = build_nonstandard_integer_type (prec, 1); gimple *g = gimple_build_assign (make_ssa_name (itype), NOP_EXPR, val); gsi_insert_before (gsi, g, GSI_SAME_STMT); --- gcc/testsuite/gcc.dg/pr99882.c.jj 2021-04-02 20:52:09.895060892 +0200 +++ gcc/testsuite/gcc.dg/pr99882.c 2021-04-02 20:51:39.590396850 +0200 @@ -0,0 +1,37 @@ +/* PR tree-optimization/99882 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void +foo (char *p, void *q) +{ + __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q; + p[2] = i; + i >>= 8; + p[3] = i; + i >>= 8; + p[4] = i; + i >>= 8; + p[5] = i; + i >>= 8; + p[6] = i; + i >>= 8; + p[7] = i; + i >>= 8; + p[8] = i; + i >>= 8; + p[9] = i; +} + +void +bar (char *p, void *q) +{ + __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q; + p[2] = i; + i >>= 8; + p[3] = i; + i >>= 8; + p[4] = i; + i >>= 8; + p[5] = i; +}