From patchwork Mon Dec 4 07:35:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 81255 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4C83385C6DA for ; Mon, 4 Dec 2023 07:36:08 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 5FE6B3858427 for ; Mon, 4 Dec 2023 07:35:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FE6B3858427 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 5FE6B3858427 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701675353; cv=none; b=cFbQKDWy4l5W2xCwNwsBsJcwUFzqiFYj3WBHazaoLneEwDEyaOeQ960VWv+3+hDZ41Dx9ssghwBoPxqOzb+d7XEX770LWMhR99j9+5taL+TnArG3GhvCn/wElDa+IARsusWrTxdjesVgcOdlCmoJel3PV65n9zreqQJtccJlE/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701675353; c=relaxed/simple; bh=+MMyBsOMmfD4UcoLilwHh6cvlTqSFMZ5soqExvnnmas=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=SJoIpy8Ifw8xoaLHtpetalAimtT8iAAxc54iDAI2mBXMSENItDTvoiUtpC3sNZYK94IDOppppZKCZ0i8cyF1yk7zZQdtkHW0T13XthdnvN4DG0L82Sg84oVyrcg3zW1JSC/CHAdYazYmGuoH5q44I4MEzuEqoRA3OuuGGFUpLvw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701675351; 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=JUnMXekU+oolKp9UvKS8im1oHlNw7kC7CHYukp4QFBI=; b=hFv2z90UEXOm5NRLKOCO3fGCVa3g1RT3Ek1Ddlx1QlQZt56GSsmGJjLX3EWMiFDRovGH5N pR8WuSH4Kp/VRm+Rpdun/UD6/yBn+LzFHD4oJK7HbykqDlrE2UX4MliBvfB9UxHcTGg6id hNzaPip94K1hcXxpkqGKzBWUUu+n3v8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-EeIqZatFPy2OXEjw06rPkg-1; Mon, 04 Dec 2023 02:35:20 -0500 X-MC-Unique: EeIqZatFPy2OXEjw06rPkg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 5B5EC2825E8E; Mon, 4 Dec 2023 07:35:20 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E99840C6EB9; Mon, 4 Dec 2023 07:35:20 +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 3B47ZHg12150103 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 4 Dec 2023 08:35:17 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3B47ZGb62150102; Mon, 4 Dec 2023 08:35:16 +0100 Date: Mon, 4 Dec 2023 08:35:16 +0100 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up signbit2 expander [PR112816] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 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+patchwork=sourceware.org@gcc.gnu.org Hi! The following testcase ICEs, because the signbit2 expander uses an explicit SUBREG in the pattern around match_operand with register_operand predicate. If we are unlucky enough that expansion tries to expand it with some SUBREG as operands[1], we have two nested SUBREGs in the IL, which is not valid and causes ICE later. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-12-04 Jakub Jelinek PR target/112816 * config/i386/sse.md (signbit2): Force operands[1] into a REG. * gcc.target/i386/sse2-pr112816.c: New test. Jakub --- gcc/config/i386/sse.md.jj 2023-12-01 08:10:42.311330174 +0100 +++ gcc/config/i386/sse.md 2023-12-02 09:53:45.489970487 +0100 @@ -5116,7 +5116,10 @@ (define_expand "signbit2" (match_operand:VF1_AVX2 1 "register_operand") 0) (match_dup 2)))] "TARGET_SSE2" - "operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (mode)-1);") +{ + operands[1] = force_reg (mode, operands[1]); + operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (mode)-1); +}) ;; Also define scalar versions. These are used for abs, neg, and ;; conditional move. Using subregs into vector modes causes register --- gcc/testsuite/gcc.target/i386/sse2-pr112816.c.jj 2023-12-02 10:00:23.623394880 +0100 +++ gcc/testsuite/gcc.target/i386/sse2-pr112816.c 2023-12-02 09:59:47.024909235 +0100 @@ -0,0 +1,16 @@ +/* PR target/112816 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2" } */ + +#define N 4 +struct S { float x[N]; }; +struct T { int x[N]; }; + +struct T +foo (struct S x) +{ + struct T res; + for (int i = 0; i < N; ++i) + res.x[i] = __builtin_signbit (x.x[i]) ? -1 : 0; + return res; +}