From patchwork Thu Oct 15 13:18:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 530699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 0A74514010F for ; Fri, 16 Oct 2015 00:19:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=m/uv4QYY; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=stN3UyS+kayoHeLg 8dLiiyhEzKJL6Hcr2e2lWjI4UzA5AOj5s/qrx9dEpqZhJwncymC3NV0YkzzJ7EOC S2BO31sr4Tg5UhDPvGM2q/9et/DQsYKfPfrSopTLmMXFiME+oQmDc+wxD7nWvRzc AbVy9p8K0MWmBrMbRYnC8FRyc8k= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=cyuwpXTgC7dfxBLwEhThKE m0VNs=; b=m/uv4QYYSJ8vaeXF5cpsbyrivbb0W10BCELNLA+UHEpqzYKyxX+Xld 99rf6fBK51S4kmo6TJOPn1Ka0s8OQ5C5oa0K9sScXeCiXg1PqaYu9GPHW3oqaWJ9 Hap3V/yAgVqpUXHPrbpD9VkRJD0dyXFkBBOkf1Om6BJ8HRmLdJhig= Received: (qmail 120594 invoked by alias); 15 Oct 2015 13:19:07 -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 120574 invoked by uid 89); 15 Oct 2015 13:19:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Oct 2015 13:19:04 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-37-UVSGEOgrQBS-cy0rqhz1DQ-1; Thu, 15 Oct 2015 14:18:58 +0100 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 15 Oct 2015 14:18:58 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Split out some tests from builtins-20.c Date: Thu, 15 Oct 2015 14:18:58 +0100 Message-ID: <87h9lsi81p.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: UVSGEOgrQBS-cy0rqhz1DQ-1 Stripping unnecessary sign ops at the gimple level means that we're no longer able to optimise: if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y))) != cos(y<10 ? x : tan(x<20 ? x : y))) link_error (); because we're currently not able to fold away the equality in: int f1 (double x, double y) { double z1 = __builtin_cos(y<10 ? x : __builtin_tan(x<20 ? x : y)); double z2 = __builtin_cos(y<10 ? x : __builtin_tan(x<20 ? x : y)); return z1 == z2; } The missed fold is being tracked as PR 67975. This patch splits the test out into a separate file so that we can XFAIL it until the PR is fixed. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. OK to install? Thanks, Richard gcc/testsuite/ * gcc.dg/builtins-20.c: Move some tests to... * gcc.dg/builtins-86.c: ...this new file. diff --git a/gcc/testsuite/gcc.dg/builtins-20.c b/gcc/testsuite/gcc.dg/builtins-20.c index 2b63428..8288367 100644 --- a/gcc/testsuite/gcc.dg/builtins-20.c +++ b/gcc/testsuite/gcc.dg/builtins-20.c @@ -115,10 +115,6 @@ void test2(double x, double y) if (cos(y<10 ? x : -y) != cos(y<10 ? x : y)) link_error (); - if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y))) - != cos(y<10 ? x : tan(x<20 ? x : y))) - link_error (); - if (cos((y*=3, -x)) != cos((y*=3,x))) link_error (); @@ -343,10 +339,6 @@ void test2f(float x, float y) if (cosf(y<10 ? x : -y) != cosf(y<10 ? x : y)) link_error (); - if (cosf(y<10 ? -fabsf(x) : tanf(x<20 ? -x : -fabsf(y))) - != cosf(y<10 ? x : tanf(x<20 ? x : y))) - link_error (); - if (cosf((y*=3, -x)) != cosf((y*=3,x))) link_error (); @@ -570,10 +562,6 @@ void test2l(long double x, long double y) if (cosl(y<10 ? x : -y) != cosl(y<10 ? x : y)) link_error (); - if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y))) - != cosl(y<10 ? x : tanl(x<20 ? x : y))) - link_error (); - if (cosl((y*=3, -x)) != cosl((y*=3,x))) link_error (); diff --git a/gcc/testsuite/gcc.dg/builtins-86.c b/gcc/testsuite/gcc.dg/builtins-86.c new file mode 100644 index 0000000..f405124 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-86.c @@ -0,0 +1,56 @@ +/* Copyright (C) 2003-2015 Free Software Foundation. + + Split out from builtins-20.c, which has the comment: + + Verify that built-in math function constant folding doesn't break + anything and produces the expected results. + + Written by Roger Sayle, 8th June 2003. */ + +/* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */ + +#include "builtins-config.h" + +extern double cos (double); +extern double tan (double); +extern double fabs (double); +extern float cosf (float); +extern float tanf (float); +extern float fabsf (float); +extern long double cosl (long double); +extern long double tanl (long double); +extern long double fabsl (long double); + +extern void link_error(void); + +void test2(double x, double y) +{ + if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y))) + != cos(y<10 ? x : tan(x<20 ? x : y))) + link_error (); +} + +void test2f(float x, float y) +{ + if (cosf(y<10 ? -fabsf(x) : tanf(x<20 ? -x : -fabsf(y))) + != cosf(y<10 ? x : tanf(x<20 ? x : y))) + link_error (); +} + +void test2l(long double x, long double y) +{ + if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y))) + != cosl(y<10 ? x : tanl(x<20 ? x : y))) + link_error (); +} + +int main() +{ + test2 (1.0, 2.0); + test2f (1.0f, 2.0f); + test2l (1.0l, 2.0l); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */