From patchwork Mon Jun 3 16:31:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Bolton X-Patchwork-Id: 248339 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D50042C0099 for ; Tue, 4 Jun 2013 02:32:07 +1000 (EST) 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; q=dns; s= default; b=EHjdQXJ6ykA1Qstwr8FbhwUgM097r6D/ScM/W/1Z2JhN2zAxqUW3N bXicSISJLbv2uMjtREJHrWIk4HfibxBZSeDgg8XWLsCMabCUUds+7PNuA9A+/ZSy NdY5lRQr1btCe8U6q2fsUrxAwh5lyzHfyrh6AiXctJPX02h0JcaH+k= 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; s= default; bh=cS+R5FskzyEpcMA/AbPsN9QEfvg=; b=j/zg71BVTv9ysSPTxfgI i1iRUUDRzd8NB73VAQe8+mHagD0qFUFHYPKyqs0Pt4lws/SqnrT5oYn7uJmkM9in jVzrHGK7hY0dZCVCVVtIRekgD0ht3GuSF4093ATeywLEUFM+g8ZqynacsN8t3De4 vvHrWakzaGUMxAgnWhmIzig= Received: (qmail 17937 invoked by alias); 3 Jun 2013 16:32:02 -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 17927 invoked by uid 89); 3 Jun 2013 16:32:01 -0000 X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_LOW, SPF_PASS, TW_MV, TW_PM autolearn=no version=3.3.1 Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 03 Jun 2013 16:32:00 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 03 Jun 2013 17:31:57 +0100 Received: from E102352xp ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 3 Jun 2013 17:31:57 +0100 From: "Ian Bolton" To: Subject: [AArch64, PATCH 1/5] Improve MOVI handling (Change interface of aarch64_simd_valid_immediate) Date: Mon, 3 Jun 2013 17:31:37 +0100 Message-ID: <000001ce6077$d1a37bd0$74ea7370$@bolton@arm.com> MIME-Version: 1.0 X-MC-Unique: 113060317315702801 X-Virus-Found: No (This patch is the first of five, where the first 4 do some clean-up and the last fixes a bug with scalar MOVI. The bug fix without the clean-up was particularly ugly!) This one is pretty simple - just altering an interface, so we can later remove an unnecessary wrapper function. OK for trunk? Cheers, Ian 13-06-03 Ian Bolton * config/aarch64/aarch64.c (aarch64_simd_valid_immediate): Change return type to bool for prototype. (aarch64_legitimate_constant_p): Check for true instead of not -1. (aarch64_simd_valid_immediate): Fix up each return to return a bool. (aarch64_simd_immediate_valid_for_move): Update retval for bool. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 12a7055..05ff5fa 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -103,7 +103,7 @@ static bool aarch64_vfp_is_call_or_return_candidate (enum machine_mode, static void aarch64_elf_asm_constructor (rtx, int) ATTRIBUTE_UNUSED; static void aarch64_elf_asm_destructor (rtx, int) ATTRIBUTE_UNUSED; static void aarch64_override_options_after_change (void); -static int aarch64_simd_valid_immediate (rtx, enum machine_mode, int, rtx *, +static bool aarch64_simd_valid_immediate (rtx, enum machine_mode, int, rtx *, int *, unsigned char *, int *, int *); static bool aarch64_vector_mode_supported_p (enum machine_mode); static unsigned bit_count (unsigned HOST_WIDE_INT); @@ -5153,7 +5153,7 @@ aarch64_legitimate_constant_p (enum machine_mode mode, rtx x) we now decompose CONST_INTs according to expand_mov_immediate. */ if ((GET_CODE (x) == CONST_VECTOR && aarch64_simd_valid_immediate (x, mode, false, - NULL, NULL, NULL, NULL, NULL) != -1) + NULL, NULL, NULL, NULL, NULL)) || CONST_INT_P (x) || aarch64_valid_floating_const (mode, x)) return !targetm.cannot_force_const_mem (mode, x); @@ -6144,11 +6144,8 @@ aarch64_vect_float_const_representable_p (rtx x) return aarch64_float_const_representable_p (x0); } -/* TODO: This function returns values similar to those - returned by neon_valid_immediate in gcc/config/arm/arm.c - but the API here is different enough that these magic numbers - are not used. It should be sufficient to return true or false. */ -static int +/* Return true for valid and false for invalid. */ +static bool aarch64_simd_valid_immediate (rtx op, enum machine_mode mode, int inverse, rtx *modconst, int *elementwidth, unsigned char *elementchar, @@ -6184,24 +6181,21 @@ aarch64_simd_valid_immediate (rtx op, enum machine_mode mode, int inverse, if (!(simd_imm_zero || aarch64_vect_float_const_representable_p (op))) - return -1; + return false; - if (modconst) - *modconst = CONST_VECTOR_ELT (op, 0); + if (modconst) + *modconst = CONST_VECTOR_ELT (op, 0); - if (elementwidth) - *elementwidth = elem_width; + if (elementwidth) + *elementwidth = elem_width; - if (elementchar) - *elementchar = sizetochar (elem_width); + if (elementchar) + *elementchar = sizetochar (elem_width); - if (shift) - *shift = 0; + if (shift) + *shift = 0; - if (simd_imm_zero) - return 19; - else - return 18; + return true; } /* Splat vector constant out into a byte vector. */ @@ -6299,7 +6293,7 @@ aarch64_simd_valid_immediate (rtx op, enum machine_mode mode, int inverse, if (immtype == -1 || (immtype >= 12 && immtype <= 15) || immtype == 18) - return -1; + return false; if (elementwidth) @@ -6351,7 +6345,7 @@ aarch64_simd_valid_immediate (rtx op, enum machine_mode mode, int inverse, } } - return immtype; + return (immtype >= 0); #undef CHECK } @@ -6369,11 +6363,11 @@ aarch64_simd_immediate_valid_for_move (rtx op, enum machine_mode mode, int tmpwidth; unsigned char tmpwidthc; int tmpmvn = 0, tmpshift = 0; - int retval = aarch64_simd_valid_immediate (op, mode, 0, &tmpconst, + bool retval = aarch64_simd_valid_immediate (op, mode, 0, &tmpconst, &tmpwidth, &tmpwidthc, &tmpmvn, &tmpshift); - if (retval == -1) + if (!retval) return 0; if (modconst)