From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 6CA123858D20 for ; Tue, 15 Mar 2022 07:43:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6CA123858D20 Received: by mail-ed1-x52b.google.com with SMTP id y8so17971415edl.9 for ; Tue, 15 Mar 2022 00:43:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OhqIRf7lKpJ8EPPK55DwBGoIL9UhI9sXgy05785PJB4=; b=opq/y2WnwL8yuStSfMGMSpMwznPITUz8dQAdRtgagVGt1H53O/+HD1FjDjha7AeEcT 7Vdn17EyFUoJw7TelRrzHb2gLTesDX4jpo5/gIL31WOHmrlMxlZsGgvVOnKKYMIOp3Zs tkGg+GP4KTCZ0SNU+K+w6CPBhdP3X77pbIck1cY7iPf8AzzMsk1gI/vWQis/thUTfImo PdNOV/xe66f1MaMlOhZnhvaUeofSQoQ67YlH9sw1YJUw3oKbHCr0VQEaKk5oA9gUy1OR Dp/TnPDwV3tlfGX/JYqxNyElqwx1v5dQ2x4eIhWTpOvXEOn8uuxoh8FEaVMKxyIqfmmb 2/kA== X-Gm-Message-State: AOAM5321EtSfjKUOPal6RTkz5/OSyCBY6ajEB71k3qcqt9GYfx1ClIkq 2u2FOH41B7Dfvgrz4u9Djlx8KsR5ee08ldEMc04= X-Google-Smtp-Source: ABdhPJyP7mxOtbeJE8l5FU8alaEx2R14JHPKAwo/lHGHxX72rfzmK2GQj7zOHg+oDgafPxrKjIXobz+11+k4872pde0= X-Received: by 2002:aa7:d543:0:b0:416:13eb:6fec with SMTP id u3-20020aa7d543000000b0041613eb6fecmr24331462edr.348.1647330207939; Tue, 15 Mar 2022 00:43:27 -0700 (PDT) MIME-Version: 1.0 References: <032301d835a2$86214110$9263c330$@nextmovesoftware.com> <6ee61d3-ffac-7667-9dc0-692699e9e12f@hippo.saclay.inria.fr> <006301d8383d$d34e1560$79ea4020$@nextmovesoftware.com> In-Reply-To: <006301d8383d$d34e1560$79ea4020$@nextmovesoftware.com> From: Richard Biener Date: Tue, 15 Mar 2022 08:43:17 +0100 Message-ID: Subject: Re: [PATCH] PR tree-optimization/101895: Fold VEC_PERM to help recognize FMA. To: Roger Sayle Cc: GCC Patches , Marc Glisse Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2022 07:43:31 -0000 On Tue, Mar 15, 2022 at 8:25 AM Roger Sayle wrote: > > > Hi Richard and Marc, > Many thanks for both your feedback on my patch for PR 101895. > Here's version 2 of this patch, incorporating all of the suggested improvements. > The one minor complication is that the :s qualifier doesn't automatically > recognize that a capture already has two (or N) uses in a pattern, > so I have to manually confirm that there are no other uses of the mult > using num_imm_uses. > > This revision has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check with no new failures. Ok for mainline? OK. Thanks, Richard. > 2022-03-15 Roger Sayle > Marc Glisse > Richard Biener > > gcc/ChangeLog > PR tree-optimization/101895 > * match.pd (vec_same_elem_p): Handle CONSTRUCTOR_EXPR def. > (plus (vec_perm (mult ...) ...) ...): New reordering simplification. > > gcc/testsuite/ChangeLog > PR tree-optimization/101895 > * gcc.target/i386/pr101895.c: New test case. > > > Thanks in advance, > Roger > -- > > > -----Original Message----- > > From: Richard Biener > > Sent: 14 March 2022 07:38 > > To: GCC Patches > > Cc: Roger Sayle ; Marc Glisse > > > > Subject: Re: [PATCH] PR tree-optimization/101895: Fold VEC_PERM to help > > recognize FMA. > > > > On Sun, Mar 13, 2022 at 12:39 AM Marc Glisse via Gcc-patches > patches@gcc.gnu.org> wrote: > > > > > > On Fri, 11 Mar 2022, Roger Sayle wrote: > > > > > > +(match vec_same_elem_p > > > + CONSTRUCTOR@0 > > > + (if (uniform_vector_p (TREE_CODE (@0) == SSA_NAME > > > + ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) > > > +: @0)))) > > > > > > Ah, I didn't remember we needed that, we don't seem to be very > > > consistent about it. Probably for this reason, the transformation > > > "Prefer vector1 << scalar to vector1 << vector2" does not match > > > > > > typedef int vec __attribute__((vector_size(16))); vec f(vec a, int b){ > > > vec bb = { b, b, b, b }; > > > return a << bb; > > > } > > > > > > which is only optimized at vector lowering time. > > > > Few more comments - since match.pd is matching in match.pd order the > > > > (match vec_same_elem_p > > @0 > > (...)) > > > > should come last. Please use > > > > +(match vec_same_elem_p > > + CONSTRUCTOR@0 > > (if (TREE_CODE (@0) == SSA_NAME > > && uniform_vector_p (... > > > > since otherwise we'll try uniform_vector_p twice on all CTORs (that are not > > uniform). > > > > > +/* Push VEC_PERM earlier if that may help FMA perception (PR101895). > > > +*/ (for plusminus (plus minus) > > > + (simplify > > > + (plusminus (vec_perm (mult@0 @1 vec_same_elem_p@2) @0 @3) @4) > > > + (plusminus (mult (vec_perm @1 @1 @3) @2) @4))) > > > > > > Don't you want :s on mult and vec_perm? > > > > Yes. Also for plus you want :c on it , likewise you want :c on the mult. The :c on > > the plus will require splitting the plus and minus case :/ > > > > Otherwise looks reasonable. > > > > Richard. > > > > > > > > -- > > > Marc Glisse