From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 59695389366A for ; Mon, 5 Dec 2022 07:32:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 59695389366A 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-lj1-x231.google.com with SMTP id z4so12524710ljq.6 for ; Sun, 04 Dec 2022 23:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hHQuc5qykV2kBq2hWtYwi1A/Un14voBd+CDr+Z1Il2Y=; b=T8xdEAH1jbTiL2heGEyOyymHFyjgRDnuYYTb5ZV6Xq6AYlB6FuvnprHBLe76rdiAfV Yxg4nUQjIV2t7y7mkBqWy6aGWbPB2MJekCBAbJoKMaR95QbucX+BW7rMJODCb3Y63pVl GobSMrNpqzevPEf3Filw9YQeX5S6jGPsU2cssA3uzRegF7uW9aJn3B1kov+lkHGuddAv 2QelACCbvKjaPJG0O1JQ2dv+iQt6LuVf/aKfqn+XTY/A8KlrXdmolvjSq5DLV2B5tQmW GdmOWYxk98KOMzo3PSjwYJu/0vcuVj8tII5H7Z4oMY8zxjyQqBxaLC2bDo1Ixcw4e/sw GfMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=hHQuc5qykV2kBq2hWtYwi1A/Un14voBd+CDr+Z1Il2Y=; b=gJ0T+OU5CSsMaw+o8WFuB+EUCS8cmT8WWQLQKeGpvx/pR6MQPOShMN2HY/4MX+11Mu NlgaGnr5DZvYwB0XuJAVkobYseDqj60q1mRLFp7JeEh6VBeuJzvaNikfEPUZ8jXXANcm 5jK8o+oM2Me/K0TCNtyYoSIoMI6mxB1LjyNDMpN6R4+/XC7NzMYYxXgw6828Ccx51owC qEKqIevIFG38jm+IzEYPS+fEUwOZpluwNU6F+z3mNhogp4+tabvpmgNrVQf+Z/CJbibX OpbPPoq2PIcvQDDl9PSuqe+UHKzaTOgDY9ZP68zq8N3yZdyejtDcNqKh2nsPbqNmGt/Q f9+A== X-Gm-Message-State: ANoB5pkyeFarfenThFTZXHHGx8rx+RsCwYOjUp8AD6ZWxoAVeI6s/rNa 6FbeMbfa1W4+MZYzgI/cR6CJNVrj3cFpIbpsgwI= X-Google-Smtp-Source: AA0mqf7ERg7qC7+BnUSM3Ndy5dxvwreI4TOjoWlF/hpnBimYG5lLXaQvOaVnblxwR+q6mnA2ybqjeFGoN9jTiFWqb/M= X-Received: by 2002:a2e:84d6:0:b0:279:7acc:9d1a with SMTP id q22-20020a2e84d6000000b002797acc9d1amr18850811ljh.297.1670225531367; Sun, 04 Dec 2022 23:32:11 -0800 (PST) MIME-Version: 1.0 References: <905c34de-6333-1021-05e6-942922918b18@linux.ibm.com> In-Reply-To: <905c34de-6333-1021-05e6-942922918b18@linux.ibm.com> From: Richard Biener Date: Mon, 5 Dec 2022 08:31:58 +0100 Message-ID: Subject: Re: [PATCH v2] Return a NULL rtx when targets don't support cbranchcc4 or predicate check fails in prepare_cmp_insn To: HAO CHEN GUI Cc: gcc-patches , Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.2 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 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, Dec 5, 2022 at 4:08 AM HAO CHEN GUI wrote: > > Hi, > It gets an assertion failure when targers don't support cbranchcc4 or > predicate check fails in prepare_cmp_insn. prepare_cmp_insn is a help > function to generate compare rtx, so it should not assume that cbranchcc4 > is existing or all sub-CC modes are supported on one target. I think it > should return the NULL rtx when cbranchcc4 is not supported or predicate check > fails, as its callers already check if the return value is null or not for CC > mode. This patch just does the change. > > Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. > Is this okay for trunk? Any recommendations? Thanks a lot. I wonder if you have a testcase you can add showing this change is worthwhile and fixes a bug? OK. Thanks, Richard. > > ChangeLog > 2022-12-05 Haochen Gui > > gcc/ > * optabs.cc (prepare_cmp_insn): Return a NULL rtx other than assertion > failure when targets don't have cbranch optab or predicate check > fails. > > patch.diff > diff --git a/gcc/optabs.cc b/gcc/optabs.cc > index 165f8d1fa22..f6d3242479b 100644 > --- a/gcc/optabs.cc > +++ b/gcc/optabs.cc > @@ -4484,10 +4484,14 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, > { > enum insn_code icode = optab_handler (cbranch_optab, CCmode); > test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y); > - gcc_assert (icode != CODE_FOR_nothing > - && insn_operand_matches (icode, 0, test)); > - *ptest = test; > - return; > + if (icode != CODE_FOR_nothing > + && insn_operand_matches (icode, 0, test)) > + { > + *ptest = test; > + return; > + } > + else > + goto fail; > } > > mclass = GET_MODE_CLASS (mode);