From patchwork Tue Sep 19 17:31:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 142010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3561474vqi; Tue, 19 Sep 2023 10:32:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkAXj3dJ0fBY1iKQ5jflP4Hc4GcOccGNExabOjBf+Dnby6od7Cd7lzf0kEXZazs0I/Z432 X-Received: by 2002:a17:906:2012:b0:99c:b0c9:4ec0 with SMTP id 18-20020a170906201200b0099cb0c94ec0mr54943ejo.30.1695144768033; Tue, 19 Sep 2023 10:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695144768; cv=none; d=google.com; s=arc-20160816; b=o3m1OtXFZ0zU1CCMeatzV8Bd9Ytotk8NEoVLea37E//weBuBrSK9CkdSTdSgTii6Ds c7MX1lMbOCopi/v5W114Cvb8yUBRfunmsFkzpEyn7BsrUJjtiw7YS681fnW+YHBFCOO7 bkRvQIIyvmL9yPbfG/50shiuXZyHnaV5bkbRAdwq3aFgJmdzeSC4AqNw/ByhQm1XR5ns bcPiPmBOOT+SYyZWuDXf87F+xx227Tikzp8BJP+ANnsRPyUqtZJgbGrGhz+jO/Gb5rlA 4MBmXUJ3deiBM+4lKCQUdk3Y4Z/jsEx0vrDh/K399vrBo39kVwVck0SVCM6Ai4w0IiTq MqBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:from :content-language:user-agent:mime-version:date:message-id :dkim-signature:dmarc-filter:delivered-to; bh=bHk0iHKACchVkIRSF4unqWebKYqrRzNer8EQXsDaNd0=; fh=XNn3asQvIblazGK92GBt13dVv+YmGV3pBS0JC29ZQco=; b=LDVyFgJHmQDrGw/kDuOEs0USzRaxranrj2d3DF1+s3uXP9aZNDF6w+Et8+CA1M3VNH IvUczJc5i0NrUJNYJ/fHIvNeUgrieImo+/cRG3Lj9KeWcClsUYrlwvD/PaRBkeL/nIqk RrJVfiogCsIWn0F5Fi9TLN2dSk39h4FOPskpPHprhcNPlKqR5HUeq8+raXDuVwLcWryi FW6qmq5KiwKiuVh8688N3OwDFjb/1TLPb4GkfbSNe/JCyruDlOF8E7xoEAldLYq4SF22 4NNhnkWIPU/EnsVWXbgN4u2Ae0dTsAAP4t7sgRhPG8Ake3hCoPKxMvAJm9Ia+1lG87ti X4kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="VV/ac9J4"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lo6-20020a170906fa0600b00992a9bc7432si11431565ejb.936.2023.09.19.10.32.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 10:32:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="VV/ac9J4"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56D16385700B for ; Tue, 19 Sep 2023 17:32:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 2CE933858D20 for ; Tue, 19 Sep 2023 17:32:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2CE933858D20 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-x434.google.com with SMTP id d2e1a72fcca58-690d8fb3b7eso50268b3a.1 for ; Tue, 19 Sep 2023 10:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695144724; x=1695749524; darn=gcc.gnu.org; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=bHk0iHKACchVkIRSF4unqWebKYqrRzNer8EQXsDaNd0=; b=VV/ac9J4Bt6SFB/6LJPk7H7mlCuRrxRchytv7/pnj684vYgp/vnScteXmt9J4JcwNn OnGfe5sIXbYYTlI1+R0JVds82+nqcSmkvW80Ko0dAxEoWoT7ysNh7y31NdqfZfzkq33H Y4b9pKC6xFgh7nh2J6hxqgcqmn9452AD3FZaGXESDrNSQyHAqAH4GBTDCVy4pvF3TVmn R6rf2xx8FcF1OHzDcCshhbwRznvPJuHRLMvQ3ETWJU6fcJ8sfqCekjZIZv14AA8b0WAV +IG2tm2iKN1knVwOnZhsma99mwMBMHdrW3wyRWM505JWEa4KtP7MKEOkkvwmqIO80IDC 6clA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695144724; x=1695749524; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bHk0iHKACchVkIRSF4unqWebKYqrRzNer8EQXsDaNd0=; b=TgC53J+ree1UYGzaErKYBV7K3GDQgigWua67NI+9B9A2CwsRn93finjoBRZLolIDMb US7f4noOVi5WpubyNCjP4LV67rqshDWflpHIB+g1SVV2BRmO/7RZAxusTEc93HF7Oj2E ap/tkcdOhIO5jV8qxGkChQ0kEbiOsIZomOSgO/Jx4MfVuMnh83s8QF20LKHh2AoyyOBD tYqdMtX7rkn6Er6HsoOkUK9yE990IwM8vye/ZYCSkZWfvzElCilj+h7GLDW0hXI1BqI6 YLx5YNoLfKqi1/2NHhLV4xn5eBarf1YPlzaait3gy0svc1ESYnxfRPkSgAjNoVDx+6Uf 2ciw== X-Gm-Message-State: AOJu0Ywy2TOs3x0T/gDpJmmGyUikMq/dpFVZfmPejrJ3D2kE1yFQCI24 5FL06Zhbl1RqPaTcfwgEESYkLtLuJA2MIQ== X-Received: by 2002:a05:6a00:1995:b0:68f:cc47:fcd7 with SMTP id d21-20020a056a00199500b0068fcc47fcd7mr349876pfl.28.1695144724475; Tue, 19 Sep 2023 10:32:04 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id bj16-20020a056a00319000b006905f6bfc37sm5462722pfb.31.2023.09.19.10.32.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Sep 2023 10:32:03 -0700 (PDT) Message-ID: Date: Tue, 19 Sep 2023 11:31:59 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Jeff Law Subject: [committed] Fix bogus operand predicate on iq2000 To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777488120401887088 X-GMAIL-MSGID: 1777488120401887088 The iq2000-elf port regressed these tests recently: > iq2000-sim: gcc.c-torture/execute/20040703-1.c -O2 (test for excess errors) > iq2000-sim: gcc.c-torture/execute/20040703-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > iq2000-sim: gcc.c-torture/execute/20040703-1.c -O3 -g (test for excess errors) It turns out one of the patterns had an operand predicate that allowed REG, SUBREG, CONST_INT (with a limited set of CONST_INTs). Yet the constraint only allowed the limited set of immediates. This naturally triggered an LRA constraint failure. The fix is trivial, create an operand predicate that accurately reflects the kinds of operands allowed by the instruction. It turns out this was a long standing bug -- fixing the pattern resolved 55 failing tests in the testsuite. Pushed to the trunk, Jeff commit eec7c373c2de6d5806537552de5f5b2bd064c43e Author: Jeff Law Date: Tue Sep 19 11:28:53 2023 -0600 Fix bogus operand predicate on iq2000 The iq2000-elf port regressed these tests recently: > iq2000-sim: gcc.c-torture/execute/20040703-1.c -O2 (test for excess errors) > iq2000-sim: gcc.c-torture/execute/20040703-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > iq2000-sim: gcc.c-torture/execute/20040703-1.c -O3 -g (test for excess errors) It turns out one of the patterns had an operand predicate that allowed REG, SUBREG, CONST_INT (with a limited set of CONST_INTs). Yet the constraint only allowed the limited set of immediates. This naturally triggered an LRA constraint failure. The fix is trivial, create an operand predicate that accurately reflects the kinds of operands allowed by the instruction. It turns out this was a long standing bug -- fixing the pattern resolved 55 failing tests in the testsuite. gcc/ * config/iq2000/predicates.md (uns_arith_constant): New predicate. * config/iq2000/iq2000.md (rotrsi3): Use it. diff --git a/gcc/config/iq2000/iq2000.md b/gcc/config/iq2000/iq2000.md index aaeda39ae99..f157a82ebc0 100644 --- a/gcc/config/iq2000/iq2000.md +++ b/gcc/config/iq2000/iq2000.md @@ -988,7 +988,7 @@ (define_insn "lshrsi3_internal1" (define_insn "rotrsi3" [(set (match_operand:SI 0 "register_operand" "=r") (rotatert:SI (match_operand:SI 1 "register_operand" "r") - (match_operand:SI 2 "uns_arith_operand" "O")))] + (match_operand:SI 2 "uns_arith_constant" "O")))] "" "ram %0,%1,%2,0x0,0x0" [(set_attr "type" "arith")]) diff --git a/gcc/config/iq2000/predicates.md b/gcc/config/iq2000/predicates.md index 1330f7d613c..38857e17c24 100644 --- a/gcc/config/iq2000/predicates.md +++ b/gcc/config/iq2000/predicates.md @@ -17,6 +17,15 @@ ;; along with GCC; see the file COPYING3. If not see ;; . +;; Return 1 if OP can be used as an operand where a 16-bit +;; unsigned integer is needed. + +(define_predicate "uns_arith_constant" + (match_code "const_int") +{ + return SMALL_INT_UNSIGNED (op); +}) + ;; Return 1 if OP can be used as an operand where a register or 16-bit ;; unsigned integer is needed.