From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by sourceware.org (Postfix) with ESMTPS id DC5063858D3C for ; Mon, 7 Nov 2022 03:29:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC5063858D3C 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-x112c.google.com with SMTP id 00721157ae682-370547b8ca0so93470947b3.0 for ; Sun, 06 Nov 2022 19:29:34 -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=rK1VkwQfuA1RAFCTPTCTruudu7r6r0ZLuZx4HBHLUzc=; b=iLAnuVnpf2KeJ1tYyWMMZ7ALKbQ/FG2aejgL0aR0kmPpTrsWjlSx0SHXGeyvJYKUMu I87SvUC/DY41XG3gbxvOLqhkYwV0ZzSbfltlDdBgT/0i8ULVvYqyaeTWsqQWxggU4gIH S6j1yn7nwAwkeFmQEQvvW6eE9a6dt7xjp+uoF5TnSpj+0OobFgGWK0A30YmgsoAa5Agb Ys794w1jVD7bV7nZLWfnps4dr6YYLX8+YcW6ciCcSkAHZifJ1FHGv93Nk42Jxi18vIIb LUmU6Pp9zwxVBlY1MsV7oA94N98AJrXRFDcZQov9FQRpWRbLxQUWRwjbRopRUjwEXeBq 6CPA== 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=rK1VkwQfuA1RAFCTPTCTruudu7r6r0ZLuZx4HBHLUzc=; b=MgzNGbsI2/ZJ/O2zxKfDbgMvOcEmC9ymoKXKO+gONMKOTMtrxM2ri+FBYrn1dI8Ue2 a7biTJ1Ynek2B9iIw41rNpk81MKXZhfItK+FyKk7wF/5dYtOMuY7VqU85pKvGpJYDkfw 2HGCfUkJY2xBgVuIcQA21h3GWnpmKLrnv2ribUJqQponwbUZPsqwETFrgAC5jN6+xhQL u19Z83qRYNN0cbR49cNf3crybplCR+ScVA0fl263OtoGMJJDna4Cd5MXRxDWhEM+yJJD riGfsL93cPkUq7RWBsPSM1pGZ6EToxqyXjD8EU08e10TzYV7BvF/Nq3vaFZwKoVsFycT 2QCw== X-Gm-Message-State: ACrzQf3osSp53MeuQb3kbdGoEmZSX5SKhTkO0xR4yf2d2EtlWfmZLSd2 WjOf1dKHxe/gcU+VY+tfD3juZgZsQjVpCitDvQs= X-Google-Smtp-Source: AMsMyM4G0E7Ic5XTEk6hSgjUL9lpyV7XMzVLCSV5ZD1fUFRwNaxEQ7iwWvDoAKbND3GIHXTwakUKO2d4M/XDRqfKFKE= X-Received: by 2002:a81:4fc9:0:b0:36b:1a78:723b with SMTP id d192-20020a814fc9000000b0036b1a78723bmr45481919ywb.241.1667791774217; Sun, 06 Nov 2022 19:29:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Hongtao Liu Date: Mon, 7 Nov 2022 11:32:42 +0800 Message-ID: Subject: Re: simd, redundant pcmpeqb and pxor To: i.nixman@autistici.org Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.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 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 Sun, Nov 6, 2022 at 6:54 PM i.nixman--- via Gcc-help wrote: > > > Hello, > > look at this example(https://godbolt.org/z/TnGMsfMs6): > ``` > auto foo(const char *p) { > const auto substr = _mm_loadu_si128((const __m128i *)p); > return _mm_cmplt_epi8(substr, _mm_set1_epi8('0')); > } > ``` > and to the generated asm: > ``` > 1: foo(char const*): > 2: movdqu xmm0, XMMWORD PTR [rdi] > 3: pxor xmm1, xmm1 > 4: pcmpgtb xmm0, XMMWORD PTR .LC0[rip] > 5: pcmpeqb xmm0, xmm1 > 6: ret > ``` > look at line 5. > is there any reason for `pcmpeqb` instruction? Looks like a mis optimization from _4 = VIEW_CONVERT_EXPR<__v16qs>(_7); _3 = _4 <= { 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47 }; _5 = VIEW_CONVERT_EXPR(_3); --- this? Could you open a bugzilla for it https://gcc.gnu.org/bugzilla/ > > just for info, clang's output(https://godbolt.org/z/MPnvEMdhr): > ``` > 1: foo(char const*): > 2: movdqu xmm1, xmmword ptr [rdi] > 3: movdqa xmm0, xmmword ptr [rip + .LCPI0_0] > 4: pcmpgtb xmm0, xmm1 > 5: ret > ``` > > > best! -- BR, Hongtao