From patchwork Fri Feb 25 12:50:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu Ianculescu X-Patchwork-Id: 51397 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 350E43857C49 for ; Fri, 25 Feb 2022 12:51:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 350E43857C49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1645793494; bh=mFQ7lgc9lD9+w7JKCBIBC3bXf0JzZ5F2LydwFGPN3M0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=LVvpJhgWYJgOv/GrEqs90fQpXJo4+M5X1lw3IJim/t24fb5i5MWhygxGQA3W/z7HP A7YExCAHBuzjJ6KsppIS3hrcPbktt0+UuQAcqeB6GVXe1DfIbELq1tMGrg5vMjNoQY JYoz44HgmcA/+jKo6gcH8xgusOA6YtGYpSuo1qGY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 1B1193858414 for ; Fri, 25 Feb 2022 12:51:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B1193858414 Received: by mail-wr1-x42c.google.com with SMTP id j17so4442693wrc.0 for ; Fri, 25 Feb 2022 04:51:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=mFQ7lgc9lD9+w7JKCBIBC3bXf0JzZ5F2LydwFGPN3M0=; b=7C74rjf2eZ/v4hoNcLUTBa2O2zVj3VL5OaBCkb1STsCM31vSELeVCSgtBDF+d0JkYU zP6eRaOfGMPmD0MJXKmBxNF71F8zgh1xbyrsJVuRhScqvlF/4WjwKUhVnwJlkbhUafrn v/HMxTXKp0UPxSB9dpoAdEN6djGYdD+i2moeGHm749o3p50dyoUFkP8VIPHSsnaALtr5 IUAEiCiudekJ1NrjKfwNwo+wH5smnr2A6p+NyKnDlRn17yuk9JPDWDgMEBiq67RAbC/X 4vPhNHZxMWlqMda4jWqaQB9jtaZWzvbqBsSTGT1t/Uk338Oe/eZrvmXTemn4ExYTD2mb ptSg== X-Gm-Message-State: AOAM530vLVJfsUbjgRroX4kL6fU83nOjtvUIpFzmJSYe5SMVsxQ4UH3s hnTDUTykh3Rv/h2CeQutgcnPQE3bN8w= X-Google-Smtp-Source: ABdhPJwaav5kLm+pd5QLXS5YtkN+0fXxcFKpDMzvekKitsnpZE1Pd8vq7s9yFEX7Y9QTupANTowX3w== X-Received: by 2002:a05:6000:1252:b0:1ed:f6fa:d435 with SMTP id j18-20020a056000125200b001edf6fad435mr5541640wrx.193.1645793462555; Fri, 25 Feb 2022 04:51:02 -0800 (PST) Received: from localhost.localdomain ([79.115.44.164]) by smtp.gmail.com with ESMTPSA id m11-20020adffe4b000000b001edbdaac445sm2815721wrs.90.2022.02.25.04.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 04:51:02 -0800 (PST) X-Google-Original-From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org, fbedard@synopsys.com Subject: [committed] arc: Fail conditional move expand patterns Date: Fri, 25 Feb 2022 14:50:57 +0200 Message-Id: <20220225125057.1230923-1-claziss@synopsys.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Claudiu Zissulescu via Gcc-patches From: Claudiu Zissulescu Ianculescu Reply-To: Claudiu Zissulescu Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" If the movcc comparison is not valid it triggers an assert in the current implementation. This behavior is not needed as we can FAIL the movcc expand pattern. gcc/ * config/arc/arc.cc (gen_compare_reg): Return NULL_RTX if the comparison is not valid. * config/arc/arc.md (movsicc): Fail if comparison is not valid. (movdicc): Likewise. (movsfcc): Likewise. (movdfcc): Likewise. Signed-off-by: Claudiu Zissulescu --- gcc/config/arc/arc.cc | 3 ++- gcc/config/arc/arc.md | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index 8cc173519ab..c27ba99eb60 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -2256,7 +2256,8 @@ gen_compare_reg (rtx comparison, machine_mode omode) cmode = GET_MODE (x); if (cmode == VOIDmode) cmode = GET_MODE (y); - gcc_assert (cmode == SImode || cmode == SFmode || cmode == DFmode); + if (cmode != SImode && cmode != SFmode && cmode != DFmode) + return NULL_RTX; if (cmode == SImode) { if (!register_operand (x, SImode)) diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index ace3cb70424..39b358052c1 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -1618,8 +1618,11 @@ (define_expand "movsicc" (match_operand:SI 2 "nonmemory_operand" "") (match_operand:SI 3 "register_operand" "")))] "" - "operands[1] = gen_compare_reg (operands[1], VOIDmode);") - + " + operands[1] = gen_compare_reg (operands[1], VOIDmode); + if (operands[1] == NULL_RTX) + FAIL; + ") (define_expand "movdicc" [(set (match_operand:DI 0 "dest_reg_operand" "") @@ -1627,7 +1630,11 @@ (define_expand "movdicc" (match_operand:DI 2 "nonmemory_operand" "") (match_operand:DI 3 "register_operand" "")))] "" - "operands[1] = gen_compare_reg (operands[1], VOIDmode);") + " + operands[1] = gen_compare_reg (operands[1], VOIDmode); + if (operands[1] == NULL_RTX) + FAIL; + ") (define_expand "movsfcc" @@ -1636,7 +1643,11 @@ (define_expand "movsfcc" (match_operand:SF 2 "nonmemory_operand" "") (match_operand:SF 3 "register_operand" "")))] "" - "operands[1] = gen_compare_reg (operands[1], VOIDmode);") + " + operands[1] = gen_compare_reg (operands[1], VOIDmode); + if (operands[1] == NULL_RTX) + FAIL; + ") (define_expand "movdfcc" [(set (match_operand:DF 0 "dest_reg_operand" "") @@ -1644,7 +1655,11 @@ (define_expand "movdfcc" (match_operand:DF 2 "nonmemory_operand" "") (match_operand:DF 3 "register_operand" "")))] "" - "operands[1] = gen_compare_reg (operands[1], VOIDmode);") + " + operands[1] = gen_compare_reg (operands[1], VOIDmode); + if (operands[1] == NULL_RTX) + FAIL; + ") (define_insn "*movsicc_insn" [(set (match_operand:SI 0 "dest_reg_operand" "=w,w")