From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by sourceware.org (Postfix) with ESMTPS id 4A28B3858D20 for ; Fri, 2 Dec 2022 09:51:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A28B3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-3b56782b3f6so43203337b3.13 for ; Fri, 02 Dec 2022 01:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q0IAj4WoqwGpQ7cDKf6Ja/Dy2203mx5UC4JCMVlgNnY=; b=FPV9PdlB4EPnxVRJLrGhLiqGex+UX5alC2AaoUoi8ihKy6qjCkqzLzlh1XF5ZT3tZe UUZecIniCuHdGDVTxBeI7lwZc20pwT8qk/lloE750BsZl6klK1u+/VBXhWE1AYM1zubT j8jF9J5OzJGhQSITqWW5DTl0cN2Lk8nfB86OoI8b1xHL6mqMzl/+lVGS1nZsD6ZyGS/o zD4o7B5Pg+3+3XxuUK4deEbggcVq0OHsnsNgsqYMsg+w4haXN1fOSDSuj0BP9wUaqYQD C/IWyTz7mKkqJXdlDEkG0nYjZ8wQPR4Wtjw+u4c5VL/5C8V5b5d3mBnrwIk+3D0ZTQdY Q/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q0IAj4WoqwGpQ7cDKf6Ja/Dy2203mx5UC4JCMVlgNnY=; b=RABgsfgrPm6WJRH6yhRdwqCV1bcCmwBmRqqnMMO5o0hiG2J2MrfMF9+ykTUSXBXdRt DQS4Ka5MgSpsx4WJ2bExeeSzH5DnVBNV2vF9aawW0sVxpv03I46hLX4Gt4DRBeWud6Mh bySMbbw2jMw2qXGkbQhW+M4ibCd4JuHjMar5UUAHVK3cpbYfyzyzSp8EFZyDCW43oxO3 E+LLXES4j6V0u501Y+YhxNB1wEZpstnEz0Y0IkOlcG46ad4Z08i07DlAAZ3SjyIAjQ4K cY3FGzO9MgQ82gjh/nU5EvjVnZuC+d4SuaIqKmtisaLuxMgG0TREvmw0edFuUmHbvbMW BkMQ== X-Gm-Message-State: ANoB5plYW6zUvZM4CjObRx+ttA1p69BvMiv2VFVPAQ8ERacs0N0LGKNs jfS9WzVfxGGYH9h5kPGJp8ZbrxKzW/Y7cMMmoMw= X-Google-Smtp-Source: AA0mqf4QwDWIEAfNbijKAMYv7mrm0tUi7nEd8V45dwHA3LFaj0liAWLBd0whDt4AnMu6CXij7Lei/tnZBkPbDTqRL68= X-Received: by 2002:a81:9e13:0:b0:3b6:3e40:7c34 with SMTP id m19-20020a819e13000000b003b63e407c34mr37015011ywj.422.1669974671604; Fri, 02 Dec 2022 01:51:11 -0800 (PST) MIME-Version: 1.0 References: <002201d8ae8b$d11fa9b0$735efd10$@nextmovesoftware.com> In-Reply-To: From: Uros Bizjak Date: Fri, 2 Dec 2022 10:51:00 +0100 Message-ID: Subject: Re: [PATCH] i386: Save/restore recog_data in ix86_vector_duplicate_value [PR106577] To: Jakub Jelinek Cc: Richard Biener , richard.sandiford@arm.com, Roger Sayle , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.1 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Dec 2, 2022 at 10:39 AM Jakub Jelinek wrote: > > Hi! > > On Tue, Aug 16, 2022 at 09:14:06AM +0100, Richard Sandiford via Gcc-patches wrote: > > IMO the correct low-effort fix is to save and restore recog_data > > in ix86_vector_duplicate_value. It's a relatively big copy, > > but the current code is pretty wasteful anyway (allocating at > > least a new SET and INSN for every query). Compared to the > > overhead of doing that, a copy to and from the stack shouldn't > > be too bad. > > The following patch does that. > It isn't the first spot in the compiler that does that, not even the first > spot in the i386 backend. > In i386-expand.cc beyond these 2 recog_memoized calls there is one in > expand_vselect, but I think it is unlikely we'd run into these issues trying > to expand new permutations from splitters. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2022-12-02 Jakub Jelinek > > PR target/106577 > * config/i386/i386-expand.cc (ix86_vector_duplicate_value): Save/restore > recog_data around recog_memoized calls. > > * gcc.target/i386/pr106577.c: New test. OK. Thanks, Uros. > > --- gcc/config/i386/i386-expand.cc.jj 2022-12-01 09:29:15.233466321 +0100 > +++ gcc/config/i386/i386-expand.cc 2022-12-01 14:05:55.901157211 +0100 > @@ -15187,6 +15187,10 @@ ix86_vector_duplicate_value (machine_mod > bool ok; > rtx_insn *insn; > rtx dup; > + /* Save/restore recog_data in case this is called from splitters > + or other routines where recog_data needs to stay valid across > + force_reg. See PR106577. */ > + recog_data_d recog_data_save = recog_data; > > /* First attempt to recognize VAL as-is. */ > dup = gen_vec_duplicate (mode, val); > @@ -15212,6 +15216,7 @@ ix86_vector_duplicate_value (machine_mod > ok = recog_memoized (insn) >= 0; > gcc_assert (ok); > } > + recog_data = recog_data_save; > return true; > } > > --- gcc/testsuite/gcc.target/i386/pr106577.c.jj 2022-12-01 14:13:03.973872383 +0100 > +++ gcc/testsuite/gcc.target/i386/pr106577.c 2022-12-01 14:13:03.973872383 +0100 > @@ -0,0 +1,10 @@ > +/* PR target/106577 */ > +/* { dg-do compile { target int128 } } */ > +/* { dg-options "-O2 -mavx" } */ > + > +int i; > +void > +foo (void) > +{ > + i ^= !(((unsigned __int128)0xf0f0f0f0f0f0f0f0 << 64 | 0xf0f0f0f0f0f0f0f0) & i); > +} > > > Jakub >