From patchwork Thu Jan 19 20:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 45950 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp520710wrn; Thu, 19 Jan 2023 12:05:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUR/L1SAlidNeP5E0rfEFaJ8R1TJm2/14ZggoveEqHgPP3rESwIT1v9eux1mZ74zE0XqaF X-Received: by 2002:a05:6402:27cf:b0:46b:4011:9863 with SMTP id c15-20020a05640227cf00b0046b40119863mr16404339ede.39.1674158719084; Thu, 19 Jan 2023 12:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674158719; cv=none; d=google.com; s=arc-20160816; b=JsdkJkwQhb3ru8qNydm5ybB4nnqIsryoImxGCEPKa6LKvmS9v0RNJAFrd0HrG+Eh/L CE0ePmk6Uqv+8Zvn73plm1rzWegsx7J+honKudbb8M/52vCTHSvhJzAYzzxghNILdFnj 9AESNWgn8DM5DDpGnu9ZhT16Kvfn627jVXVU0Aweb7zoQsPeNAKHXKYnuECsoDRItqDt cDhpGB1iouvofTAG+F+Pc4818h/NVMdYyr1JpPdDv8V4Uc5vHFw5wkI+czX2vc62fq5y 2pLUkOHsfRWMIIzMyPeIuUWzg2N1S58Emj7Ko0OVYyRYBWN9uRACFZlWwaXubVqbc5Ek zG8A== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=h+QETljPNdvkQxGGuNtDyy0eIC6Djs77rzQlVjLNqA0=; b=odbexCaxHk6b5LmfWPitIYSq9dyLRzK4ZbQN1rrhLWD46Wh0YJcYA4GmB1KqO5bSg0 y7N6sgcXtmf2+xZvV6U/86lMwewtcvpPyhwPdYYOfz3Cw/I/g/RXn74dvK6oMXD+m573 yL3xxfNSaa02yLoM1tnVhkA6Si2HiMSAkbZJZsEuuRZPmPH4X0W9Kvv+pNXfXZvxD2BE 9cbVGbQSkpKVhOZ05W7BNE33nfYupU3+3nNiH/4NCroUWCvO71mF/H0PmaS9NAGuYzoE BQgHS8mq+PGvkuG8I3MDAsYqovL3peHVH2/TZ2RdSVDh7dSW6JzQlaHjFGI/AfynF2LR f1/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ld8Z7ohE; 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 by8-20020a0564021b0800b0049d0890542fsi19209235edb.364.2023.01.19.12.05.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 12:05:19 -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=Ld8Z7ohE; 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 DE066385841D for ; Thu, 19 Jan 2023 20:05:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE066385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674158717; bh=h+QETljPNdvkQxGGuNtDyy0eIC6Djs77rzQlVjLNqA0=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Ld8Z7ohE+4htENtcyjwzJTbuQkTKeQbHJaFbmue6sTDuujXpy3+ZXuub9Lfogy4o/ RSJKax7UtnK5XJYboVIJI4PnnSfBt5uPs4BUSv1R7xixKJOj8briTCt+z59Nqymdov tRStLAFza6KGX11FRtBjs434Ch9iOeByyLYo5ks0= 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C3D203858291 for ; Thu, 19 Jan 2023 20:04:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3D203858291 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-4wNuO6_aNxaj45bsuKCOGw-1; Thu, 19 Jan 2023 15:04:32 -0500 X-MC-Unique: 4wNuO6_aNxaj45bsuKCOGw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 172EA3C1069E; Thu, 19 Jan 2023 20:04:32 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB6C440C2064; Thu, 19 Jan 2023 20:04:31 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30JK4SDr3366224 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 19 Jan 2023 21:04:29 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30JK4RUP3366223; Thu, 19 Jan 2023 21:04:27 +0100 Date: Thu, 19 Jan 2023 21:04:27 +0100 To: gcc-patches@gcc.gnu.org Cc: Tobias Burnus Subject: [committed] openmp: Fix up OpenMP expansion of non-rectangular loops [PR108459] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1755482652997562824?= X-GMAIL-MSGID: =?utf-8?q?1755482652997562824?= Hi! expand_omp_for_init_counts was using for the case where collapse(2) inner loop has init expression dependent on non-constant multiple of the outer iterator and the condition upper bound expression doesn't depend on the outer iterator fold_unary (NEGATE_EXPR, ...). This will just return NULL if it can't be folded, we need fold_build1 instead. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2023-01-19 Jakub Jelinek PR middle-end/108459 * omp-expand.cc (expand_omp_for_init_counts): Use fold_build1 rather than fold_unary for NEGATE_EXPR. * testsuite/libgomp.c/pr108459.c: New test. Jakub --- gcc/omp-expand.cc.jj 2023-01-02 09:32:49.399894958 +0100 +++ gcc/omp-expand.cc 2023-01-19 12:01:05.103410564 +0100 @@ -2003,8 +2003,8 @@ expand_omp_for_init_counts (struct omp_f t = fold_build2 (MINUS_EXPR, itype, unshare_expr (fd->loops[i].m2), unshare_expr (fd->loops[i].m1)); else if (fd->loops[i].m1) - t = fold_unary (NEGATE_EXPR, itype, - unshare_expr (fd->loops[i].m1)); + t = fold_build1 (NEGATE_EXPR, itype, + unshare_expr (fd->loops[i].m1)); else t = unshare_expr (fd->loops[i].m2); tree m2minusm1 --- libgomp/testsuite/libgomp.c/pr108459.c.jj 2023-01-19 12:22:07.191038771 +0100 +++ libgomp/testsuite/libgomp.c/pr108459.c 2023-01-19 12:21:17.973755215 +0100 @@ -0,0 +1,41 @@ +/* PR middle-end/108459 */ + +char a[17][17]; + +__attribute__((noipa)) void +foo (int x, int y) +{ + #pragma omp for collapse(2) + for (int i = 1; i <= 16; i++) + for (int j = i * x + y; j <= 16; j++) + a[i][j] = 1; +} + +int +main () +{ + #pragma omp parallel + foo (1, 1); + for (int i = 0; i <= 16; i++) + for (int j = 0; j <= 16; j++) + if (i >= 1 && j >= i + 1) + { + if (a[i][j] != 1) + __builtin_abort (); + a[i][j] = 0; + } + else if (a[i][j]) + __builtin_abort (); + #pragma omp parallel + foo (2, -2); + for (int i = 0; i <= 16; i++) + for (int j = 0; j <= 16; j++) + if (i >= 1 && j >= 2 * i - 2) + { + if (a[i][j] != 1) + __builtin_abort (); + } + else if (a[i][j]) + __builtin_abort (); + return 0; +}