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: 60968 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 A9AB438518BC for ; Tue, 22 Nov 2022 11:05:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9AB438518BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669115149; 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=QxrccV9yvczLBL7SVORMl6B66rpdo2PFXMH8VOY4psvSeuysgPr07hayq6y4OV/bC 5Jauc9RMqhFXcLFkJnuNC2BwY+qnKTIHejH5BQYXFwz8ww0bgE0FFM0DQThVbKoHHz LVGxzP+P3WNxhqD5Cma22xXXGx+cycn0jKnVPYqU= 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-Google-Smtp-Source: AA0mqf5ZfIhaHE25pqEgz3SPyYPjHckxNEWgl4tnIOIezIpkfh6ZSUbO+GqOu53ogLxPYKdP/gnm6A== 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 ())