From patchwork Tue Nov 22 11:05:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 24268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2133857wrr; Tue, 22 Nov 2022 03:06:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5mq2+kj0RW+4c4EiaXc8dQMF/dXjQOQTZG0TzIMejpKHmcQKio+3vt1TBCZSJLgMt3NMHo X-Received: by 2002:a17:907:9190:b0:78a:52bb:d904 with SMTP id bp16-20020a170907919000b0078a52bbd904mr3152837ejb.630.1669115191437; Tue, 22 Nov 2022 03:06:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669115191; cv=none; d=google.com; s=arc-20160816; b=WhOz/+N45alel4uDQRUpQjg/MdUTeJBAiTKCiF1istNVLzujlCB+FnXrrLlVI2Trp4 rPEopPzaO8FCIl7JqU2CHCVfQjKJFplAzF/pXt/UJQbYascSUnIpA7ZvXtdcIizMrPsR LP5XgwaMcJsYgCKYNgsMZEfgNL5KfnZlKsaMIm4tRC6STrwetU0Q1uvjxNi7eiKrU1l+ dFqldsM6HU4ZUCNdwxFL/DFnTj0SgmkFNmwgR8USXJNu7V/uu07ZvpPGz/L1H1vX2sPQ 2eZddgBVKm5CykpUDiEq74kplbTErTPuwNjqiSNYK/rXWWTdZNizWbjl0gR0lh2zR2A7 rwrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=qwLH/pssA/TjD9TEOgGCoVLY3HR1bIIyatpuLTQmh0U=; b=kQUB2KBM8N8Azq742EN4tdIytLh0SBJ22WAkpcmWgRka27ykccT+k7GPTJEjBESN2Z tLw8MUEWu+sEaukWOeCHIEIz+vMV+irplo9hZyMvfeqc1P10mT3JMZl2z1AIVt0/1MEl QaNEGKuAG4MSDLpIKT/oeLXdXBnQsCQQIs5MpAAunEwmkx3+9NG9wf/FdxL97xk2UPZX uS/C3zZb+Jr4n1ZWcSM41Vwuu2d4eYe1Ur8TxKmDaAM8DxUZlH/Fl3yAnfftnpabYlBq hVUEUPRrWMxjPmF5HVEcZEsivNdr4TNsEfZCvhfUtC80fLpsdOYZf/iGPHcQ4SPDKvh4 5Vdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kwspohPU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c13-20020a170906170d00b007a92b00c075si9141005eje.891.2022.11.22.03.06.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 03:06:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kwspohPU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E80463858289 for ; Tue, 22 Nov 2022 11:06:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E80463858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669115164; bh=qwLH/pssA/TjD9TEOgGCoVLY3HR1bIIyatpuLTQmh0U=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kwspohPUP1yhqocRLXF5a7kr7XRcUOfc3IOQCKc8O8MDdp/P+QfNhqQ97HNKH4Qvs 7fiZPXaGta1RjSxwmgAMVJFts3utd1NDQX0xRpEz4hTa2fJf60hMX3Z3JeFpHWioz0 ADiBDzd1HgUBtoc6F67tq6LjG7N9Luo1b+VjAOJA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 4F9DF3858D20 for ; Tue, 22 Nov 2022 11:05:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F9DF3858D20 Received: by mail-wr1-x435.google.com with SMTP id n3so7594968wrp.5 for ; Tue, 22 Nov 2022 03:05:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qwLH/pssA/TjD9TEOgGCoVLY3HR1bIIyatpuLTQmh0U=; b=tXn8KGFqoCGgzkkz9brCq9h4RLDucVpq9D5aHkc8JNpBRq8/hNIAKKD2C3qpAa/Uoc HOsxO6kaf3euJ6Vb4uYgBInVhbWjz2WL199EdshEu2QrqIjcKrN+MWe+DeT5gqivLytR oQp2daZ1UlE3NzlSKwxaS2Eh1U0+WKUXjGL+9P4dYelfFCn/Ef/NVU3QayeC7BfLA0Vp qjleAaW+ok6BbMlcHIhnE+zPZW60FAWitqdIsoHmWEPuCBReRT0DbcQVLGPW2dWgr3D+ pihxwidAVqVCi0//Yq8Snxt/kWJi30OQf3sTzh1ph4rO2FswdDjayNOu308Owby+I1f6 3Rhw== X-Gm-Message-State: ANoB5plHzOi0p72pcR620U9yt0O3QLGt1IFGF7u0Xw4Q21FajCuf5Uxt /odXNW7TXt9CJiub+tWvnDvfrNupKWGCRw== X-Received: by 2002:a5d:48cf:0:b0:236:4983:285f with SMTP id p15-20020a5d48cf000000b002364983285fmr13835897wrs.576.1669115117642; Tue, 22 Nov 2022 03:05:17 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id c12-20020adffb4c000000b0022a3a887ceasm13683157wrs.49.2022.11.22.03.05.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 03:05:16 -0800 (PST) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix wrong array type conversion with different storage order Date: Tue, 22 Nov 2022 12:05:16 +0100 Message-ID: <4442231.LvFx2qVVIh@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750194130979614253?= X-GMAIL-MSGID: =?utf-8?q?1750194130979614253?= Hi, when two arrays of scalars have a different storage order in Ada, the front-end makes sure that the conversion is performed component-wise so that each component can be reversed. So it's a little bit counter productive that the ldist pass performs the opposite transformation and synthesizes a memcpy/memmove in this case. Tested on x86-64/Linux, OK for the mainline? 2022-11-22 Eric Botcazou * tree-loop-distribution.cc (loop_distribution::classify_builtin_ldst): Bail out if source and destination do not have the same storage order. 2022-11-22 Eric Botcazou * gnat.dg/sso18.adb: New test. diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index ed3dd73e1a9..15ae2410861 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -1790,10 +1790,15 @@ loop_distribution::classify_builtin_ldst (loop_p loop, struct graph *rdg, if (res != 2) return; - /* They much have the same access size. */ + /* They must have the same access size. */ if (!operand_equal_p (size, src_size, 0)) return; + /* They must have the same storage order. */ + if (reverse_storage_order_for_component_p (DR_REF (dst_dr)) + != reverse_storage_order_for_component_p (DR_REF (src_dr))) + return; + /* Load and store in loop nest must access memory in the same way, i.e, their must have the same steps in each loop of the nest. */ if (dst_steps.length () != src_steps.length ())