From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 979EB385B512 for ; Fri, 15 Mar 2024 09:43:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 979EB385B512 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 979EB385B512 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::230 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710495806; cv=none; b=OCGMvWuXel6pWKFsPVlo+Jx74bsacqUXZ1oCkzm6N/Vt7P8O42BZsgh7Iy/ahYmC40LmOOgnHxcHB6K1PGTqX3WsN/n2UyFUuXG03AQOOo+EJyXvaqLRFnk+pXH8h9MHtjTAcmsaaQT4M7miRFRzjxej7ZdY4yQeihtY0nbkdEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710495806; c=relaxed/simple; bh=svZZr0fequdfS59v9RbH7MHooCavRiyQ3dWgmOB7Ptw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=OS3HbThXQEoJPlJK9eAWPlycpqKPB9CoRu74An9iz8ICT7eal+31NN4rsEq19+fHUjym2fDYON7wk5MhUcPplHM+4vMDDdcHYOFXOFWr8FG+yxUuG8z2BtJureIes85J2A179jighUhQF5SDKs/p29mjOi4dJMAVrLhOofbtyOg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2d4360ab3daso27289291fa.3 for ; Fri, 15 Mar 2024 02:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710495802; x=1711100602; darn=gcc.gnu.org; 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=0zABbDY/t47kfkxDjyUal2A+wbz0iCAQrucdq5QT3Kc=; b=UyUguzNx1uQqCOvxfaNisZVVy/OYCRGtCBVpFeFKhNbqsemsoofOr4njP3gm2lKNNL jD1x/2vTCosAjGlJC4CmUubGEVj+1RmNVeUNqQ7YxQxR16fmjN0uzy27WNd9RXGU57l/ A1u1Z7O2NunqjEC1qoqKbBkTAVSRGlW3IdSyOEzb9wjqYgT4Cx9Zea9u0OmvkQTxiLct iskpFW08D+zPY9I+tLSUo3XUguZUZMPmrJTOiqxyiddCvTav/3siZ69NIIVMBkFYqc62 oavTA2wDeSbHiYVfXo4Oet0+LS0K6np4OySMN+4j9wxenIfF76Cigo/R67LeZxEFvank f7RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710495802; x=1711100602; 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=0zABbDY/t47kfkxDjyUal2A+wbz0iCAQrucdq5QT3Kc=; b=VDIrcr2KkcXxoibLhJyIjym0J3kLSCj9Y69SCkSVngiDCaaR+wzOf6Sd6LvKTkHb9k 60GQsSYmqxPyOTCN9Yn1mYXOOFDW5eSUGF159Qq5cUjPs92OKNyzCzpU+NjZSR/ov7fS nU8OcAkEcdfDaEg+qWLeppnQwMQITitvWsCLvM/gjzoTUxsI1z9oGUC4OAChTmFNXLyM SSfMcHRyzGTaIqrYvUHLNkO1/PftDkVNQtD1WmV9cgLMlxjJ91Lz/N2ldEZN5eKGc8Ik ZkCbR1nKwwn8Yui6VS4I6mC9rC1dHmQ9fLteM8R+TJmyr6UealllWwKO7+hIaPyDa1a5 6jFg== X-Forwarded-Encrypted: i=1; AJvYcCU9c+UXW3DjNLxAAO8Gn/2nt1jDH8lXIHeGaFBr07KkkVkHgRb+TF6zgYj3bzxx0ERz6LJ6CqDZ+93tDSrgr2ynYIwZ8/jljA== X-Gm-Message-State: AOJu0Yz3nYRdmmkqtu+AMIqSEtJYNRImouQ/waXIpKRtoj0pdI2ZSikf M45AvaBFb18oZTfDsySrukNyqYOVShWx7fXMZOf+zxsXljTnDXIq+sgatgloVWDWkpn6beF23qF JxTELPX7K2wznPyNBL8vbPCztHTU= X-Google-Smtp-Source: AGHT+IHKfwr5u/PekWCnn1o9oUiHS1/3nfNtc083YKTTiULlc8lj0MWvZ+0YshNQJLXAofl38xQHNdfCDrYMtd3u2CQ= X-Received: by 2002:a05:651c:19a1:b0:2d4:6d87:b56f with SMTP id bx33-20020a05651c19a100b002d46d87b56fmr3486237ljb.46.1710495801607; Fri, 15 Mar 2024 02:43:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Uros Bizjak Date: Fri, 15 Mar 2024 10:43:09 +0100 Message-ID: Subject: Re: [PATCH] i386: Fix a pasto in ix86_expand_int_sse_cmp [PR114339] To: Jakub Jelinek Cc: Hongtao Liu , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Mar 15, 2024 at 9:50=E2=80=AFAM Jakub Jelinek wr= ote: > > Hi! > > In r13-3803-gfa271afb58 I've added an optimization for LE/LEU/GE/GEU > comparison against CONST_VECTOR. As the comments say: > /* x <=3D cst can be handled as x < cst + 1 unless there is > wrap around in cst + 1. */ > ... > /* For LE punt if some element is signed maximum. *= / > ... > /* For LEU punt if some element is unsigned maximum. */ > and > /* x >=3D cst can be handled as x > cst - 1 unless there is > wrap around in cst - 1. */ > ... > /* For GE punt if some element is signed minimum. *= / > ... > /* For GEU punt if some element is zero. */ > Apparently I wrote the GE/GEU (second case) first and then > copied/adjusted it for LE/LEU, most of the adjustments look correct, but > I've left if (code =3D=3D GE) comparison when testing if it should punt f= or > signed maximum. That condition is never true, because this is in > switch (code) { ... case LE: case LEU: block and we really meant to > be what the comment says, for LE punt if some element is signed maximum, > as then cst + 1 wraps around. > > The following patch fixes the pasto. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2024-03-15 Jakub Jelinek > > PR target/114339 > * config/i386/i386-expand.cc (ix86_expand_int_sse_cmp) := Fix > a pasto, compare code against LE rather than GE. > > * gcc.target/i386/pr114339.c: New test. OK. Thanks, Uros. > > --- gcc/config/i386/i386-expand.cc.jj 2024-03-07 08:34:21.043802912 +01= 00 > +++ gcc/config/i386/i386-expand.cc 2024-03-14 22:55:57.321842686 +01= 00 > @@ -4690,7 +4690,7 @@ ix86_expand_int_sse_cmp (rtx dest, enum > rtx elt =3D CONST_VECTOR_ELT (cop1, i); > if (!CONST_INT_P (elt)) > break; > - if (code =3D=3D GE) > + if (code =3D=3D LE) > { > /* For LE punt if some element is signed maximum. = */ > if ((INTVAL (elt) & (GET_MODE_MASK (eltmode) >> 1)) > --- gcc/testsuite/gcc.target/i386/pr114339.c.jj 2024-03-14 22:58:04.73907= 6025 +0100 > +++ gcc/testsuite/gcc.target/i386/pr114339.c 2024-03-14 22:38:59.73697= 2124 +0100 > @@ -0,0 +1,20 @@ > +/* PR target/114339 */ > +/* { dg-do run } */ > +/* { dg-options "-O2 -Wno-psabi" } */ > +/* { dg-additional-options "-mavx" { target avx_runtime } } */ > + > +typedef long long V __attribute__((vector_size (16))); > + > +__attribute__((noipa)) V > +foo (V a) > +{ > + return a <=3D (V) {0, __LONG_LONG_MAX__ }; > +} > + > +int > +main () > +{ > + V t =3D foo ((V) { 0, 0 }); > + if (t[0] !=3D -1LL || t[1] !=3D -1LL) > + __builtin_abort (); > +} > > Jakub >