From patchwork Tue Nov 12 00:06:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1193205 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-513017-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="DWZ6QZbO"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Bdm7+xSm"; 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 47Bp2p0HQzz9sPF for ; Tue, 12 Nov 2019 11:07:13 +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=eQr PTbgcukjaWPaNG2+Gipx6CJI3WlLu10nHuKsCjb+n0iVCTRigyFez5KfLy+LWBPW ES+ftSu+d5WVvcQeP/GYEOzxTA5fIhHguD7ViPxey04BGARuit7mekqKOD/dqnMc Xm7eJTJXrI9i6ha4yDTDtLTiJXPnWH7o9TxvlQIE= 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=t/pZuNkmS 0H3JFszwUJ0OZQDHmw=; b=DWZ6QZbO7ADihgbOPKKBeDvEmi3Psiqe0DV8eHNpc MLkFTCKRUz5V8havGaHU1vw+OxzqSfoZkXK0AurFSY3thbPZhiYjstsv70Gp9PLb EoBWkPZgqNyemZTdg0OsQ9SJyF2EWy+3JQJGPC3KaPsWTHwcapLBFaxOI5m7Yknu WE= Received: (qmail 117516 invoked by alias); 12 Nov 2019 00:07:06 -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 117505 invoked by uid 89); 12 Nov 2019 00:07:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL, BAYES_00, FUZZY_PRICES, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:UNKNOWN, sk:unknown 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; Tue, 12 Nov 2019 00:07:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573517223; 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=PhNtXkkwEYnc/PtajNUnq9q+kms322mE7IijAtmEkfo=; b=Bdm7+xSmHLWbz8eYacqRIZKW7JTj9ZeDV3iUNQ7Fd9S1ZhifAUzi0jek9lTMNq1G6fesMQ ncuG1XRMzPgEY6P9PiC0yRo9v0b0adbRCt/Gfh66mrRt5rg9JLPvDrILTcAN6wSo8UE1Cm X2rE9RUht65YcL7LQfPKbrGIXY+l4GQ= 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-325-YQUMr2LyMzCdwSgaQn5krw-1; Mon, 11 Nov 2019 19:07:00 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D774BDB20; Tue, 12 Nov 2019 00:06:59 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FAED61072; Tue, 12 Nov 2019 00:06:59 +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 xAC06vnn010324; Tue, 12 Nov 2019 01:06:57 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xAC06tvt010323; Tue, 12 Nov 2019 01:06:55 +0100 Date: Tue, 12 Nov 2019 01:06:55 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid *ORDERED_EXPRs in the IL if !HONOR_NANS (PR target/92449) Message-ID: <20191112000655.GD4650@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! The testcase from the PR ICEs on rs6000. For __builtin_isunordered etc. the folding makes sure that there is no *ORDERED_EXPR etc. in the IL if !HONOR_NANS, but the complex multiplication can emit it when mixing -Ofast with -fno-cx-limited-range. The following patch makes sure we don't emit it even in that case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? I'll defer the addition of the testcase and rs6000 changes to Segher. 2019-11-11 Jakub Jelinek PR target/92449 * tree-complex.c (expand_complex_multiplication): If !HONOR_NANS, don't emit UNORDERED_EXPR guarded libcall. Formatting fixes. Jakub --- gcc/tree-complex.c.jj 2019-01-10 11:43:02.252577041 +0100 +++ gcc/tree-complex.c 2019-11-11 20:26:28.585315282 +0100 @@ -1144,6 +1144,16 @@ expand_complex_multiplication (gimple_st return; } + if (!HONOR_NANS (inner_type)) + { + /* If we are not worrying about NaNs expand to + (ar*br - ai*bi) + i(ar*bi + br*ai) directly. */ + expand_complex_multiplication_components (gsi, inner_type, + ar, ai, br, bi, + &rr, &ri); + break; + } + /* Else, expand x = a * b into x = (ar*br - ai*bi) + i(ar*bi + br*ai); if (isunordered (__real__ x, __imag__ x)) @@ -1151,7 +1161,7 @@ expand_complex_multiplication (gimple_st tree tmpr, tmpi; expand_complex_multiplication_components (gsi, inner_type, ar, ai, - br, bi, &tmpr, &tmpi); + br, bi, &tmpr, &tmpi); gimple *check = gimple_build_cond (UNORDERED_EXPR, tmpr, tmpi, @@ -1167,13 +1177,12 @@ expand_complex_multiplication (gimple_st = insert_cond_bb (gsi_bb (*gsi), gsi_stmt (*gsi), check, profile_probability::very_unlikely ()); - gimple_stmt_iterator cond_bb_gsi = gsi_last_bb (cond_bb); gsi_insert_after (&cond_bb_gsi, gimple_build_nop (), GSI_NEW_STMT); tree libcall_res = expand_complex_libcall (&cond_bb_gsi, type, ar, ai, br, - bi, MULT_EXPR, false); + bi, MULT_EXPR, false); tree cond_real = gimplify_build1 (&cond_bb_gsi, REALPART_EXPR, inner_type, libcall_res); tree cond_imag = gimplify_build1 (&cond_bb_gsi, IMAGPART_EXPR, @@ -1190,20 +1199,18 @@ expand_complex_multiplication (gimple_st edge orig_to_join = find_edge (orig_bb, join_bb); gphi *real_phi = create_phi_node (rr, gsi_bb (*gsi)); - add_phi_arg (real_phi, cond_real, cond_to_join, - UNKNOWN_LOCATION); + add_phi_arg (real_phi, cond_real, cond_to_join, UNKNOWN_LOCATION); add_phi_arg (real_phi, tmpr, orig_to_join, UNKNOWN_LOCATION); gphi *imag_phi = create_phi_node (ri, gsi_bb (*gsi)); - add_phi_arg (imag_phi, cond_imag, cond_to_join, - UNKNOWN_LOCATION); + add_phi_arg (imag_phi, cond_imag, cond_to_join, UNKNOWN_LOCATION); add_phi_arg (imag_phi, tmpi, orig_to_join, UNKNOWN_LOCATION); } else /* If we are not worrying about NaNs expand to (ar*br - ai*bi) + i(ar*bi + br*ai) directly. */ expand_complex_multiplication_components (gsi, inner_type, ar, ai, - br, bi, &rr, &ri); + br, bi, &rr, &ri); break; default: