From patchwork Wed Nov 29 09:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1869616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Wq1nST6i; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4SgDgs3cdxz1yST for ; Wed, 29 Nov 2023 20:35:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E7CC3858037 for ; Wed, 29 Nov 2023 09:35:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 2F7133858CD1 for ; Wed, 29 Nov 2023 09:34:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F7133858CD1 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 2F7133858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701250491; cv=none; b=ZjMd8k41/ZESP5nlvNQrS6lSuVhAJOngP0/O3Lc4JtGf9xN5Jug77yQYYKF6xjTSmytX3ywA1hJavfjZ6cPk5GyzdITnX9KbTDKIuEEzzNF/98pAfbAkhn1RHIA5T40Xziwid9G1BHPgttVQlBVJDfyME/Ra+oe9RNEjqeyY+IU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701250491; c=relaxed/simple; bh=yjW1TIy6GvHgFmmcT9LmyYH7n9SBn+YfVEKrfQ/B0Lk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=PPFDBmnhPRV79nOjphYGUwQ+iqj3V27ftAS9wwv34KlU5XTCdFNOpnKVOEsSg+dlgdD9gRcaJO84GM0YyDpkshDZbMDCqhdeBd3l5WBlleCUjlcgzlWR92p38nTwUgh2WPdD2z5nFUxsFU7FuX2IPgM+SAMllkeUI25fINl0+BM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-54ba86ae133so2188866a12.2 for ; Wed, 29 Nov 2023 01:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701250488; x=1701855288; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=TrMW49PJFtZSYrSEQD4PVINDg9WEoACOnLvIomTHp9A=; b=Wq1nST6isUJMGn6U7TALz5fqDqGKhIupRTZoQgebFL4b3IYBehIC4WbFHU4Nwxv9Vd F4F5pxvlpgLDQlEHt5MMocbhvYKl/3bDlSfrpUKY7Isu6FwyszL+hQyHKHwcORD4k4X6 yQjXbwVgZYpN1BQ9/vdYtqomCbDIELqmbsulnIWh4l+FW3NlgWI66Go4IfOyS2fr3yxj ZBtaitPJWWF3Jq4JVmeWYJk+AjOfQOoMaQYSxuzJB/jRBrnevRETABHq5JQ8XSrxo3xw rks2Br3hk/kCSjJ/5se1ei/qL5copzPRnUeM43m6AS1YNkikklVWDjgrU1e1p0xVtTN4 wP1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701250488; x=1701855288; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=TrMW49PJFtZSYrSEQD4PVINDg9WEoACOnLvIomTHp9A=; b=IfJTKNsb4N9Y+QvzLu8EwMBVKxtB7OqMWlNux9TrLF3m7c/aVs4PPgH5fdX+TKNxcB L1/9AQ8KEMdyWuVUGBZIjXmjGZWCp0RbUNtHixmDxWO0EB23Kvxkfk01T2WKBqvkRL1t rP2BtjewPUcKaXUZf43CiEpsHvCi3uH/5Pb/w+niGeHLJAk8mmukDH7kYrj34lqf4vas /v46txz8945T5QrCfAd15Ap+sn0hdqhC199/dfzStdTJScqoV65A7JqSE8iDNmA2c6x2 81H5NmbTb4D0C6uVxIhsylvS7k1Udx3QrcSrYYZei96JSS7ad/WgNdBcZXzcq4HE95yi EFsg== X-Gm-Message-State: AOJu0YzCUi5tWUEbhJNFw/zB9y8Wc2MheREfFkIA3zJfSvq7xy7KyH4H BfQUTxXLIkO1R+aAX52kZHRRcD/Ldd4ZvjzA32YOKe52iU0Ung== X-Google-Smtp-Source: AGHT+IH6PXvRYfYpnpfLapsWEXEU7nwj0EhXH1ZdeuU+6GI1rv+O6cq1IJDlI1zdUS4T+U41S0e7vUJ9VY9a2uRI4Jk= X-Received: by 2002:a50:a693:0:b0:53e:5dad:dce0 with SMTP id e19-20020a50a693000000b0053e5daddce0mr13317994edc.3.1701250488058; Wed, 29 Nov 2023 01:34:48 -0800 (PST) MIME-Version: 1.0 From: Uros Bizjak Date: Wed, 29 Nov 2023 10:34:36 +0100 Message-ID: Subject: [PATCH] combine: Fix ICE in try_combine on pr112494.c [PR112560] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org The compiler, configured with --enable-checking=yes,rtl,extra ICEs with: 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 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) combine assumes CC must be used inside of a comparison and uses XEXP (..., 0) without checking on the RTX type of the argument. Skip the modification of CC-using operation if *cc_use_loc is not COMPARISON_P. PR middle-end/112560 gcc/ChangeLog: * combine.cc (try_combine): Skip the modification of CC-using operation if *cc_use_loc is not COMPARISON_P. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. OK for master? Uros. diff --git a/gcc/combine.cc b/gcc/combine.cc index 6344cd3c9f2..a270138b59f 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -3184,11 +3184,16 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, && (cc_use_loc = find_single_use (SET_DEST (newpat), i3, &cc_use_insn))) { - compare_code = orig_compare_code = GET_CODE (*cc_use_loc); - if (is_a (GET_MODE (i2dest), &mode)) - compare_code = simplify_compare_const (compare_code, mode, - &op0, &op1); - target_canonicalize_comparison (&compare_code, &op0, &op1, 1); + if (COMPARISON_P (*cc_use_loc)) + { + compare_code = orig_compare_code = GET_CODE (*cc_use_loc); + if (is_a (GET_MODE (i2dest), &mode)) + compare_code = simplify_compare_const (compare_code, mode, + &op0, &op1); + target_canonicalize_comparison (&compare_code, &op0, &op1, 1); + } + else + cc_use_loc = NULL; } /* Do the rest only if op1 is const0_rtx, which may be the