From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id D950C3858280 for ; Mon, 7 Aug 2023 16:31:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D950C3858280 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686ba97e4feso4503466b3a.0 for ; Mon, 07 Aug 2023 09:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691425886; x=1692030686; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=gL/D8Apg08GHWVr/nwbAes13IJ6MgkdY5JLU6aKvquE=; b=LtaiSy3CovqQgZ959ZixJ/jijMdtRe7VfD/l7f3jGvMamrqXR8bQY1BONTnF7ey/7s L1F5sjwHCWakoWgSxjHovvfRtYi3GCHRwUyUVhV9Cloj1OQuXHiuy+OpKX0EJHbyFetD ZzxaZ2ounbAo3Zy2EJno553WuYQunnYoLcn0QLvrmdTfagyH3rImbIkX5Hrck0PagaY0 SRE6XHyGJsEPweP2aR1wuS+SejDBJjESZrNjLlD9BMr5aE/ZUxqnWffx9OGKn1/v4Uvh qL2BkIucLH4+BAV+oSpvez0iAUy6Ws0BLeNuvGGdHR/x4cFkRBv7EVf+ekQYxUYQgSiv 3ZRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691425886; x=1692030686; h=content-transfer-encoding:in-reply-to:from:references:cc: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=gL/D8Apg08GHWVr/nwbAes13IJ6MgkdY5JLU6aKvquE=; b=TR9EirofeIsRiLr1lJvJivCb6Vb0K+Bo7OjHdTqEhtwBtQ78OiOxW/TSuQ7KgbgDXj LZt6lmker3L2Q6vyF1dzGbrDzA77MhbP0B6BuZhxPFoV8RtwL5IkOoy25xt15ErRvP6Q DR4c9FvQSFhlm/141A+W2KJx0vY05Opf6gL9kbqS3BjIuwJmH0YqPKmtqCRVn8z41dYP SkUmGDYxwZNOGSUElt+2BgLsb4YPKoVVST5+ZzaW+kwDFXGiKY4wezWpEnx+DclxiM8p U8qrsok+Py/wxbQ/+7U8ifP/XnzIQ79u50rpjEXnqFN0G2MKhGXrRIUPFjlDZol1SXrr TWKQ== X-Gm-Message-State: AOJu0Yyw5BBKsl9Ncev3PTXEhjiJiL+X9M5OSiGrsxF6qpoVwkQQqOQG aHaBdGN9ZqIleZRkxlbOC7E= X-Google-Smtp-Source: AGHT+IEy5UZV6RATmXsp/yMMmDpNKvpK7JtFto/PLmgIRupWL/JHtt3qI/JYdJnXjf7uWiCLYeleqQ== X-Received: by 2002:a05:6a20:6a0c:b0:13f:cd07:2b40 with SMTP id p12-20020a056a206a0c00b0013fcd072b40mr12672904pzk.3.1691425885632; Mon, 07 Aug 2023 09:31:25 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id v19-20020aa78093000000b00672401787c6sm6364457pff.109.2023.08.07.09.31.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Aug 2023 09:31:25 -0700 (PDT) Message-ID: Date: Mon, 7 Aug 2023 10:31:23 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1] Mode-Switching: Fix SET_SRC ICE when only one operand Content-Language: en-US To: Richard Biener , pan2.li@intel.com Cc: gcc-patches@gcc.gnu.org, juzhe.zhong@rivai.ai, kito.cheng@sifive.com, yanzhang.wang@intel.com References: <20230807122247.1881775-1-pan2.li@intel.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,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 8/7/23 07:13, Richard Biener wrote: > On Mon, Aug 7, 2023 at 2:30 PM Pan Li via Gcc-patches > wrote: >> >> From: Pan Li >> >> In same cases, like gcc/testsuite/gcc.dg/pr78148.c in RISC-V, there will >> be only 1 operand when SET_SRC in create_pre_exit. For example as below. >> >> (insn 13 9 14 2 (clobber (reg/i:TI 10 a0)) "gcc/testsuite/gcc.dg/pr78148.c":24:1 -1 >> (expr_list:REG_UNUSED (reg/i:TI 10 a0) >> (nil))) >> >> Unfortunately, SET_SRC requires at least 2 operands and then Segment >> Fault here. This patch would like to fix this ICE by adding operand >> length check before SET_SRC. >> >> Signed-off-by: Pan Li >> >> gcc/ChangeLog: >> >> * mode-switching.cc (create_pre_exit): Add operand length check. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/riscv/mode-switch-ice-1.c: New test. >> --- >> gcc/mode-switching.cc | 2 ++ >> .../gcc.target/riscv/mode-switch-ice-1.c | 22 +++++++++++++++++++ >> 2 files changed, 24 insertions(+) >> create mode 100644 gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c >> >> diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc >> index 64ae2bc29c3..cbf03c02159 100644 >> --- a/gcc/mode-switching.cc >> +++ b/gcc/mode-switching.cc >> @@ -411,6 +411,8 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes) >> conflict with address reloads. */ >> if (copy_start >= ret_start >> && copy_start + copy_num <= ret_end >> + && GET_RTX_LENGTH (GET_CODE (return_copy_pat)) >= 2 >> + /* SET_SRC requires at least 2 operands. */ > > maybe check that return_copy_pat is a SET instead? Or just ignore the case of an insn that is a toplevel USE/CLOBBER? I bet we even have a function for that somewhere given how commonly we need to do that. jeff