From patchwork Fri Mar 15 08:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1912419 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BkpY/KgV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Twydf2JLFz1yWn for ; Fri, 15 Mar 2024 19:51:00 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70819385ED4A for ; Fri, 15 Mar 2024 08:50:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E71DA385735D for ; Fri, 15 Mar 2024 08:50:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E71DA385735D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E71DA385735D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710492616; cv=none; b=gzvSuNo7MUwpmIuKJqm04nsVj5Ab+pIQBoqqbc8/v66oGKsUkcJp4E1Bhx3u1/2sbiSBbH5/P/tde93Ni/QT7huDP+Ri0i1JyBMchW6zMlaYnfvlQq0N/s0Ogx/MM90ZuNtStZ/PG2kvbmJE/lKSh0/jKiN7tfsiavUzcaupz+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710492616; c=relaxed/simple; bh=uQimSbe/zJvI0gBwcTKeHUnSeWXp+d3Iuj5+A7k8k3Y=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=aBG7mbx84lYaI3r3c4F3kMUDGijErX7iU6Knv1ppnpbzuUYVbOFryJdYeMcwDw/Yk92YUOhswx992ijbqZjmc0s5WSPSwaDWSbN7462+XfzlI/8aZHYI2UA8i6Q45qNXpze2GYebb6QLbKQRHqyaNYooa+QsiujfvM9tcW7qVPk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710492608; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ozk2Kwi0FkkPVhTdjVpzhNmGTeJ8ZZnOrlOj9ni139Y=; b=BkpY/KgVA/7Mq7JeRTgbXGQgJL++/2//LlphzbkwSbpd4Xtbxgd0sop2M/eaRsJrXxExtc iKvpt6N7fxXr3Tf7QVOMZOueUg4ysx+Jz7IeG/mU4hFvNKNFSbAf5CNeDpgdpUiZ8kvPXH bPiGBB1ZD33SJGGJOcuBmAZP8WKYPjo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-266-Rz0XaaTTNlabhNRsfuJ-Xw-1; Fri, 15 Mar 2024 04:50:05 -0400 X-MC-Unique: Rz0XaaTTNlabhNRsfuJ-Xw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2E65800264; Fri, 15 Mar 2024 08:50:04 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.225.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68A4E492BD0; Fri, 15 Mar 2024 08:50:04 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 42F8o2472931223 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 15 Mar 2024 09:50:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 42F8o22M2931222; Fri, 15 Mar 2024 09:50:02 +0100 Date: Fri, 15 Mar 2024 09:50:02 +0100 From: Jakub Jelinek To: Uros Bizjak , Hongtao Liu Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix a pasto in ix86_expand_int_sse_cmp [PR114339] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! In r13-3803-gfa271afb58 I've added an optimization for LE/LEU/GE/GEU comparison against CONST_VECTOR. As the comments say: /* x <= 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 >= 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 == GE) comparison when testing if it should punt for 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. Jakub --- gcc/config/i386/i386-expand.cc.jj 2024-03-07 08:34:21.043802912 +0100 +++ gcc/config/i386/i386-expand.cc 2024-03-14 22:55:57.321842686 +0100 @@ -4690,7 +4690,7 @@ ix86_expand_int_sse_cmp (rtx dest, enum rtx elt = CONST_VECTOR_ELT (cop1, i); if (!CONST_INT_P (elt)) break; - if (code == GE) + if (code == 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.739076025 +0100 +++ gcc/testsuite/gcc.target/i386/pr114339.c 2024-03-14 22:38:59.736972124 +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 <= (V) {0, __LONG_LONG_MAX__ }; +} + +int +main () +{ + V t = foo ((V) { 0, 0 }); + if (t[0] != -1LL || t[1] != -1LL) + __builtin_abort (); +}