From patchwork Thu Nov 19 16:06:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 546558 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 CBC49141425 for ; Fri, 20 Nov 2015 03:07:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KEHDHsqN; 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=IE2WcaVtePJAqKcPr R/o8kJcLdvOlf8NThKoCKeh+q6IzY+u+YUQ7yKN3Ev9jYSGkADLAqptkceuaJFMc jPNRT/n/CQQ/ebZyrJaIEN7uBmFZoElNSCSQHt0rtFebSBb6xCzLpE/yjAIlrWY5 hJ9fOX+BIwbgeyre+g4J0zq0AE= 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 :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=yS4sk8Gf7xt2WWEUIKmw2tb yBmc=; b=KEHDHsqNERMeGVV5km1zcDlPm57zVzwr83R+oJ23wTQOmwWnR+O9YJG wLLNbMZGjVaa1l9XLWL6R5yhCa782EI3oQwTPC50EvsIAyFJ/yG/+AjIwSzk8zUk p3XrbWyYLZ65Ejltut+be5g77hSBr/OEVpPHL5PZkQ3HaY4/EL0g= Received: (qmail 67006 invoked by alias); 19 Nov 2015 16:06:54 -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 65277 invoked by uid 89); 19 Nov 2015 16:06:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 19 Nov 2015 16:06:46 +0000 Received: by wmdw130 with SMTP id w130so246582118wmd.0 for ; Thu, 19 Nov 2015 08:06:42 -0800 (PST) X-Received: by 10.28.156.83 with SMTP id f80mr11984659wme.41.1447949202731; Thu, 19 Nov 2015 08:06:42 -0800 (PST) Received: from msticlxl57.ims.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id gj2sm8507354wjb.40.2015.11.19.08.06.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Nov 2015 08:06:42 -0800 (PST) Date: Thu, 19 Nov 2015 19:06:13 +0300 From: Ilya Enkovich To: Bernd Schmidt Cc: gcc-patches@gcc.gnu.org, law@redhat.com Subject: Re: [PATCH] Get rid of insn-codes.h in optabs-tree.c Message-ID: <20151119160613.GF42296@msticlxl57.ims.intel.com> References: <20151119142854.GE42296@msticlxl57.ims.intel.com> <564DEECC.3000609@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <564DEECC.3000609@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On 19 Nov 16:46, Bernd Schmidt wrote: > On 11/19/2015 03:28 PM, Ilya Enkovich wrote: > >This is a refactoring patch discussed in another thread [1]. It gets > >rid of CODE_FOR_nothing usage in optabs-tree.c by introducing boolean > >predicated in optabs-query. Bootstrapped and regtesed on > >x86_64-unknown-linux-gnu. > > Looks pretty reasonable, but I think we have to start saying "not now" after > the end of stage 1. I send it now because Jeff considered this patch at early stage3. I can commit it at the next stage1 either. > > > > >+/* Return 1 id there is a valid insn code to convert fixed-point mode > > "true", not "1" (elsewhere too), and "if". > > >+{ > >+ return get_fix_icode (fixmode, fltmode, unsignedp, truncp_ptr) > >+ != CODE_FOR_nothing; > > Formatting. Thanks! Below is a fixed version. Ilya > > > Bernd --- gcc/ 2015-11-19 Ilya Enkovich * optabs-query.h (get_vec_cmp_icode): Remove 'static'. (get_vcond_mask_icode): Likewise. (get_extend_icode): New. (get_float_icode): New. (get_fix_icode): New. (can_extend_p): Return bool (can_float_p): Return bool. (can_fix_p): Return bool. (can_vec_cmp_p): New. (can_vcond_p): New. (can_vcond_mask_p): New. * optabs-query.c (get_float_icode): New. (can_extend_p): Return bool. (get_float_icode): New. (can_float_p): Return bool. (get_fix_icode): New. (can_fix_p): Return bool. (can_vec_cmp_p): New. (can_vcond_p): New. (can_vcond_mask_p): New. * expr.c (init_expr_target): Use get_extend_icode and adjust to new can_extend_p return type. (convert_move): Likewise. (compress_float_constant): Likewise. * function.c (assign_parm_setup_reg): Likewise. * optabs-tree.c: Don't include insn-codes.h. (supportable_convert_operation): Adjust to can_fix_p and can_float_p new return types. * optabs.c (gen_extend_insn): Use get_extend_icode. (expand_float): Use get_float_icode and adjust to can_float_p new return type. (expand_fix): Use get_fix_icode and adjust to can_fix_p new return type. * tree-vrp.c (simplify_float_conversion_using_ranges): Adjust to can_float_p new return type. diff --git a/gcc/expr.c b/gcc/expr.c index bd43dc4..f4c06a1 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -223,7 +223,7 @@ init_expr_target (void) { enum insn_code ic; - ic = can_extend_p (mode, srcmode, 0); + ic = get_extend_icode (mode, srcmode, 0); if (ic == CODE_FOR_nothing) continue; @@ -452,7 +452,7 @@ convert_move (rtx to, rtx from, int unsignedp) int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD); /* Try converting directly if the insn is supported. */ - if ((code = can_extend_p (to_mode, from_mode, unsignedp)) + if ((code = get_extend_icode (to_mode, from_mode, unsignedp)) != CODE_FOR_nothing) { /* If FROM is a SUBREG, put it into a register. Do this @@ -466,7 +466,7 @@ convert_move (rtx to, rtx from, int unsignedp) } /* Next, try converting via full word. */ else if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD - && ((code = can_extend_p (to_mode, word_mode, unsignedp)) + && ((code = get_extend_icode (to_mode, word_mode, unsignedp)) != CODE_FOR_nothing)) { rtx word_to = gen_reg_rtx (word_mode); @@ -573,7 +573,7 @@ convert_move (rtx to, rtx from, int unsignedp) if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (from_mode)) { /* Convert directly if that works. */ - if ((code = can_extend_p (to_mode, from_mode, unsignedp)) + if ((code = get_extend_icode (to_mode, from_mode, unsignedp)) != CODE_FOR_nothing) { emit_unop_insn (code, to, from, equiv_code); @@ -588,12 +588,10 @@ convert_move (rtx to, rtx from, int unsignedp) /* Search for a mode to convert via. */ for (intermediate = from_mode; intermediate != VOIDmode; intermediate = GET_MODE_WIDER_MODE (intermediate)) - if (((can_extend_p (to_mode, intermediate, unsignedp) - != CODE_FOR_nothing) + if ((can_extend_p (to_mode, intermediate, unsignedp) || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate) && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, intermediate))) - && (can_extend_p (intermediate, from_mode, unsignedp) - != CODE_FOR_nothing)) + && can_extend_p (intermediate, from_mode, unsignedp)) { convert_move (to, convert_to_mode (intermediate, from, unsignedp), unsignedp); @@ -3638,7 +3636,7 @@ compress_float_constant (rtx x, rtx y) rtx_insn *last_insn; /* Skip if the target can't extend this way. */ - ic = can_extend_p (dstmode, srcmode, 0); + ic = get_extend_icode (dstmode, srcmode, 0); if (ic == CODE_FOR_nothing) continue; diff --git a/gcc/function.c b/gcc/function.c index afc2c87..1be96dc 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3143,8 +3143,8 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, enum insn_code icode; rtx op0, op1; - icode = can_extend_p (promoted_nominal_mode, data->passed_mode, - unsignedp); + icode = get_extend_icode (promoted_nominal_mode, data->passed_mode, + unsignedp); op0 = parmreg; op1 = validated_mem; diff --git a/gcc/optabs-query.c b/gcc/optabs-query.c index c20597c..747d2a1 100644 --- a/gcc/optabs-query.c +++ b/gcc/optabs-query.c @@ -231,8 +231,8 @@ get_best_mem_extraction_insn (extraction_insn *insn, no such operation exists, CODE_FOR_nothing will be returned. */ enum insn_code -can_extend_p (machine_mode to_mode, machine_mode from_mode, - int unsignedp) +get_extend_icode (machine_mode to_mode, machine_mode from_mode, + int unsignedp) { if (unsignedp < 0 && targetm.have_ptr_extend ()) return targetm.code_for_ptr_extend; @@ -241,18 +241,40 @@ can_extend_p (machine_mode to_mode, machine_mode from_mode, return convert_optab_handler (tab, to_mode, from_mode); } +/* Return true if there is a valid insn code used to extend FROM_MODE + to TO_MODE. UNSIGNEDP specifies zero-extension instead of + sign-extension. */ + +bool +can_extend_p (machine_mode to_mode, machine_mode from_mode, + int unsignedp) +{ + return get_extend_icode (to_mode, from_mode, unsignedp) != CODE_FOR_nothing; +} + /* Return the insn code to convert fixed-point mode FIXMODE to floating-point mode FLTMODE, or CODE_FOR_nothing if no such instruction exists. UNSIGNEDP specifies whether FIXMODE is unsigned. */ enum insn_code -can_float_p (machine_mode fltmode, machine_mode fixmode, - int unsignedp) +get_float_icode (machine_mode fltmode, machine_mode fixmode, + int unsignedp) { convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab; return convert_optab_handler (tab, fltmode, fixmode); } +/* Return true if there is a valid insn code to convert fixed-point mode + FIXMODE to floating-point mode FLTMODE. + UNSIGNEDP specifies whether FIXMODE is unsigned. */ + +bool +can_float_p (machine_mode fltmode, machine_mode fixmode, + int unsignedp) +{ + return get_float_icode (fltmode, fixmode, unsignedp) != CODE_FOR_nothing; +} + /* Return the insn code to convert floating-point mode FLTMODE to fixed-point mode FIXMODE, or CODE_FOR_nothing if no such instruction exists. UNSIGNEDP specifies whether FIXMODE is unsigned. @@ -261,8 +283,8 @@ can_float_p (machine_mode fltmode, machine_mode fixmode, output an explicit FTRUNC before the instruction. */ enum insn_code -can_fix_p (machine_mode fixmode, machine_mode fltmode, - int unsignedp, bool *truncp_ptr) +get_fix_icode (machine_mode fixmode, machine_mode fltmode, + int unsignedp, bool *truncp_ptr) { convert_optab tab; enum insn_code icode; @@ -290,6 +312,21 @@ can_fix_p (machine_mode fixmode, machine_mode fltmode, return CODE_FOR_nothing; } +/* Return true if there a valid insn code to convert floating-point mode + FLTMODE to fixed-point mode FIXMODE. + UNSIGNEDP specifies whether FIXMODE is unsigned. + + On a successful return, set *TRUNCP_PTR to true if it is necessary to + output an explicit FTRUNC before the instruction. */ + +bool +can_fix_p (machine_mode fixmode, machine_mode fltmode, + int unsignedp, bool *truncp_ptr) +{ + return get_fix_icode (fixmode, fltmode, unsignedp, truncp_ptr) + != CODE_FOR_nothing; +} + /* Return nonzero if a conditional move of mode MODE is supported. This function is for combine so it can tell whether an insn that looks @@ -580,3 +617,31 @@ lshift_cheap_p (bool speed_p) return cheap[speed_p]; } + +/* Return true if there is a valid insn code for a comparison + operator with VMODE resultin MASK_MODE, unsigned if UNS is true. */ + +bool +can_vec_cmp_p (machine_mode vmode, machine_mode mask_mode, bool uns) +{ + return get_vec_cmp_icode (vmode, mask_mode, uns) != CODE_FOR_nothing; +} + +/* Return true if there is a valid insn code for a conditional operator + with a comparison in mode CMODE, unsigned if UNS is true, resulting + in a value of mode VMODE. */ + +bool +can_vcond_p (machine_mode vmode, machine_mode cmode, bool uns) +{ + return get_vcond_icode (vmode, cmode, uns) != CODE_FOR_nothing; +} + +/* Return true if there is a valid insn code for a conditional operator + with a mask mode MMODE resulting in a value of mode VMODE. */ + +bool +can_vcond_mask_p (machine_mode vmode, machine_mode mmode) +{ + return get_vcond_mask_icode (vmode, mmode) != CODE_FOR_nothing; +} diff --git a/gcc/optabs-query.h b/gcc/optabs-query.h index 48bcf7c..0604a2e 100644 --- a/gcc/optabs-query.h +++ b/gcc/optabs-query.h @@ -77,7 +77,7 @@ trapv_binoptab_p (optab binoptab) /* Return insn code for a comparison operator with VMODE resultin MASK_MODE, unsigned if UNS is true. */ -static inline enum insn_code +inline enum insn_code get_vec_cmp_icode (machine_mode vmode, machine_mode mask_mode, bool uns) { optab tab = uns ? vec_cmpu_optab : vec_cmp_optab; @@ -101,7 +101,7 @@ get_vcond_icode (machine_mode vmode, machine_mode cmode, bool uns) /* Return insn code for a conditional operator with a mask mode MMODE resulting in a value of mode VMODE. */ -static inline enum insn_code +inline enum insn_code get_vcond_mask_icode (machine_mode vmode, machine_mode mmode) { return convert_optab_handler (vcond_mask_optab, vmode, mmode); @@ -136,9 +136,12 @@ bool get_best_mem_extraction_insn (extraction_insn *, enum extraction_pattern, HOST_WIDE_INT, HOST_WIDE_INT, machine_mode); -enum insn_code can_extend_p (machine_mode, machine_mode, int); -enum insn_code can_float_p (machine_mode, machine_mode, int); -enum insn_code can_fix_p (machine_mode, machine_mode, int, bool *); +enum insn_code get_extend_icode (machine_mode, machine_mode, int); +enum insn_code get_float_icode (machine_mode, machine_mode, int); +enum insn_code get_fix_icode (machine_mode, machine_mode, int, bool *); +bool can_extend_p (machine_mode, machine_mode, int); +bool can_float_p (machine_mode, machine_mode, int); +bool can_fix_p (machine_mode, machine_mode, int, bool *); bool can_conditionally_move_p (machine_mode mode); bool can_vec_perm_p (machine_mode, bool, const unsigned char *); enum insn_code widening_optab_handler (optab, machine_mode, machine_mode); @@ -153,5 +156,8 @@ bool can_vec_mask_load_store_p (machine_mode, machine_mode, bool); bool can_compare_and_swap_p (machine_mode, bool); bool can_atomic_exchange_p (machine_mode, bool); bool lshift_cheap_p (bool); +bool can_vec_cmp_p (machine_mode, machine_mode, bool); +bool can_vcond_p (machine_mode, machine_mode, bool); +bool can_vcond_mask_p (machine_mode, machine_mode); #endif diff --git a/gcc/optabs-tree.c b/gcc/optabs-tree.c index d887619..0bb1534 100644 --- a/gcc/optabs-tree.c +++ b/gcc/optabs-tree.c @@ -22,7 +22,6 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "target.h" -#include "insn-codes.h" #include "tree.h" #include "optabs-tree.h" #include "stor-layout.h" @@ -298,11 +297,9 @@ supportable_convert_operation (enum tree_code code, /* First check if we can done conversion directly. */ if ((code == FIX_TRUNC_EXPR - && can_fix_p (m1,m2,TYPE_UNSIGNED (vectype_out), &truncp) - != CODE_FOR_nothing) + && can_fix_p (m1,m2,TYPE_UNSIGNED (vectype_out), &truncp)) || (code == FLOAT_EXPR - && can_float_p (m1,m2,TYPE_UNSIGNED (vectype_in)) - != CODE_FOR_nothing)) + && can_float_p (m1,m2,TYPE_UNSIGNED (vectype_in)))) { *code1 = code; return true; diff --git a/gcc/optabs.c b/gcc/optabs.c index 5545302..1276d5f 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -4498,7 +4498,7 @@ rtx_insn * gen_extend_insn (rtx x, rtx y, machine_mode mto, machine_mode mfrom, int unsignedp) { - enum insn_code icode = can_extend_p (mto, mfrom, unsignedp); + enum insn_code icode = get_extend_icode (mto, mfrom, unsignedp); return GEN_FCN (icode) (x, y); } @@ -4535,10 +4535,10 @@ expand_float (rtx to, rtx from, int unsignedp) && significand_size (fmode) < GET_MODE_PRECISION (GET_MODE (from))) continue; - icode = can_float_p (fmode, imode, unsignedp); + icode = get_float_icode (fmode, imode, unsignedp); if (icode == CODE_FOR_nothing && unsignedp) { - enum insn_code scode = can_float_p (fmode, imode, 0); + enum insn_code scode = get_float_icode (fmode, imode, 0); if (scode != CODE_FOR_nothing) can_do_signed = true; if (imode != GET_MODE (from)) @@ -4577,7 +4577,7 @@ expand_float (rtx to, rtx from, int unsignedp) for (fmode = GET_MODE (to); fmode != VOIDmode; fmode = GET_MODE_WIDER_MODE (fmode)) if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_BITSIZE (fmode) - && can_float_p (fmode, GET_MODE (from), 0) != CODE_FOR_nothing) + && can_float_p (fmode, GET_MODE (from), 0)) break; if (fmode == VOIDmode) @@ -4729,9 +4729,12 @@ expand_fix (rtx to, rtx from, int unsignedp) { int doing_unsigned = unsignedp; - icode = can_fix_p (imode, fmode, unsignedp, &must_trunc); + icode = get_fix_icode (imode, fmode, unsignedp, &must_trunc); if (icode == CODE_FOR_nothing && imode != GET_MODE (to) && unsignedp) - icode = can_fix_p (imode, fmode, 0, &must_trunc), doing_unsigned = 0; + { + icode = get_fix_icode (imode, fmode, 0, &must_trunc); + doing_unsigned = 0; + } if (icode != CODE_FOR_nothing) { @@ -4787,7 +4790,7 @@ expand_fix (rtx to, rtx from, int unsignedp) if (unsignedp && GET_MODE_PRECISION (GET_MODE (to)) <= HOST_BITS_PER_WIDE_INT) for (fmode = GET_MODE (from); fmode != VOIDmode; fmode = GET_MODE_WIDER_MODE (fmode)) - if (CODE_FOR_nothing != can_fix_p (GET_MODE (to), fmode, 0, &must_trunc) + if (can_fix_p (GET_MODE (to), fmode, 0, &must_trunc) && (!DECIMAL_FLOAT_MODE_P (fmode) || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (GET_MODE (to)))) { diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 5d085b4..90f4e54 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -9712,13 +9712,12 @@ simplify_float_conversion_using_ranges (gimple_stmt_iterator *gsi, /* First check if we can use a signed type in place of an unsigned. */ if (TYPE_UNSIGNED (TREE_TYPE (rhs1)) - && (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), 0) - != CODE_FOR_nothing) + && can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), 0) && range_fits_type_p (vr, TYPE_PRECISION (TREE_TYPE (rhs1)), SIGNED)) mode = TYPE_MODE (TREE_TYPE (rhs1)); /* If we can do the conversion in the current input mode do nothing. */ else if (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), - TYPE_UNSIGNED (TREE_TYPE (rhs1))) != CODE_FOR_nothing) + TYPE_UNSIGNED (TREE_TYPE (rhs1)))) return false; /* Otherwise search for a mode we can use, starting from the narrowest integer mode available. */ @@ -9730,7 +9729,7 @@ simplify_float_conversion_using_ranges (gimple_stmt_iterator *gsi, /* If we cannot do a signed conversion to float from mode or if the value-range does not fit in the signed type try with a wider mode. */ - if (can_float_p (fltmode, mode, 0) != CODE_FOR_nothing + if (can_float_p (fltmode, mode, 0) && range_fits_type_p (vr, GET_MODE_PRECISION (mode), SIGNED)) break;