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: 1836792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=VV/ac9J4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RqpdZ6nrXz1ynX for ; Wed, 20 Sep 2023 03:32:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D364C3857C5A for ; Tue, 19 Sep 2023 17:32:28 +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-Google-Smtp-Source: AGHT+IFTv1gin1zRecA2kBgVq5jlX2FMKui39TEPrwMfvat2S67vYJtjIZNCJIUlZfiJ5QnJYjDDxA== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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.