From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 B77D53858409 for ; Tue, 14 Nov 2023 17:51:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B77D53858409 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 B77D53858409 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=1699984300; cv=none; b=CnvzrYwXUKonPhf8XVBaQfrWf0HGuh+1qWPw3Fr43TTgnL8T6JK2j5vZd70anM7SOVEdhI6NgkGfHwgvg0kPpwdiIT1x87jDqfAKILNHuQJYPETEbHzksM9mHoLjuT0Y+FUYNGMCIAnfKDBY7Rw8ktj89auowD3Ju9T8pw7GP4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699984300; c=relaxed/simple; bh=3U2+udB7u+tooxeYCnWbN3mSPgHxUtLsD3wMMtTIi00=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=qwfi0XbqeKmqOVkVSV3d0K1PYg7qFWcBjA/atrTwZGxaFqHqIZ1tK6Cx61FzRxwr/+SNLaYZRWs8kQGPnFhzQ7FJmy+jqh8k9rb38NSVbFaI00ih1GXsfgVFIoRAIdWth0bz04ocIzipSPyNVPjrDJWumATtNFgyiNV9BUqXDPM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699984298; 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:in-reply-to:in-reply-to: references:references; bh=b2ea7oYoyOex4EbUKUt9OLXpCxu9tPgeOAknzaBzmaw=; b=UN5h1U2Yd+XYO+YXeTirjBuXW1jfgCQSsLj4Sf+D+r/WM0QQORXgXJ5dwHzJQD58XJmh38 7oK6X6DgNWN/K5e9ga1jTcsJ/AG6ar954aFaN0qKYU3wx2LFUYJOhkMCDIivc1qAsOWaU0 wkfzytGjUeyL7i8w2L7IrKg/rp46QE8= 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-587-cfWxBbG8PxiZYsbiS9yJ3Q-1; Tue, 14 Nov 2023 12:51:34 -0500 X-MC-Unique: cfWxBbG8PxiZYsbiS9yJ3Q-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 9F6F9185A797; Tue, 14 Nov 2023 17:51:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C58540C6EB9; Tue, 14 Nov 2023 17:51:34 +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 3AEHpVsM1910393 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 18:51:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3AEHpUfL1910392; Tue, 14 Nov 2023 18:51:30 +0100 Date: Tue, 14 Nov 2023 18:51:30 +0100 From: Jakub Jelinek To: Uros Bizjak , Segher Boessenkool Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [committed] i386: Return CCmode from ix86_cc_mode for unknown RTX code [PR112494] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 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,WEIRD_PORT 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 Mon, Nov 13, 2023 at 10:49:23PM +0100, Uros Bizjak wrote: > Combine wants to combine following instructions into an insn that can > perform both an (arithmetic) operation and set the condition code. During > the conversion a new RTX is created, and combine passes the RTX code of the > innermost RTX expression of the CC use insn in which CC reg is used to > SELECT_CC_MODE, to determine the new mode of the comparison: > > Trying 5 -> 8: > 5: r98:DI=0xd7 > 8: flags:CCZ=cmp(r98:DI,0) > REG_EQUAL cmp(0xd7,0) > Failed to match this instruction: > (parallel [ > (set (reg:CC 17 flags) > (compare:CC (const_int 215 [0xd7]) > (const_int 0 [0]))) > (set (reg/v:DI 98 [ flags ]) > (const_int 215 [0xd7])) > ]) > > where: > > (insn 5 2 6 2 (set (reg/v:DI 98 [ flags ]) > (const_int 215 [0xd7])) "pr112494.c":8:8 84 {*movdi_internal} > (nil)) > > (insn 8 7 11 2 (set (reg:CCZ 17 flags) > (compare:CCZ (reg/v:DI 98 [ flags ]) > (const_int 0 [0]))) "pr112494.c":11:9 8 {*cmpdi_ccno_1} > (expr_list:REG_EQUAL (compare:CCZ (const_int 215 [0xd7]) > (const_int 0 [0])) > (nil))) > > x86_cc_mode (AKA SELECT_CC_MODE) is not prepared to handle random RTX > codes and triggers gcc_unreachable() when SET RTX code is passed to it. > The patch removes gcc_unreachable() and returns CCmode for unknown > RTX codes, so combine can try various combinations involving CC reg > without triggering ICE. > > Please note that x86 MOV instructions do not set flags, so the above > combination is not recognized as a valid x86 instruction. > > PR target/112494 > > gcc/ChangeLog: > > * config/i386/i386.cc (ix86_cc_mode) [default]: Return CCmode. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/pr112494.c: New test. > > Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. For me the test ICEs with RTL checking on both x86_64-linux and i686-linux. pr112494.c:17:1: internal compiler error: RTL check: expected elt 0 type 'e' or 'u', have 'E' (rtx unspec) in try_combine, at combine.cc:3237 This is on 3236 /* Just replace the CC reg with a new mode. */ 3237 SUBST (XEXP (*cc_use_loc, 0), newpat_dest); 3238 undobuf.other_insn = cc_use_insn; in combine.cc, where *cc_use_loc is (unspec:DI [ (reg:CC 17 flags) ] UNSPEC_PUSHFL) on which XEXP (guess combine assumes CC must be used inside of a comparison). Jakub