From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 6869C386182D for ; Sun, 23 Jun 2024 20:55:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6869C386182D 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 6869C386182D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719176145; cv=none; b=WOc78HXywvO7rk0RQ2rXi2IXZckZt66srWvKpAGfBz+Bosl8ybFnWqokh1kFsXRL+BMwsET59Hbvwi1/oyB12xepqag6P6PnMa86SwFEHZqEyBhRvjkCYu5ApoIlpJPkAcgTf1Aky/2WNABLg4+aV9KAfyrhuzUs00hXHENMqNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719176145; c=relaxed/simple; bh=ZzzFytiQYKnJNdJ/psIm7dPcsIKaLaPf5ufIz0m20y0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=JuM3FeilGkjV+DOOBGfbErtJgUTZklgXLiRUPlyIYSlR/Qi79b+Z9eg8dWdOoTXvB4IV4vEwD7zywD9XG1kEOx2MaylZN1PecGAf2VqB/Pz7DJrdy2/4Kts7+Q1DZ7o9mmQZGiahOMinUVKhN4SFG+q6wpzkNTfKbRnpAFXFR6I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-63bdb089ffdso28119437b3.3 for ; Sun, 23 Jun 2024 13:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719176143; x=1719780943; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6jUQmJYXcYuYtQ6qCvSKfETX3yJxvZO9xHEGxBPh1c0=; b=LPwHgP2dp8Wymhr0nGHIqVbnn98Z1JB1KpQA7VBaQ/2i2nVm3CZHJ0zBB9kpyzGTCo thUrzUZat/SGZj+TOg4XJNdZ576wLnkOLCgDQztI4LXdowBo06EGGCVtIHqIHbhT8Wwy WVpmDckpFId/Aw7HfZLX4S6v8luv4IkPiJY5OeS8wGhDHedTVAKOQEQTkyxvxLaKAeLU k2yNbR765tD3P6WEktQ48AT5wM14w//V5ZzLDsLbFZAl+BjQIVjVEHzHol17MWhA/Wd4 cn69dRe6rFf4Hq0HvAWCj4kvXOGR46aHPy0FqFOIBP7oyI90ZAw50s9PZkOEKmUTwCKA 4S9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719176143; x=1719780943; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6jUQmJYXcYuYtQ6qCvSKfETX3yJxvZO9xHEGxBPh1c0=; b=apN4LOnXASxf+vNlF98k5Wz1P8oTVe3/9YK63SQMakSii/VBRz1yNQJaFTUg8uBhoU g0d54nRA+OpFjlk1u93jGJX/lzfIAwnZsHiVHm2GBy1YBuqCGYc5JquOXp9qCT+qC8oM Fs5U9yj6yrg7O/hUIEMqfT9VI5VE1JrLIGtqHdGHDBGEvX7pnLVmkOdN/kuAO+T0W0fy oUyubw4sV2UIPdRrRM2xpo434lUPZnaOwMfsIlAbOi2fAEYpWMuCMak/kOImcQ2g+ZQm 2lz6KDC2eC8hryXah7WKNntGlqkD4+h9fhtsekGYElGP5QOoRbexHN3xqyjnjHhL0O1s cfoQ== X-Forwarded-Encrypted: i=1; AJvYcCU5Th6FDY281j56BsZD+541gLcb/vtMzIFTB56LgeYze62LxmVgU1v40RX9ByPI6opcAcYEdBfUuXAAe2p581NIusmmS7Z/Kg== X-Gm-Message-State: AOJu0YyAr5OKTV6j+kLPaJLhMTRLk7Z4vbgS8quU44+bigOMMYa5KZGh 1RJ9pUv6iXsRCt1SrK4JXn78cqBb0o1uh+yKVaMZpqFFpS2eLEuR X-Google-Smtp-Source: AGHT+IG+0rCusBeUlSfR5OuAxNk6eHW+Kw/AtW0sqsuJurqSTfJ3nkAWRtUoKWV+Qoq3hUIX2Mgl4w== X-Received: by 2002:a05:690c:4908:b0:62c:c5ea:407 with SMTP id 00721157ae682-643e98d3f63mr15328137b3.29.1719176142603; Sun, 23 Jun 2024 13:55:42 -0700 (PDT) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id 00721157ae682-63f125a3d25sm22415707b3.67.2024.06.23.13.55.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Jun 2024 13:55:42 -0700 (PDT) Message-ID: Date: Sun, 23 Jun 2024 14:55:40 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH] RISC-V: Fix unrecognizable pattern in riscv_expand_conditional_move() Content-Language: en-US To: Artemiy.Volkov@synopsys.com, gcc-patches@gcc.gnu.org, zengxiao@eswincomputing.com, jlaw@ventanamicro.com References: <20240621144612.122744-1-artemiy@synopsys.com> From: Jeff Law In-Reply-To: <20240621144612.122744-1-artemiy@synopsys.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On 6/21/24 8:46 AM, Artemiy Volkov wrote: > Presently, the code fragment: > > int x[5]; > > void > d(int a, int b, int c) { > for (int i = 0; i < 5; i++) > x[i] = (a != b) ? c : a; > } > > causes an ICE when compiled with -O2 -march=rv32i_zicond: > > test.c: In function 'd': > test.c: error: unrecognizable insn: > 11 | } > | ^ > (insn 8 5 9 2 (set (reg:SI 139 [ iftmp.0_2 ]) > (if_then_else:SI (ne:SI (reg/v:SI 136 [ a ]) > (reg/v:SI 137 [ b ])) > (reg/v:SI 136 [ a ]) > (reg/v:SI 138 [ c ]))) -1 > (nil)) > during RTL pass: vregs > > This happens because, as part of one of the optimizations in > riscv_expand_conditional_move(), an if_then_else is generated with both > comparands being register operands, resulting in an unmatchable insn since > Zicond patterns require constant 0 as the second comparand. Fix this by adding > a extra check before performing this optimization. > > The code snippet mentioned above is also included in this patch as a new Zicond > testcase. > > gcc/ChangeLog: > > * config/riscv/riscv.cc (riscv_expand_conditional_move): Add a > CONST0_RTX check. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/zicond-ice-3.c: New test. I've pushed this to the trunk. Thanks Artemiy! Jeff