From patchwork Sat Aug 17 16:33:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1973498 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=Z6icWjzi; 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 4WmPZc47zxz1yXZ for ; Sun, 18 Aug 2024 02:34:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CC41F3861032 for ; Sat, 17 Aug 2024 16:34:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id 6E41A3858C48 for ; Sat, 17 Aug 2024 16:33:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E41A3858C48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6E41A3858C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723912436; cv=none; b=BSl1odkkMBku4TifpflGAWQqERIBSjAtLnfyzKOy5pZ3yXi8Sg025XtCxjhlegH1h7DHytEUCxUzg2BXNnGLAa1IO1Mm/iz2fpuIXaHjycQc2MQECWzWKh4eJOJzctyzePCBIK06Aw0ewtxQh3NyVMi0wCwYSFdLwVXFfsC6mqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723912436; c=relaxed/simple; bh=iDK2n9dCxsLpTgz7h6JYFyOuZ6iZ1IJGKZHn6lxXHGQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=o7iQJpFeOobuADJCLs1daEZZ2Xccr1uhMadZlZQQ3o1MoALkEsCRQ3jZiTtX87H5rV2VZq+5MVscJ12YRU0CCSDrf+Ly7bFHFiSYssDilSSPU6W2L74YT8X3iuEA7y+UO872tOGF+2Y1c/z99J7I8zeWCEoKTqtK8Pm9Nx09el0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-81fad534a04so165993939f.1 for ; Sat, 17 Aug 2024 09:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723912433; x=1724517233; 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=4dmOv8ggrltWms1rd+LnpN6s1YBKC9UKHhn+NdpYBNg=; b=Z6icWjzitOpM8qG7+Mgg+B1GO8q66NRL8QusnJj817Iqy7RMqIDzYiGpxsr0MJO7Wm TPREhVQFNpx34evX5x+Vh+U5WIJjsljQz6OjVF86jgWGH2s1BgRrWusmnHzg3Q6GaH5B S0HgU/5SHiIwTLDrk3jZ15LGmuGeIbWk8QYw+kqGMPD9TOyOuPyKvQO6mycVBbQIMFkt /q0RnYHmNBGeftJoXg6PPBOQG8T8hHj8lnYP/rKrxuOIwi+fB895dmfugG41iL5X+Lgy 0kkY4zTOGPOxUkl3Mpx8Xw3fzo1FsuDKWdAEZ//SJtvaiGsaSh0pW5TP9TspJM3/Fj7j RVNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723912433; x=1724517233; 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=4dmOv8ggrltWms1rd+LnpN6s1YBKC9UKHhn+NdpYBNg=; b=cIqnfzOsOankOkBn3rywpU+AJakLuMmoyQq9FZcYHxEBgc3gxxoGmcUlGcJ6v/vwVt uNXKH03UrGpdQpKcXUOJaScYJvpEINE3IfLeKzcozIZ1+9ct5UDjw5OMXFP/MMAYtd8T w6/tZCyL2Dt2fuNR54YTX+RymCNQUXkSoQkdrlfryx+IVc07g5KEhuKRqesICSvuKiED CChyCFCVGn9fiEm4DlREsXy7wVN2ZW8rLHzmIJjEMC82+JvBUsor4+CHoLqunM3bK6Zv glkNeYr7XqaIh1Z2yH2GjYhLo8SIb2oqNsYL3x0d0pUkenv4GVvB/SlUaDkw44FZ/gQp hSHg== X-Gm-Message-State: AOJu0YyafOoClyzzlJksWgd0wufrfaMQlVDiKpbCk7UevEGkB8DvktoF bbL34ufBIqu8L5j3DYUu1FQi8hr9K6m04VxfYQKNyo+L7+smlLa+cVjFRi42 X-Google-Smtp-Source: AGHT+IG2ovDymbfUdNIgrC587gS+OfwD4b/Eggb7UejTn3O7aiGnRIrbufcFZj2kbIHqA7EqjPHN2g== X-Received: by 2002:a05:6e02:17c6:b0:383:5520:cc48 with SMTP id e9e14a558f8ab-39d26c34300mr87391795ab.0.1723912433028; Sat, 17 Aug 2024 09:33:53 -0700 (PDT) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b61c6f12sm4902718a12.35.2024.08.17.09.33.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 17 Aug 2024 09:33:52 -0700 (PDT) Message-ID: <6bd6ed90-2b4e-4956-8392-a8a56c577d86@gmail.com> Date: Sat, 17 Aug 2024 10:33:47 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Content-Language: en-US From: Jeff Law Subject: [committed] Adjust v850 rotate expander to allow more cases for V850E3V5 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, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 recent if-conversion changes tripped a failure on the v850 port. The core underlying issue is that while the if-conversion code tries to do the right thing with noce_can_force_operand to determine if it can force an arbitrary operand into a register, it's not really a sufficient check. Essentially for arithmetic codes, it checks the operands. If the operands are force-able and there's a code_to_optab mapping, then it returns true. code_to_optab doesn't actually check anything other than the existence of a mapping in the target. If the target pattern has restrictions enforced by the condition or it's an expander that is allowed to FAIL, then noce_can_force_operand can return true, even though we may not be able to directly force the operand into a register. This came up on the v850 when we had an operand that was a rotate by a constant number of bits (I don't remember the count, all that's important about it was the count was not 8 or 16). The v850 port has this define_expand: > (define_expand "rotlsi3" > [(parallel [(set (match_operand:SI 0 "register_operand" "") > (rotate:SI (match_operand:SI 1 "register_operand" "") > (match_operand:SI 2 "const_int_operand" ""))) > (clobber (reg:CC CC_REGNUM))])] > "(TARGET_V850E_UP)" > { > if (INTVAL (operands[2]) != 16) > FAIL; > }) So the only rotate count allowed is 16 (there's a similar HI rotate with a count of 8). AFAICT the rotate patterns are allowed to FAIL. So naturally the expander fails and we get a testsuite regression: > Tests that now fail, but worked before (4 tests): > > v850-sim/-mgcc-abi/-msoft-float/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > v850-sim/-mgcc-abi/-msoft-float/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > v850-sim/-msoft-float/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > v850-sim/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) This patch works around the problem by allowing the rotates in additional cases, particularly for the V850E3V5+ variants which have a general rotate capability. But let's be clear, this is just a workaround and I expect we're going to have to revisit the code to test if an operand can be forced into a register. Pushing to the trunk. commit abfc140579682598cd178eb9d0b0160bbfafc633 Author: Jeff Law Date: Sat Aug 17 10:30:48 2024 -0600 Adjust v850 rotate expander to allow more cases for V850E3V5 The recent if-conversion changes tripped a failure on the v850 port. The core underlying issue is that while the if-conversion code tries to do the right thing with noce_can_force_operand to determine if it can force an arbitrary operand into a register, it's not really a sufficient check. Essentially for arithmetic codes, it checks the operands. If the operands are force-able and there's a code_to_optab mapping, then it returns true. code_to_optab doesn't actually check anything other than the existence of a mapping in the target. If the target pattern has restrictions enforced by the condition or it's an expander that is allowed to FAIL, then noce_can_force_operand to be true, even though we may not be able to directly force the operand into a register. This came up on the v850 when we had an operand that was a rotate by a constant number of bits (I don't remember the count, all that's important about it was the count was not 8 or 16). The v850 port has this define_expand: > (define_expand "rotlsi3" > [(parallel [(set (match_operand:SI 0 "register_operand" "") > (rotate:SI (match_operand:SI 1 "register_operand" "") > (match_operand:SI 2 "const_int_operand" ""))) > (clobber (reg:CC CC_REGNUM))])] > "(TARGET_V850E_UP)" > { > if (INTVAL (operands[2]) != 16) > FAIL; > }) So the only rotate count allowed is 16 (there's a similar HI rotate with a count of 8). AFAICT the rotate patterns are allowed to FAIL. So naturally the expander fails and we get a testsuite regression: > Tests that now fail, but worked before (4 tests): > > v850-sim/-mgcc-abi/-msoft-float/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > v850-sim/-mgcc-abi/-msoft-float/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > v850-sim/-msoft-float/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > v850-sim/-mv850e3v5: gcc: gcc.c-torture/execute/20100805-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) This patch works around the problem by allowing the rotates in additional cases, particularly for the V850E3V5+ variants which have a general rotate capability. But let's be clear, this is just a workaround and I expect we're going to have to revisit the code to test if an operand can be forced into a register. gcc/ * config/v850/v850.md (rotlsi3): Allow more cases for V850E3V5+. diff --git a/gcc/config/v850/v850.md b/gcc/config/v850/v850.md index f810a27fa2e..83cc9972673 100644 --- a/gcc/config/v850/v850.md +++ b/gcc/config/v850/v850.md @@ -1352,7 +1352,9 @@ (define_expand "rotlsi3" (clobber (reg:CC CC_REGNUM))])] "(TARGET_V850E_UP)" { - if (INTVAL (operands[2]) != 16) + if (TARGET_V850E3V5_UP && e3v5_shift_operand (operands[2], SImode)) + ; + else if (INTVAL (operands[2]) != 16) FAIL; })