From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22439 invoked by alias); 6 Nov 2015 12:56:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22389 invoked by uid 89); 6 Nov 2015 12:56:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f176.google.com Received: from mail-yk0-f176.google.com (HELO mail-yk0-f176.google.com) (209.85.160.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 06 Nov 2015 12:56:43 +0000 Received: by ykdv3 with SMTP id v3so92760988ykd.0 for ; Fri, 06 Nov 2015 04:56:42 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.129.125.194 with SMTP id y185mr10775035ywc.5.1446814601956; Fri, 06 Nov 2015 04:56:41 -0800 (PST) Received: by 10.37.93.11 with HTTP; Fri, 6 Nov 2015 04:56:41 -0800 (PST) In-Reply-To: References: <559F5D7B.6070208@redhat.com> <55B148AB.6010103@redhat.com> <55B28DCB.2080404@redhat.com> Date: Fri, 06 Nov 2015 12:56:00 -0000 Message-ID: Subject: Re: [PATCH] Simple optimization for MASK_STORE. From: Richard Biener To: Yuri Rumyantsev Cc: Jeff Law , gcc-patches , Igor Zamyatin Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00616.txt.bz2 On Mon, Nov 2, 2015 at 4:24 PM, Yuri Rumyantsev wrote: > Hi Richard, > > I've come back to this optimization and try to implement your proposal > for comparison: >> Btw, you didn't try the simpler alternative of >> >> tree type = type_for_mode (int_mode_for_mode (TYPE_MODE (vectype))); >> build2 (EQ_EXPR, boolean_type_node, >> build1 (VIEW_CONVERT, type, op0), build1 (VIEW_CONVERT, type, op1)); >> >> ? That is, use the GIMPLE level equivalent of >> (cmp (subreg:TI reg:V4SI) (subreg:TI reg:V4SI)) > > using the following code: > > vectype = TREE_TYPE (mask); > ext_mode = mode_for_size (GET_MODE_BITSIZE (TYPE_MODE (vectype)), > MODE_INT, 0); > ext_type = lang_hooks.types.type_for_mode (ext_mode , 1); > > but I've got zero type for it. Should I miss something? Use ext_type = build_nonstandard_integer_type (GET_MODE_PRECISION (ext_mode), 1); Richard. > Any help will be appreciated. > Yuri. > > > 2015-08-13 14:40 GMT+03:00 Richard Biener : >> On Thu, Aug 13, 2015 at 1:32 PM, Yuri Rumyantsev wrote: >>> Hi Richard, >>> >>> Did you have a chance to look at updated patch? >> >> Having a quick look now. Btw, you didn't try the simpler alternative of >> >> tree type = type_for_mode (int_mode_for_mode (TYPE_MODE (vectype))); >> build2 (EQ_EXPR, boolean_type_node, >> build1 (VIEW_CONVERT, type, op0), build1 (VIEW_CONVERT, type, op1)); >> >> ? That is, use the GIMPLE level equivalent of >> >> (cmp (subreg:TI reg:V4SI) (subreg:TI reg:V4SI)) >> >> ? That should be supported by the expander already, though again not sure if >> the target(s) have compares that match this. >> >> Btw, the tree-cfg.c hook wasn't what was agreed on - the restriction >> on EQ/NE_EXPR >> is missing. Operand type equality is tested anyway. >> >> Why do you need to restrict forward_propagate_into_comparison_1? >> >> Otherwise this looks better, but can you try with the VIEW_CONVERT as well? >> >> Thanks, >> Richard. >> >> >>> Thanks. >>> Yuri. >>> >>> 2015-08-06 14:07 GMT+03:00 Yuri Rumyantsev : >>>> HI All, >>>> >>>> Here is updated patch which implements Richard proposal to use vector >>>> comparison with boolean result instead of target hook. Support for it >>>> was added to ix86_expand_branch. >>>> >>>> Any comments will be appreciated. >>>> >>>> Bootstrap and regression testing did not show any new failures. >>>> >>>> ChangeLog: >>>> 2015-08-06 Yuri Rumyantsev >>>> >>>> * config/i386/i386.c (ix86_expand_branch): Implement vector >>>> comparison with boolean result. >>>> * config/i386/sse.md (define_expand "cbranch4): Add define >>>> for vector comparion. >>>> * fold-const.c (fold_relational_const): Add handling of vector >>>> comparison with boolean result. >>>> * params.def (PARAM_ZERO_TEST_FOR_STORE_MASK): New DEFPARAM. >>>> * params.h (ENABLE_ZERO_TEST_FOR_STORE_MASK): new macros. >>>> * tree-cfg.c (verify_gimple_comparison): Add test for vector >>>> comparion with boolean result. >>>> * tree-ssa-forwprop.c (forward_propagate_into_comparison_1): Do not >>>> propagate vector comparion with boolean result. >>>> * tree-vect-stmts.c (vectorizable_mask_load_store): Initialize >>>> has_mask_store field of vect_info. >>>> * tree-vectorizer.c: Include files ssa.h, cfghooks.h and params.h. >>>> (is_valid_sink): New function. >>>> (optimize_mask_stores): New function. >>>> (vectorize_loops): Invoke optimaze_mask_stores for loops having masked >>>> stores. >>>> * tree-vectorizer.h (loop_vec_info): Add new has_mask_store field and >>>> correspondent macros. >>>> >>>> gcc/testsuite/ChangeLog: >>>> * gcc.target/i386/avx2-vect-mask-store-move1.c: New test. >>>> >>>> >>>> 2015-07-27 11:48 GMT+03:00 Richard Biener : >>>>> On Fri, Jul 24, 2015 at 9:11 PM, Jeff Law wrote: >>>>>> On 07/24/2015 03:16 AM, Richard Biener wrote: >>>>>>>> >>>>>>>> Is there any rationale given anywhere for the transformation into >>>>>>>> conditional expressions? ie, is there any reason why we can't have a >>>>>>>> GIMPLE_COND where the expression is a vector condition? >>>>>>> >>>>>>> >>>>>>> No rationale for equality compare which would have the semantic of >>>>>>> having all elements equal or not equal. But you can't define a sensible >>>>>>> ordering (that HW implements) for other compare operators and you >>>>>>> obviously need a single boolean result, not a vector of element comparison >>>>>>> results. >>>>>> >>>>>> Right. EQ/NE only as others just don't have any real meaning. >>>>>> >>>>>> >>>>>>> I've already replied that I'm fine allowing ==/!= whole-vector compares. >>>>>>> But one needs to check whether expansion does anything sensible >>>>>>> with them (either expand to integer subreg compares or add optabs >>>>>>> for the compares). >>>>>> >>>>>> Agreed, EQ/NE for whole vector compares only would be fine for me too under >>>>>> the same conditions. >>>>> >>>>> Btw, you can already do this on GIMPLE by doing >>>>> >>>>> TImode vec_as_int = VIEW_CONVERT_EXPR (vec_2); >>>>> if (vec_as_int == 0) >>>>> ... >>>>> >>>>> which is what the RTL will look like in the end. So not sure if making this >>>>> higher-level in GIMPLE is good or required. >>>>> >>>>> Richard. >>>>> >>>>>> jeff