From patchwork Thu Jan 14 16:52:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 567601 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 9BDAE140662 for ; Fri, 15 Jan 2016 03:52:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=tEMFyfz8; 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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=RqBp96J/yjakNrk8hY4lrPxI33xmo0f5maj75gGXmSkznw JhZSbYTZpdGYcboWaAa+ODPsKu3XzOK6zXHsgv9UekSQC8dZL1J5uCBAvdpzMSiu c6/kjnrD4tiRKiDoG1Ho/dkhmBLOxwjKt0YAbsdR6GivIq3MLH/ISLRV3rTqM= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Lg5HgjlQMXbZkQfKH1Wl93Vh4Pk=; b=tEMFyfz84Bl+ewpjJXit YSicZYWl7yjxH8NGXfMpODZAYRc89Qc2dIUXFPq/cqEQmJkQ0lynY2o3mmOIr6ae iro61LyW9aw0/y/TCnkE9Oez/RmSPwwXY89BZT1dZCSyJtmu14yuSbKuKV7BoXow qnwglhyKk2r8Wcb9VKhcrGg= Received: (qmail 5695 invoked by alias); 14 Jan 2016 16:52:14 -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 5681 invoked by uid 89); 14 Jan 2016 16:52:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=const_int_p, CONST_INT_P, complement, orr X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Jan 2016 16:52:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 061FD49 for ; Thu, 14 Jan 2016 08:51:33 -0800 (PST) Received: from [10.2.206.200] (e100706-lin.cambridge.arm.com [10.2.206.200]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A86763F246 for ; Thu, 14 Jan 2016 08:52:08 -0800 (PST) Message-ID: <5697D237.9050207@foss.arm.com> Date: Thu, 14 Jan 2016 16:52:07 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches Subject: [PATCH][ARM][4.9 backport] Fix PR target/68648 Hi all, This the 4.9 backport of https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00708.html. The gcc change is the same, but the testcase is put into gcc.dg/torture rather than gcc.c-torture/execute. This is because the testcase actually requires a -std=gnu99, and adding a dg-options in execute.exp doesn't seem to work (it gets ignored). On GCC 5 we default to the required -std level already, so we don't need the option there. In gcc.dg/torture dg-options works and the testcase behaves as expected. I'm committing this to the 4.9 branch and we can close this PR (I've already done the GCC 5 backport) Thanks, Kyrill 2016-01-14 Kyrylo Tkachov PR target/68648 * config/arm/arm.md (*andsi_iorsi3_notsi): Try to simplify the complement of operands[3] during splitting. 2016-01-14 Kyrylo Tkachov PR target/68648 * gcc.dg/torture/pr68648.c: New test. diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 3bb8aef36f7ed54faeeb05f4b2b9825d96162f54..138d17e8d7dec2c38c4daa531b46be3e0ce88cea 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -3331,8 +3331,22 @@ (define_insn_and_split "*andsi_iorsi3_notsi" "#" ; "orr%?\\t%0, %1, %2\;bic%?\\t%0, %0, %3" "&& reload_completed" [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2))) - (set (match_dup 0) (and:SI (not:SI (match_dup 3)) (match_dup 0)))] - "" + (set (match_dup 0) (and:SI (match_dup 4) (match_dup 5)))] + { + /* If operands[3] is a constant make sure to fold the NOT into it + to avoid creating a NOT of a CONST_INT. */ + rtx not_rtx = simplify_gen_unary (NOT, SImode, operands[3], SImode); + if (CONST_INT_P (not_rtx)) + { + operands[4] = operands[0]; + operands[5] = not_rtx; + } + else + { + operands[5] = operands[0]; + operands[4] = not_rtx; + } + } [(set_attr "length" "8") (set_attr "ce_count" "2") (set_attr "predicable" "yes") diff --git a/gcc/testsuite/gcc.dg/torture/pr68648.c b/gcc/testsuite/gcc.dg/torture/pr68648.c new file mode 100644 index 0000000000000000000000000000000000000000..762eb8243bd786f1232ecb3ad5d3f7773476c2ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr68648.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +int __attribute__ ((noinline)) +foo (void) +{ + return 123; +} + +int __attribute__ ((noinline)) +bar (void) +{ + int c = 1; + c |= 4294967295 ^ (foo () | 4073709551608); + return c; +} + +int +main () +{ + if (bar () != 0x83fd4005) + __builtin_abort (); +}