From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id CD3843858C52 for ; Thu, 19 Oct 2023 08:12:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD3843858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CD3843858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697703142; cv=none; b=uU7GjKxjMwWPZOzvHQjI74mLYiqKGF8TPM3HnPUM7f0O/YsIM1+UZtTymwbeVj11hykPCJyd4PMCMRFk7GkwUP/7thRsozTg1RxyNv4yfPBC2YwqSgcy25XggQBVJKCCnWy5Yln8eLJyoKUn/I5TSc+kDJRVC0anlJ/Rny2AW8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697703142; c=relaxed/simple; bh=/AU/4nu8fLZo1GYbBZqPeWcvnNYK6SUJ4oIlx1drVvM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=H+ftjKh0zu3oZbKg9rRA2UcRHkclc0HO3Je2mEBlpK8ZLd/sCZ/14kB1Ifebbiurah8fpuuiN4/lWSM6iULw9TjS/ZpUoIMpj8cghqOENYQZkRhNcuafVNdunr3PWn636hDEEfPvEaO3LpE/XwBC7bEu5Ts59SwNg8bmqeSdiTs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-408382da7f0so17079485e9.0 for ; Thu, 19 Oct 2023 01:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697703138; x=1698307938; darn=gcc.gnu.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7exPFW/rflFXxiEv979IleDk73JS5IOOWYdIJ3ULHMY=; b=nTklqIDr+JgjC/yftsM6vx0X7V8JT3rCGVmRjCKqhW9qa/7dO2FA3ZooGgUL770ZzD TJF29GD6MQWieiXVNduP8LuAOZYIF1FqAsF5uXQVqMx2qxKmyweCFPVeN4sb+R8esv/C tEzKUcKSOnOldUo7XW1B+ffxi+sv2InhuAoruCCnUnIBdRf+Qbw9EQCd6OG/09rKg+8g 493PDnMmUnPYmPv3jBh/J3ofhM0ibq6fAcByzbd9j0QX6NX8hk6wBmpIvK+kkZFZukJg FVnEFGnUSObbCdXO3aaaI1EomAMXb1adN7Sawu1te7G1/l2wKq81rLh88Ccp9SG2m+KI fsPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697703138; x=1698307938; h=content-transfer-encoding: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=7exPFW/rflFXxiEv979IleDk73JS5IOOWYdIJ3ULHMY=; b=EFju/oRSclAYM8PNnrWwl8dvhH6Fi4LTfBf5EHe9uhaUZzk7EDzHB3ww9Vdoz8AW6o JtcLF4EoDjINkZRsAp7egOR1QDfKSpXJ+05+0LqvcnpLGuuTAC7lURyiyEjJYy9QNxdq xMzm5sz0xa5KjkIPCaFeZ/JFhmk31zh3ok+J3qYhC/SfhaxRi2Gm/mNj15zVH0wQimr6 5iqoseVKspsZsRRD/bFldqsONNv0bzGtAVWuNfM3GmZlhcJmMiJFYCsPfllKY+HSUG+e F5nCVwOy3PMkg3hhuojHd1VRBob+g5DaEztofZHpkzDPyjuQ07NtlbbLU4F2ClFq09pg 74cg== X-Gm-Message-State: AOJu0YxcnUt0Kh+IRrxcmPkDZtcN0rAWgqkJiAymQeF1DMjrXG7sVCGE 4/bgVyAqWylSMWILl4K+0MPNwUplTLZb9ecvkmepuF1iVhg= X-Google-Smtp-Source: AGHT+IEt3N3cW+iRFV6yMQL+ifSifuEwlgd3pzIxkYnaUcC18bbZ7j3LvZvGM2e63C4KpVjoJ4cF05EN1oXOYjPt6Es= X-Received: by 2002:adf:f142:0:b0:32c:c35c:2eea with SMTP id y2-20020adff142000000b0032cc35c2eeamr816019wro.6.1697703137758; Thu, 19 Oct 2023 01:12:17 -0700 (PDT) MIME-Version: 1.0 References: <19a5df20-af1e-37b2-3a7d-e35bf4f1bcb1@inria.fr> In-Reply-To: <19a5df20-af1e-37b2-3a7d-e35bf4f1bcb1@inria.fr> From: Mathieu Malaterre Date: Thu, 19 Oct 2023 10:12:05 +0200 Message-ID: Subject: Re: missed: not vectorized: relevant phi not supported: found_14 = PHI To: gcc-help Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 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: Hi Marc, On Thu, Oct 19, 2023 at 9:17=E2=80=AFAM Marc Glisse = wrote: > > On Thu, 19 Oct 2023, Mathieu Malaterre via Gcc-help wrote: > > > After reading this SO post (*), I became curious as to what my gcc > > would do with the following code. It turns out that I cannot make any > > sense of the output: > > > > % gcc -fopt-info-missed -std=3Dc11 -O3 -c generic.c > > generic.c:4:21: missed: couldn't vectorize loop > > generic.c:2:5: missed: not vectorized: relevant phi not supported: > > found_14 =3D PHI > > If you try again with a snapshot of gcc-14, it does vectorize, although > the result doesn't seem as nice as what clang produces. > (in general I would also suggest adding -march=3Dnative or some recent ar= ch) > > > Doing a quick search did not reveal anything meaningful. If my > > understanding is correct this is a basic information level (not meant > > for GCC developers): > > > > * https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#index-fopt-= info > > > > So my question is: what should the following sentence indicates > > > > ... > > missed: not vectorized: relevant phi not supported: found_14 =3D PHI > > > > ... > > Some information is hard to translate to a user-understandable language > that refers to source code, this deep in the optimization, although in > this case the message is not very informative even for a gcc dev. > -fdump-tree-vect-details generates a file with more information, but that > can be hard to understand if you are not used to it. > > In this loop, some variables are 16 bits (haystack, needle), while the > reduction variable is 32 bits, and gcc has a hard time vectorizing mixed > sizes (and it doesn't realize that 'found' could be narrowed). If you > declare 'found' as 'short' instead, something different happens. Thanks very much for your answer, very helpful ! I was able to vectorize a different piece of C code, just using your trick. The type being reduced must be of the same type as the vector elements. I still do not understand what `PHI`, `found_14` or `` refer to exactly, but I'll continue studying the *.vect output. > > % cat generic.c > > #include > > int hasmatch(uint16_t needle, const uint16_t haystack[4]) { > > int found =3D 0; > > for (int i =3D 0; i < 4; ++i) { > > if (needle =3D=3D haystack[i]) { > > found =3D 1; > > } > > } > > return found; > > } > > > > (*) https://stackoverflow.com/questions/74803190/fastest-way-to-find-16= bit-match-in-a-4-element-short-array > > > > Thanks ! > > -- > Marc Glisse -- Mathieu