From patchwork Wed Jun 3 09:33:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 479843 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 64530140280 for ; Wed, 3 Jun 2015 19:34:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=T3SNQair; 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:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=AQewpKmziInXsAaw4VeXVSsHRFWShvhBrQWfstZZsAhuUSwKw7iqZ RPsr9cIXa0Og58TWvLwJ4Q0KN9lWI0xD9YkPB9R0aTChwr5S9+T1Mw/VPg1MkP9B s9sq7/Lmofvy7b/0Zmo9HE0TYlFeh7KxcoiHsHp80auPoDnNii9Vyg= 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:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=zw/Q1qhQ+XZjsiktq9JmzcoyWpo=; b=T3SNQairlr0UybILpiA+A0gMFJa+ v9je3X68Wsw0+P71uP5uAdMN99bUm0Ys9Fr9qWi9ifeqB4Qv6+RbxXQH/woe6aPl gVZTEEKKxnHeN3JWcsKnvnOVEEv8chAtXzTxj0fsuY6gGaFcHqHAMmmQ2K0flscd NU2nYOa9r+ReSM4= Received: (qmail 63869 invoked by alias); 3 Jun 2015 09:33:53 -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 63855 invoked by uid 89); 3 Jun 2015 09:33:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 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) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Jun 2015 09:33:51 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-18.uk.mimecast.lan; Wed, 03 Jun 2015 10:33:48 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Jun 2015 10:33:47 +0100 From: Richard Sandiford To: Richard Henderson Mail-Followup-To: Richard Henderson , "gcc-patches\@gcc.gnu.org" , Andreas Krebbel , richard.sandiford@arm.com Cc: "gcc-patches\@gcc.gnu.org" , Andreas Krebbel Subject: Re: RFA: Fix mode checks for possibly-constant predicates References: <87egn5yis1.fsf@e105548-lin.cambridge.arm.com> <5556DF07.6020000@linux.vnet.ibm.com> <87bnhix61c.fsf@e105548-lin.cambridge.arm.com> <555F4FCC.5020501@linux.vnet.ibm.com> <87siao38dq.fsf@e105548-lin.cambridge.arm.com> <87pp5jl2m1.fsf_-_@e105548-lin.cambridge.arm.com> <5568A761.20705@redhat.com> <87sia971bv.fsf@e105548-lin.cambridge.arm.com> Date: Wed, 03 Jun 2015 10:33:47 +0100 In-Reply-To: <87sia971bv.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Wed, 03 Jun 2015 07:28:20 +0100") Message-ID: <87oakx6sqs.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: r314izdORV2zk5RGQ42vAw-1 Richard Sandiford writes: > Richard Henderson writes: >> On 05/29/2015 10:23 AM, Richard Sandiford wrote: >>> + /* Check whether the predicate accepts const scalar ints (which always >>> + have a stored mode of VOIDmode, but logically have a real mode) >>> + and whether it matches anything besides const scalar ints. */ >>> + bool matches_const_scalar_int_p = false; >>> + bool matches_other_p = false; >>> + for (int i = 0; i < NUM_RTX_CODE; ++i) >>> + if (p->codes[i]) >>> + switch (i) >>> + { >>> + CASE_CONST_SCALAR_INT: >>> + matches_const_scalar_int_p = true; >>> + break; >>> + >>> + default: >>> + matches_other_p = true; >>> + break; >>> + } >>> + >>> + /* There's no need for a mode check if the predicate only accepts >>> + constant integers. The code checks in the predicate are enough >>> + to establish that the mode is VOIDmode. >>> + >>> + Note that the predicate itself should check whether a scalar >>> + integer is in range of the given mode. */ >>> + if (!matches_other_p && !p->codes[CONST_DOUBLE]) >>> + return; >> >> I think perhaps it would be cleaner to not use CASE_CONST_SCALAR_INT, >> and then do >> >> switch (i) >> { >> case CONST_INT: >> case CONST_WIDE_INT: >> matches_const_scalar_int_p = true; >> break; >> >> case CONST_DOUBLE: >> if (!TARGET_SUPPORTS_WIDE_INT) >> matches_const_scalar_int_p = true; >> matches_other_p = true; >> break; >> >> default: >> matches_other_p = true; >> break; >> } >> >> if (!matches_other_p) >> return; >> >> Otherwise ok. > > Ah, yeah, that's better. Here's what I applied after testing on > x86_64-linux-gnu. This broke the build for !TARGET_SUPPORTS_WIDE_INT because the default definition was in the wrong part of defaults.h: #ifdef GCC_INSN_FLAGS_H /* Dependent default target macro definitions This section of defaults.h defines target macros that depend on generated headers. This is a bit awkward: We want to put all default definitions for target macros in defaults.h, but some of the defaults depend on the HAVE_* flags defines of insn-flags.h. But insn-flags.h is not always included by files that do include defaults.h. Fortunately, the default macro definitions that depend on the HAVE_* macros are also the ones that will only be used inside GCC itself, i.e. not in the gen* programs or in target objects like libgcc. Obviously, it would be best to keep this section of defaults.h as small as possible, by converting the macros defined below to target hooks or functions. */ ... #endif /* GCC_INSN_FLAGS_H */ The macro is supposed to be a configuration invariant and so there's no reason for it depend on generated headers. The same goes for SWITCHABLE_TARGET (oops). Tested by making sure that aarch64-linux-gnu builds again. Committed as obvious. Thanks, Richard gcc/ * defaults.h (SWITCHABLE_TARGET, TARGET_SUPPORTS_WIDE_INT): Move out of GCC_INSN_FLAGS_H block. Index: gcc/defaults.h =================================================================== --- gcc/defaults.h 2015-06-03 10:21:20.247590112 +0100 +++ gcc/defaults.h 2015-06-03 10:21:27.015513249 +0100 @@ -1253,6 +1253,18 @@ #define STACK_PUSH_CODE PRE_INC # define DEFAULT_FLAG_PIE 0 #endif +#ifndef SWITCHABLE_TARGET +#define SWITCHABLE_TARGET 0 +#endif + +/* If the target supports integers that are wider than two + HOST_WIDE_INTs on the host compiler, then the target should define + TARGET_SUPPORTS_WIDE_INT and make the appropriate fixups. + Otherwise the compiler really is not robust. */ +#ifndef TARGET_SUPPORTS_WIDE_INT +#define TARGET_SUPPORTS_WIDE_INT 0 +#endif + #ifdef GCC_INSN_FLAGS_H /* Dependent default target macro definitions @@ -1414,18 +1426,6 @@ #define STACK_CHECK_MAX_VAR_SIZE (STACK_ #define TARGET_VTABLE_USES_DESCRIPTORS 0 #endif -#ifndef SWITCHABLE_TARGET -#define SWITCHABLE_TARGET 0 -#endif - -/* If the target supports integers that are wider than two - HOST_WIDE_INTs on the host compiler, then the target should define - TARGET_SUPPORTS_WIDE_INT and make the appropriate fixups. - Otherwise the compiler really is not robust. */ -#ifndef TARGET_SUPPORTS_WIDE_INT -#define TARGET_SUPPORTS_WIDE_INT 0 -#endif - #ifndef HAVE_simple_return #define HAVE_simple_return 0 static inline rtx