From patchwork Tue Sep 5 21:36:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 810295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461543-incoming=patchwork.ozlabs.org@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.b="dK5B0vA+"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xn0RP18wdz9t2R for ; Wed, 6 Sep 2017 07:37:04 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=ZLzYxQzZ2FRinagBORaPJz5calWiDo1YNaAnABzPmLT tKKiNtJrBeKoJBS2TLLeFwEWnf8n0k0xPItToCtDnP5OGh+4+szLS7sF8AzidZ30 dD0xDTn7gIKOZ3ysOjJrOVsD37ovTYuGXoXjtg8LxoplmLJGDg6TSaDyp0KcHdl4 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=/+i2cr+lq4IdEFGtBkTni7exoo4=; b=dK5B0vA+hl5die8Ox seI7vC6QmfuLNuPQHHpidmvPsOF9Yd/lKqRxu2cunGnfct/awvpPRfzADeKQFzZR yZ3HCnK/YqusIO93om/arU/EjUlMskOOvllgrt5wiajY4ZZwbNBMnUSP1GnnosBH 9Xw5rgqvsBj3yKJG1ns3R02SY8= Received: (qmail 15914 invoked by alias); 5 Sep 2017 21:36:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14746 invoked by uid 89); 5 Sep 2017 21:36:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Sep 2017 21:36:51 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB6FA3F74D for ; Tue, 5 Sep 2017 21:36:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CB6FA3F74D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub@redhat.com Received: from tucnak.zalov.cz (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7510B5D6A3 for ; Tue, 5 Sep 2017 21:36:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v85LalFT002720 for ; Tue, 5 Sep 2017 23:36:47 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v85LakU0002719 for gcc-patches@gcc.gnu.org; Tue, 5 Sep 2017 23:36:46 +0200 Date: Tue, 5 Sep 2017 23:36:46 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix OpenMP simd expansion ICE (PR middle-end/81768) Message-ID: <20170905213646.GI2323@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! On the following testcase when trying to gimplify a COND_EXPR that we expect to stay a COND_EXPR in GIMPLE, the gimplifier actually produces code with branches and labels, which is of course invalid inside of a bb. The reason for that is that a former global VAR_DECL is being replaced through DECL_VALUE_EXPR with a target mapping thereof and so is considered as potentially trapping. Fixed by pre-gimplifying the operand. Bootstrapped/regtested on x86_64-linux and i686-linux, committed so far to trunk. 2017-09-05 Jakub Jelinek PR middle-end/81768 * omp-expand.c (expand_omp_simd): Force second operands of COND_EXPR into gimple val before gimplification fo the COND_EXPR. * gcc.dg/gomp/pr81768-1.c: New test. Jakub --- gcc/omp-expand.c.jj 2017-09-01 09:26:27.000000000 +0200 +++ gcc/omp-expand.c 2017-09-05 13:13:49.303159003 +0200 @@ -4730,24 +4730,28 @@ expand_omp_simd (struct omp_region *regi tree itype2 = TREE_TYPE (fd->loops[i - 1].v); if (POINTER_TYPE_P (itype2)) itype2 = signed_type_for (itype2); + t = fold_convert (itype2, fd->loops[i - 1].step); + t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, + GSI_SAME_STMT); t = build3 (COND_EXPR, itype2, build2 (fd->loops[i].cond_code, boolean_type_node, fd->loops[i].v, fold_convert (itype, fd->loops[i].n2)), - build_int_cst (itype2, 0), - fold_convert (itype2, fd->loops[i - 1].step)); + build_int_cst (itype2, 0), t); if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i - 1].v))) t = fold_build_pointer_plus (fd->loops[i - 1].v, t); else t = fold_build2 (PLUS_EXPR, itype2, fd->loops[i - 1].v, t); expand_omp_build_assign (&gsi, fd->loops[i - 1].v, t); + t = fold_convert (itype, fd->loops[i].n1); + t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, + GSI_SAME_STMT); t = build3 (COND_EXPR, itype, build2 (fd->loops[i].cond_code, boolean_type_node, fd->loops[i].v, fold_convert (itype, fd->loops[i].n2)), - fd->loops[i].v, - fold_convert (itype, fd->loops[i].n1)); + fd->loops[i].v, t); expand_omp_build_assign (&gsi, fd->loops[i].v, t); } } --- gcc/testsuite/gcc.dg/gomp/pr81768-1.c.jj 2017-09-05 13:59:57.821977911 +0200 +++ gcc/testsuite/gcc.dg/gomp/pr81768-1.c 2017-09-05 13:50:24.000000000 +0200 @@ -0,0 +1,15 @@ +/* PR middle-end/81768 */ +/* { dg-do compile } */ + +float b[10][15][10]; + +void +foo (void) +{ + float *i; +#pragma omp target parallel for simd schedule(static, 32) collapse(3) + for (i = &b[0][0][0]; i < &b[0][0][10]; i++) + for (float *j = &b[0][15][0]; j > &b[0][0][0]; j -= 10) + for (float *k = &b[0][0][10]; k > &b[0][0][0]; --k) + b[i - &b[0][0][0]][(j - &b[0][0][0]) / 10 - 1][(k - &b[0][0][0]) - 1] -= 3.5; +}