From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 551B03858D32 for ; Thu, 30 Nov 2023 09:09:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 551B03858D32 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 551B03858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701335361; cv=none; b=kWdU5K6HjXxsEtOjdiQP9t5Ccl8jS0jgXaj1bIMLx+RPU+7L+NRYgWX3fLJrYO4ldfChokGmExuGDEX4eXttSf9JSSSFjPHFB3vORWg1hqEN+XqERIlsbYITITU/0xca8ThKX0/YsAcYaSCpBNJOjwRt3OuTOIyrbGWBfgDzlbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701335361; c=relaxed/simple; bh=Yj8tqkuHXcj6idjMsNkqLHKqoGwrR3LDKzh6OZpO73A=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=MyFZssotxAb5ZXvlMvd50LcXlGHWvCwyKfmzNQ/Bfx0WhgHMOXGqXY0WzbcTGw6DcdJ3/BlFocUKc98j/tBVJtn+qn8MYMGMLDvTGZNE4AbKL/P30V46ahNe3Gz/WKHQuPU90YyW2JJCXkVOzVbRtqB5/WRuJXKWlhxymz578wI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a18ebac19efso28449566b.0 for ; Thu, 30 Nov 2023 01:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701335358; x=1701940158; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NMiKiLyNqTAG+ZowQ3gd33Cn1SEag+ZYm+Tdyay/Zsg=; b=HIjEhyjWeICyhTR6ZmdVtHRRphVun62BpWpXPRlpiRU0Z3iamcyIbSbvyrEGf2ARoX E5O0k+lygF2Y8vABtWRj8Ya+dwjLoHkt1CWF9YY0S/CxmCqJBZDKB5gSbQ+Fr1QDrNNp jp0I6fs2p/u0DcTBSuETDT5nPV9s7BvMv+u2R2FHN7KLlGvOJrE3bsMSuvjM0khsK89n YURJskqxT5IpKD7HWp0fFbN1k4V07hE5i2ukWUPmIh7Mk9Y7BGmiUAPM0Pc82yGE9fEN kQvuwWedMtLGkHOCtYT+s72tmD1xNicD3JtvUvSJvBHit/5bHMbjmcoLItURAry+GGJv sBvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701335358; x=1701940158; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMiKiLyNqTAG+ZowQ3gd33Cn1SEag+ZYm+Tdyay/Zsg=; b=XhtlAaVBrsLh+E7QSXUYboONqasWw+x50eVn+FKivnlHvJxwhmIsg0RKcfBo6tHmHr 9TKu+pssO4KKQBl0ChBoWnvfnQ02U/hqTGj52CJgqC1GK+QBORiEoD1+zTJTiPYqszpl uMs65Irkz0gvbRWwUMcQyuqRfxxBdS9O6UpvRDhvBFkvGLig66zoCuVbVQL1HZwIGbmn CjnITCED15Jd3OOIJKxQd/I6yCuVoTnmvguI7Trb0qO1ApsGbKAEL84PDx8Py2+k/yA7 pLZt6p0BqsIOfXQsqtehF7SO+ba/b9f4aGFUKkYAUOGsxfePSjDK92hpF75rYP4014s5 sGGw== X-Gm-Message-State: AOJu0YyfVkg8QGxcCrvx5wisZVW03kQXMWEfTJTzI9sGW39VpOsRaNqT S9YaxqaSkLnPOQBr0aa5Tyv4NEyKuhatt6A2i1E= X-Google-Smtp-Source: AGHT+IEHHsd4x9t0GpEF6wJzZJS9OBZ4tYPSimgdXHkkAdcLJXYcOPOSUiZVb5+DCtvmcX5yiKtOC1yS2+uQ0wq7LM4= X-Received: by 2002:a17:907:7da9:b0:9fd:9e54:a4fc with SMTP id oz41-20020a1709077da900b009fd9e54a4fcmr27063037ejc.15.1701335357443; Thu, 30 Nov 2023 01:09:17 -0800 (PST) MIME-Version: 1.0 References: <20231130081858.GH19790@gate.crashing.org> In-Reply-To: <20231130081858.GH19790@gate.crashing.org> From: Uros Bizjak Date: Thu, 30 Nov 2023 10:09:05 +0100 Message-ID: Subject: Re: [PATCH] combine: Fix ICE in try_combine on pr112494.c [PR112560] To: Segher Boessenkool Cc: Richard Biener , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Thu, Nov 30, 2023 at 9:21=E2=80=AFAM Segher Boessenkool wrote: > > Hi! > > On Wed, Nov 29, 2023 at 02:20:03PM +0100, Uros Bizjak wrote: > > On Wed, Nov 29, 2023 at 1:25=E2=80=AFPM Richard Biener > > wrote: > > > On Wed, Nov 29, 2023 at 10:35=E2=80=AFAM Uros Bizjak wrote: > > I was assuming that if the CC reg is not used inside the comparison, > > then the mode of CC reg is irrelevant. We can still combine the > > instructions into new insn, without updating the use of CC reg. > > It should never happen that the CC reg is not used, so what does this > mean? I was trying to say that when CC reg is used inside the comparison, e.g.: (define_insn "*setcc_qi" [(set (match_operand:QI 0 "nonimmediate_operand" "=3Dqm") (match_operator:QI 1 "ix86_comparison_operator" [(reg FLAGS_REG) (const_int 0)]))] "" "set%C1\t%0" and through the%C operand modifier we call put_condition_code, the mode of CC reg is checked and a different instruction is emitted, depending on the CC reg mode. Please also note that not all comparison operators are handled, so when the combine rewrites the comparison, it isn't necessarily supported. This is in contrast with: (define_insn "@pushfl2" [(set (match_operand:W 0 "push_operand" "=3D<") (unspec:W [(match_operand:CC 1 "flags_reg_operand")] UNSPEC_PUSHFL))] where we don't care about CC reg mode at all. The CC reg is not in the comparison, so the mode does not matter. The combination of instructions should not be limited by CC reg user in this case. > > Where it is used might not be a comparison of course, as in your > example. > > > && (cc_use_loc =3D find_single_use (SET_DEST (newpat), i3, > > &cc_use_insn))) > > { > > - compare_code =3D orig_compare_code =3D GET_CODE (*cc_use_loc); > > - if (is_a (GET_MODE (i2dest), &mode)) > > - compare_code =3D simplify_compare_const (compare_code, mode, > > - &op0, &op1); > > - target_canonicalize_comparison (&compare_code, &op0, &op1, 1); > > + if (COMPARISON_P (*cc_use_loc)) > > + { > > + compare_code =3D orig_compare_code =3D GET_CODE (*cc_use_lo= c); > > + if (is_a (GET_MODE (i2dest), &mode)) > > + compare_code =3D simplify_compare_const (compare_code, mo= de, > > + &op0, &op1); > > + target_canonicalize_comparison (&compare_code, &op0, &op1, = 1); > > + } > > + else > > + { > > + if (dump_file && (dump_flags & TDF_DETAILS)) > > + fprintf (dump_file, "CC register not used in comparison.\= n"); > > "Where the CCmode register is used is not a comparison". But more > compact if you can manage (I cannot). Perhaps "CCmode register user is not a comparison." ? Uros.