From patchwork Mon Apr 14 23:09:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 339119 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 B5B8A140093 for ; Tue, 15 Apr 2014 09:10:08 +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:date :message-id:from:to:subject; q=dns; s=default; b=CzImQ4zIHZBGEpc 5tUTX10EkUKJuvHT5Riht5AWTi9h5wWBzzOSXedT4ih4jYG13fpOGlPfmWlkg6Xj KRho4GRtVd6BkLkD0zzFsqFm6YH+CDeOqTrNg5jL6Rlwvir8Ds/ZraunSr7deVMk W23TPa0hAQYCMQUaMFBvNoqU4590= 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 :message-id:from:to:subject; s=default; bh=2PAQZHIHkY31lq6v+7V4N yGM1kI=; b=Q75FZYY2hhX2wrvP1+ICK2k+jX7TV8GZXQ9pwXvHDuuZmWmo3Q85K i/nOUTTGraoI4IU2/N61l3w91nkjP+AedflVFgD/f3F6vufL7EWTunbAEkkkdfZb qhnGb5wWVZz6D146w3SNApmqn6dH6R16bffN0ivSGk0lv8sHjziF68= Received: (qmail 12031 invoked by alias); 14 Apr 2014 23:10:01 -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 12002 invoked by uid 89); 14 Apr 2014 23:10:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Apr 2014 23:09:58 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3EN9vBP010482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 14 Apr 2014 19:09:57 -0400 Received: from greed.delorie.com (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3EN9uKX020083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 14 Apr 2014 19:09:56 -0400 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id s3EN9tJ7010077 for ; Mon, 14 Apr 2014 19:09:55 -0400 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id s3EN9tbZ010076; Mon, 14 Apr 2014 19:09:55 -0400 Date: Mon, 14 Apr 2014 19:09:55 -0400 Message-Id: <201404142309.s3EN9tbZ010076@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: [patch] more partial int mode precision patches X-IsSubscribed: yes More cases where a mode's precision should be used instead of its storage size. Ok? gcc/ * expmed.c (init_expmed_one_conv): Assume partial integers have a known precision, but still compensate for those that are whole-int-sized. * expr.c (convert_move): Allow for the case where the target has an explicit converter between the two given modes, before checking for the "expected" converters. * loop-iv.c (iv_number_of_iterations): Use the mode's precision, not bitsize. * optabs.c (expand_float): Check mode precisions, not storage sizes. * simplify-rtx.c (simplify_unary_operation_1): Check mode precisions, not storage sizes. Index: optabs.c =================================================================== --- optabs.c (revision 209391) +++ optabs.c (working copy) @@ -5162,13 +5162,13 @@ expand_float (rtx to, rtx from, int unsi { rtx libfunc; rtx insns; rtx value; convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab; - if (GET_MODE_SIZE (GET_MODE (from)) < GET_MODE_SIZE (SImode)) + if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_PRECISION (SImode)) from = convert_to_mode (SImode, from, unsignedp); libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from)); gcc_assert (libfunc); start_sequence (); Index: expr.c =================================================================== --- expr.c (revision 209391) +++ expr.c (working copy) @@ -420,12 +420,32 @@ convert_move (rtx to, rtx from, int unsi from) : gen_rtx_FLOAT_EXTEND (to_mode, from)); return; } /* Handle pointer conversion. */ /* SPEE 900220. */ + /* If the target has a converter from FROM_MODE to TO_MODE, use it. */ + { + convert_optab ctab; + + if (GET_MODE_PRECISION (from_mode) > GET_MODE_PRECISION (to_mode)) + ctab = trunc_optab; + else if (unsignedp) + ctab = zext_optab; + else + ctab = sext_optab; + + if (convert_optab_handler (ctab, to_mode, from_mode) + != CODE_FOR_nothing) + { + emit_unop_insn (convert_optab_handler (ctab, to_mode, from_mode), + to, from, UNKNOWN); + return; + } + } + /* Targets are expected to provide conversion insns between PxImode and xImode for all MODE_PARTIAL_INT modes they use, but no others. */ if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT) { enum machine_mode full_mode = smallest_mode_for_size (GET_MODE_BITSIZE (to_mode), MODE_INT); Index: expmed.c =================================================================== --- expmed.c (revision 209391) +++ expmed.c (working copy) @@ -103,19 +103,25 @@ static void init_expmed_one_conv (struct init_expmed_rtl *all, enum machine_mode to_mode, enum machine_mode from_mode, bool speed) { int to_size, from_size; rtx which; - /* We're given no information about the true size of a partial integer, - only the size of the "full" integer it requires for storage. For - comparison purposes here, reduce the bit size by one in that case. */ - to_size = (GET_MODE_BITSIZE (to_mode) - - (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT)); - from_size = (GET_MODE_BITSIZE (from_mode) - - (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT)); + to_size = GET_MODE_PRECISION (to_mode); + from_size = GET_MODE_PRECISION (from_mode); + + /* Most partial integers have a precision less than the "full" + integer it requires for storage. In case one doesn't, for + comparison purposes here, reduce the bit size by one in that + case. */ + if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT + && exact_log2 (to_size) != -1) + to_mode --; + if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT + && exact_log2 (from_size) != -1) + from_mode --; /* Assume cost of zero-extend and sign-extend is the same. */ which = (to_size < from_size ? &all->trunc : &all->zext); PUT_MODE (&all->reg, from_mode); set_convert_cost (to_mode, from_mode, speed, set_src_cost (which, speed)); Index: simplify-rtx.c =================================================================== --- simplify-rtx.c (revision 209391) +++ simplify-rtx.c (working copy) @@ -1344,14 +1344,14 @@ simplify_unary_operation_1 (enum rtx_cod } /* (sign_extend:M (sign_extend:N )) is (sign_extend:M ). (sign_extend:M (zero_extend:N )) is (zero_extend:M ). */ if (GET_CODE (op) == SIGN_EXTEND || GET_CODE (op) == ZERO_EXTEND) { - gcc_assert (GET_MODE_BITSIZE (mode) - > GET_MODE_BITSIZE (GET_MODE (op))); + gcc_assert (GET_MODE_PRECISION (mode) + > GET_MODE_PRECISION (GET_MODE (op))); return simplify_gen_unary (GET_CODE (op), mode, XEXP (op, 0), GET_MODE (XEXP (op, 0))); } /* (sign_extend:M (ashiftrt:N (ashift (const_int I)) (const_int I))) is (sign_extend:M (subreg:O )) if there is mode with Index: loop-iv.c =================================================================== --- loop-iv.c (revision 209391) +++ loop-iv.c (working copy) @@ -2394,13 +2394,13 @@ iv_number_of_iterations (struct loop *lo if (!canonicalize_iv_subregs (&iv0, &iv1, cond, desc)) goto fail; comp_mode = iv0.extend_mode; mode = iv0.mode; - size = GET_MODE_BITSIZE (mode); + size = GET_MODE_PRECISION (mode); get_mode_bounds (mode, (cond == LE || cond == LT), comp_mode, &mmin, &mmax); mode_mmin = lowpart_subreg (mode, mmin, comp_mode); mode_mmax = lowpart_subreg (mode, mmax, comp_mode); if (!CONST_INT_P (iv0.step) || !CONST_INT_P (iv1.step)) goto fail;