From patchwork Thu Nov 10 09:29:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 18027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp41114wru; Thu, 10 Nov 2022 01:30:30 -0800 (PST) X-Google-Smtp-Source: AMsMyM6ZpBQfOVShuPGP3qKlxQ1pFyW1DNImEPRxahVx2Vb1RMKwS1NUdoHVieBFxs+R0OkW5UyG X-Received: by 2002:aa7:c58a:0:b0:461:fc07:a821 with SMTP id g10-20020aa7c58a000000b00461fc07a821mr63850852edq.19.1668072630248; Thu, 10 Nov 2022 01:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668072630; cv=none; d=google.com; s=arc-20160816; b=gdoedMK3M2XIcGJXDHihU0b6vqLfAWy6G0+gQcncg4DEyXQSomXWN4DUDcqsRRDmOB y6HP2jVrITHcGKhD2lepWD4cQO/t+GfcTZewzgN9vtIlLNQ74UQpORbv/cvPMEZ/39gQ y+blIV5oPthSWW+hLw7M+Y7Jm+CNg16rcwHUfeQTSHpTLOzuY/UpJL+TYonW+V+nglWV oqFAmDX75GFZSTZhPdvUcgtIkVEGNOLT7Ok/42yPp5RQKgttV7rnwBJTyep034KsCpbO t8CUt1XfGdMieHJn91wvGcoTZ0ZY0CJHuwRfOFsSyfwEXrZD/OZl2pOaOeNBAWPjb58x wIdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=NmgHLbouS1F4+4MZQWNX0ijhz8cv2eFJq2ffCzj/PtA=; b=X6TFDH9GyG1bdVBDqp3rI8b2xKyAf57C8ai3Vs1f9yxlBbCkUEfjVQUmt78SRb23OR 0g7e6xk/9tE6Z3hnBArCxA8gVJvTXO/mhDkszlrgaY9fHfdDwwGxoW2wGd8zhjfKBo7V h/jQ2LdD1s7xyCXcY2ufM/klpldS8pChZEvNZd+vOHlh+4+vfrsq3TwuzaA4vl9KOouT i/DPlztQpMEgtHdt56uh8cpkuEHjtL9v9aJe/JWRtc41tZbaB9EXSlFv2RDy393AF+MD m8TWC20dJ/DUjbEJNfTKHO8DQsjR581ydlp/mSdvJZyluJKiioBIQOBdvorkZ7ZkcIgM LDxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xEasrMxu; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r26-20020aa7d15a000000b00447eb58b921si4240465edo.38.2022.11.10.01.30.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 01:30:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xEasrMxu; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41BAD3858425 for ; Thu, 10 Nov 2022 09:30:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41BAD3858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668072629; bh=NmgHLbouS1F4+4MZQWNX0ijhz8cv2eFJq2ffCzj/PtA=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xEasrMxu+lalqybqyaNto0CjLaLeKIcznUpVLNCofOucwyELfXPC5V7GXkdEwZpsp fSgVoERSsiJNVAM0Siz89tuNF/E1L98XOAXX5wDqrpuhXEiF7F9eMOmSRzAB/QP0Ra kxZSWFdO6bdi18gK+ZC1xwEccM6ZZQO6zmb4Ura4= 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 2043B3858D35 for ; Thu, 10 Nov 2022 09:29:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2043B3858D35 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-474-x2pt-8t2N8iat2GIGm-Ydg-1; Thu, 10 Nov 2022 04:29:23 -0500 X-MC-Unique: x2pt-8t2N8iat2GIGm-Ydg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D2A81C09B63; Thu, 10 Nov 2022 09:29:23 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC9271415114; Thu, 10 Nov 2022 09:29:22 +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 2AA9THQE3709495 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 10:29:18 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AA9TC9R3709494; Thu, 10 Nov 2022 10:29:12 +0100 Date: Thu, 10 Nov 2022 10:29:11 +0100 To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up ix86_expand_int_sse_cmp [PR107585] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749100926085635881?= X-GMAIL-MSGID: =?utf-8?q?1749100926085635881?= Hi! The following patch fixes ICE on the testcase. I've used GEN_INT incorrectly thinking the code punts on the problematic boundaries. It does, but only for LE and GE, i.e. signed comparisons, for unsigned the boundaries are 0 and unsigned maximum, so when say unsigned char adds one to 127 or subtracts one from 128 we need to canonicalize it. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-11-10 Jakub Jelinek PR target/107585 PR target/107546 * config/i386/i386-expand.cc (ix86_expand_int_sse_cmp): Use gen_int_mode rather than GEN_INT. * gcc.dg/pr107585.c: New test. Jakub --- gcc/config/i386/i386-expand.cc.jj 2022-11-08 12:21:48.704047171 +0100 +++ gcc/config/i386/i386-expand.cc 2022-11-09 14:40:12.157012775 +0100 @@ -4540,7 +4540,8 @@ ix86_expand_int_sse_cmp (rtx dest, enum rtvec v = rtvec_alloc (n_elts); for (i = 0; i < n_elts; ++i) RTVEC_ELT (v, i) - = GEN_INT (INTVAL (CONST_VECTOR_ELT (cop1, i)) + 1); + = gen_int_mode (INTVAL (CONST_VECTOR_ELT (cop1, i)) + 1, + eltmode); cop1 = gen_rtx_CONST_VECTOR (mode, v); std::swap (cop0, cop1); code = code == LE ? GT : GTU; @@ -4584,7 +4585,8 @@ ix86_expand_int_sse_cmp (rtx dest, enum rtvec v = rtvec_alloc (n_elts); for (i = 0; i < n_elts; ++i) RTVEC_ELT (v, i) - = GEN_INT (INTVAL (CONST_VECTOR_ELT (cop1, i)) - 1); + = gen_int_mode (INTVAL (CONST_VECTOR_ELT (cop1, i)) - 1, + eltmode); cop1 = gen_rtx_CONST_VECTOR (mode, v); code = code == GE ? GT : GTU; break; --- gcc/testsuite/gcc.dg/pr107585.c.jj 2022-11-09 14:52:37.554779118 +0100 +++ gcc/testsuite/gcc.dg/pr107585.c 2022-11-09 14:48:24.063258991 +0100 @@ -0,0 +1,13 @@ +/* PR target/107585 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned char __attribute__((__vector_size__ (16))) V; +char c; +void bar (int); + +void +foo (void) +{ + bar (((V) (c <= (V){127}))[2]); +}