From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 6EF793858D20 for ; Tue, 8 Aug 2023 13:28:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EF793858D20 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-pg1-x52b.google.com with SMTP id 41be03b00d2f7-53482b44007so3308259a12.2 for ; Tue, 08 Aug 2023 06:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691501318; x=1692106118; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LbO7IvET6VLUyjmUQApeKYIW/baVpySGNHP2ZsHJ4WE=; b=CgVZuhmN/3mBM6ijJ+Jz/Twjsaln1HqmJRbUzmwOxDoHErBx45Ra56UekZr7DS9JYY PDmWsdUNm3YgSAJy0OTsA4DL0EZOXdY9z6TtKbOzlS73nI0ZYIS+k7cCTxrE//wD70Ow l9J2wCUioBb503lH6OTfzFFfd3cYMHFbSa0mAkDNS92sZi1RRrEOcR0olnwFR/HEXkav /yQuB3qhwCG4gkPKotR7ujnrcdNGmRc08fufZcdP7cnIYJTeBt1I8QwRwx4bQ5mdlMEf cpJKHWoRPTyv0/kPpqq1RDyPt8jnRmxDandiBGtqfqNI02pubFy+yqJDejNIcdtrxPs0 8VFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691501318; x=1692106118; h=content-transfer-encoding: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=LbO7IvET6VLUyjmUQApeKYIW/baVpySGNHP2ZsHJ4WE=; b=B0213SBckPdIpK8Zwh5xOa5TNnn+tzZGdXr7dMR7J/Ye3qnW8ITgZtwStAc8Vt+4Ex 1TBtZsWXc76Y2E4pP+x+IZRk19jjw3srzRlFcv/4VGUB9AneOfFGazEY47N8JYjNKdM/ aEcPHRwVWL9lrTdvHWL8AjrYBxkh1PNrn+RrJZdRPGUVmG/x13cuMZIY21PG01XUEeFd I75nkBNg4QH5QbDlsHDb2nbMEdkXOgSotuj4BUZtAn/CHSt9OZXytbrXM0RjfKQZHcYD A4FyGri4ijOyUTEQDaiftBK7eDvGntGOJTKPoJy3mUfaE5Q8Oyk66Y26PEA5JCneou8y rMAg== X-Gm-Message-State: AOJu0Yx3ix1TvFKYOw3F8COZcHU8pNu5FGnGVL4DwFd0/0rlvg8m5J4Y O1goN+p8a5yDWqHiG9u2kmdL9a6zQxOPWHmLKpfNQwSa7qs= X-Google-Smtp-Source: AGHT+IH07VADiqFPzPnz19TyPO6UcPXkU+Qs6p8/znZF6mRXyRVz/PXJoqnZB8NFdfoPQJ1rW1qqZylSY8xHBgBOqos= X-Received: by 2002:a17:90a:f287:b0:268:93d:b936 with SMTP id fs7-20020a17090af28700b00268093db936mr9163540pjb.18.1691501318229; Tue, 08 Aug 2023 06:28:38 -0700 (PDT) MIME-Version: 1.0 References: <4d0d53a0-20d2-5b98-c4f9-67b624a27269@gmail.com> <86bb6ae6-1eb5-040a-19ef-bab1e1bc6f4e@gmail.com> <2a568bea-04db-ebd1-8b0d-f2f124f0b183@gmail.com> In-Reply-To: <2a568bea-04db-ebd1-8b0d-f2f124f0b183@gmail.com> From: Richard Biener Date: Tue, 8 Aug 2023 15:28:21 +0200 Message-ID: Subject: Re: [PATCH] vect: Add a popcount fallback. To: Robin Dapp Cc: gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 Tue, Aug 8, 2023 at 3:06=E2=80=AFPM Robin Dapp wro= te: > > > Hmm, the conversion should be a separate statement so I wonder > > why it would go wrong? > > It is indeed. Yet, lhs_type is the lhs type of the conversion > and not the call and consequently we compare the precision of > the converted type with the popcount input. > > So we should probably rather do something like: > > + tree call_lhs =3D gimple_call_lhs (call_stmt); > + > /* Input and output of .POPCOUNT should be same-precision integer. */ > - if (TYPE_PRECISION (unprom_diff.type) !=3D TYPE_PRECISION (lhs_type)) > + if (TYPE_PRECISION (unprom_diff.type) !=3D TYPE_PRECISION (TREE_TYPE (= call_lhs))) > return NULL; We seem to be looking at promotions of the call argument, lhs_type is the same as the type of the call LHS. But the comment mentions .POPCOUN= T and the following code also handles others, so maybe handling should be moved. Also when we look to vectorize popcount (x) instead of popcount((T)= x) we can simply promote the result accordingly. It looks like vect_recog_popcount_clz_ctz_ffs_pattern is specifcally for the conversions, so your fallback should possibly apply even when not matching them. > Regards > Robin