From patchwork Mon Oct 25 12:00:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 46609 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 596763858003 for ; Mon, 25 Oct 2021 12:08:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 596763858003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635163698; bh=KOwWS//Ze+sL/XeaRvY7SffkEJmmo7zxJ6eY/IlwaQA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=P2VVo+y56jsd94ktmTBhjcLuXWwVvkCIXBr7Fxuqp4Qxw7s6Xdh1tupQl6vqp+RQD yrrzXdyRaobqz1A+YnrlroLft/LUfq14PYEJAk6qCnifzbW9H0G2gdXNg7gaCU095R WPTHexfHc0BAsRfz6Y6nF4wPQKlmJ8bR7e5CUE1Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D6A3E3858410 for ; Mon, 25 Oct 2021 12:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6A3E3858410 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 80D69D6E; Mon, 25 Oct 2021 05:00:52 -0700 (PDT) Received: from [10.57.23.87] (unknown [10.57.23.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F12533F5A1; Mon, 25 Oct 2021 05:00:51 -0700 (PDT) Message-ID: <53802562-2e6b-ea67-0f97-a32126702593@arm.com> Date: Mon, 25 Oct 2021 13:00:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US To: "gcc-patches@gcc.gnu.org" Subject: [Aarch64] Fix alignment of neon loads & stores in gimple X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "Andre Vieira \(lists\) via Gcc-patches" From: "Andre Vieira (lists)" Reply-To: "Andre Vieira \(lists\)" Cc: Richard Sandiford Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This fixes the alignment on the memory access type for neon loads & stores in the gimple lowering. Bootstrap ubsan on aarch64 builds again with this change. 2021-10-25  Andre Vieira  gcc/ChangeLog:         * config/aarch64/aarch64-builtins.c (aarch64_general_gimple_fold_builtin): Fix memory access         type alignment. Is this OK for trunk? Kind regards, Andre diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index a815e4cfbccab692ca688ba87c71b06c304abbfb..f5436baf5f8a65c340e05faa491d86a7847c37d3 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -2490,12 +2490,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt, gimple_seq stmts = NULL; tree base = gimple_convert (&stmts, elt_ptr_type, args[0]); + /* Use element type alignment. */ + tree access_type + = build_aligned_type (simd_type.itype, + TYPE_ALIGN (TREE_TYPE (simd_type.itype))); if (stmts) gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); new_stmt = gimple_build_assign (gimple_get_lhs (stmt), fold_build2 (MEM_REF, - simd_type.itype, + access_type, base, zero)); } break; @@ -2512,13 +2516,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt, gimple_seq stmts = NULL; tree base = gimple_convert (&stmts, elt_ptr_type, args[0]); + /* Use element type alignment. */ + tree access_type + = build_aligned_type (simd_type.itype, + TYPE_ALIGN (TREE_TYPE (simd_type.itype))); if (stmts) gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); new_stmt - = gimple_build_assign (fold_build2 (MEM_REF, - simd_type.itype, - base, - zero), args[1]); + = gimple_build_assign (fold_build2 (MEM_REF, access_type, + base, zero), + args[1]); } break;