From patchwork Thu Dec 12 00:05:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1208022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515753-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Bowc2DPQ"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="gi5Vpohu"; 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 47YDb45pLzz9sPf for ; Thu, 12 Dec 2019 11:05:36 +1100 (AEDT) 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:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=pVf /GTJv/Tl6LENCVIyCL0r5kO4a+/Y/Um2oAgI9RuKItfsoDC7/T0y1CsPmpkkvVFd Fc6yG0LFq2YJE88wE+nUlj0p+UWF4FsvyQML2OTfUXftJl0s8V8oW76f5sNZtAfP IHKCfTKC2wBxo3TsJE4a1kwkVRArUAyFx+EtTncA= 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:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=PajY8jRWf /un4mMX2ONgsv9k6l4=; b=Bowc2DPQuEQwKIhUctqdwj3OHBI1w50n6PQjS9IGN giWNMweMdwOP6DzPN2qqeJp8SIhFZNzHQdUIJvvEtgZXGqqPxE6bCAjN2pBkZOm3 VogNord5JydLWBplXfQWShu2t0IutiwcV6KqUP0ILeNIim9xAi5adJ3uhD6gdU8r ac= Received: (qmail 94573 invoked by alias); 12 Dec 2019 00:05:30 -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 94563 invoked by uid 89); 12 Dec 2019 00:05:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2019 00:05:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576109127; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iotncdHtussRH6qvnAL18xlyfNusmucwMCWaK/MkhWk=; b=gi5Vpohuv4vhOVrZCkyLtXqDcCl4FH1x9XMLXNtFpaxsZPfaw/mFyfH6ddqljZ0nvXyTQO OalDEk2UOsmn3zrwLqapqIkWbvfOQcF7W90m0UC0noC3/+xTslx35956rDaHz9d1PKCxIF ZMCPIQG+baJJEOTZhCbNKw4m8PcDPlg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-FsuQFws8PC6O91c2wZnP8g-1; Wed, 11 Dec 2019 19:05:25 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60C18800EC0; Thu, 12 Dec 2019 00:05:24 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB9935C1C3; Thu, 12 Dec 2019 00:05:23 +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 xBC05L8S027241; Thu, 12 Dec 2019 01:05:22 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xBC05LuC027240; Thu, 12 Dec 2019 01:05:21 +0100 Date: Thu, 12 Dec 2019 01:05:21 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: fortran@gcc.gnu.org Subject: [committed] Fix OpenMP fortran atomic swap with casts (PR fortran/92899) Message-ID: <20191212000521.GA10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! My PR77500 fix apparently broke the following testcase, while atomic swaps are handled in many ways similarly to atomic writes, in this conditional which is the first one in atomic swap we actually need to look through the conversions. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for 9/8 backports. 2019-12-11 Jakub Jelinek PR fortran/92899 * trans-openmp.c (gfc_trans_omp_atomic): For GFC_OMP_ATOMIC_SWAP, do look through conversion on expr2 if any. * testsuite/libgomp.fortran/atomic1.f90: New test. Jakub --- gcc/fortran/trans-openmp.c.jj 2019-12-09 19:50:25.580940368 +0100 +++ gcc/fortran/trans-openmp.c 2019-12-11 17:14:42.706119406 +0100 @@ -3534,7 +3534,6 @@ gfc_trans_omp_atomic (gfc_code *code) expr2 = code->expr2; if (((atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_MASK) != GFC_OMP_ATOMIC_WRITE) - && (atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_SWAP) == 0 && expr2->expr_type == EXPR_FUNCTION && expr2->value.function.isym && expr2->value.function.isym->id == GFC_ISYM_CONVERSION) --- libgomp/testsuite/libgomp.fortran/atomic1.f90.jj 2019-12-11 17:10:33.118950283 +0100 +++ libgomp/testsuite/libgomp.fortran/atomic1.f90 2019-12-11 17:09:46.324668521 +0100 @@ -0,0 +1,46 @@ +! PR fortran/92899 + +program pr92899 + real :: x = 1.0 + double precision :: y + integer(kind=4) :: z = 4 + integer(kind=8) :: w + !$omp atomic capture + y = x + x = 2.0 + !$omp end atomic + if (y /= 1.0 .or. x /= 2.0) stop 1 + !$omp atomic capture + x = y + y = 3.0 + !$omp end atomic + if (x /= 1.0 .or. y /= 3.0) stop 2 + !$omp atomic capture + w = z + z = 5 + !$omp end atomic + if (w /= 4 .or. z /= 5) stop 3 + !$omp atomic capture + z = w + w = 6 + !$omp end atomic + if (z /= 4 .or. w /= 6) stop 4 + !$omp atomic write + x = y + !$omp end atomic + if (x /= 3.0 .or. y /= 3.0) stop 5 + x = 7.0 + !$omp atomic write + y = x + !$omp end atomic + if (x /= 7.0 .or. y /= 7.0) stop 6 + !$omp atomic write + z = w + !$omp end atomic + if (z /= 6 .or. w /= 6) stop 7 + z = 8 + !$omp atomic write + w = z + !$omp end atomic + if (z /= 8 .or. w /= 8) stop 8 +end