From patchwork Sat Jun 29 00:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1954188 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=KXDn0qYi; 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 4W9tmv4nwvz20Xg for ; Sat, 29 Jun 2024 10:42:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60B01385E441 for ; Sat, 29 Jun 2024 00:42:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by sourceware.org (Postfix) with ESMTPS id 79496385840B for ; Sat, 29 Jun 2024 00:41:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79496385840B 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 79496385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719621706; cv=none; b=aVQIhhIAaE+S6CkVtrvp+BQKTsHgHPE3puEI5hh5Gj94rJEkOuelYUf/kKU18GAEsYNcke0RCP2OIjSk1NgevyhZ1ebkrCeufPPEtGMFCbWxqdqxX+TuFecT/8Kz61b1R37g05+7z+U/QHPeOBQNTDQ2JMcYDm8P0q36jwqpJEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719621706; c=relaxed/simple; bh=yQtaSIERo3ZVrO9W42kvT95eNA6uNnqOBbqrhS8cF2M=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:To:Subject; b=KBF8/C4FavJDj0DSUxkYYr0fM8X25Lf5rP/2/MNt5ss4WBKmIJREl195GRzwGtKbn/COk0W66XNQ32uAU7yec/9X6YPxAhyNFwRKBAN3vk9vVSZrS455onqGQmSdRJo+Fje043Qg+mjaAdMyjUAaIR60Nzox37yxZ/jvoeeeFus= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5c40f0aed5bso526962eaf.2 for ; Fri, 28 Jun 2024 17:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719621703; x=1720226503; darn=gcc.gnu.org; h=subject:to:from:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=EwB7BPpBtWfvMOHg7oD7FAQruGED24NMohdvnAhJr8Y=; b=KXDn0qYiMMm649f8NiM7bcf1NH4ClZiBa2IqGRkKV9xOsQGMRo2ZDTQ7hAsrbZbLzt +RqcSBdygBzHy1fl309Q3Q6LufSofIqYkxi1aINa7t4HJ1fGKXaF7k+hsEyi/OfbEIQE SJwC6Jhzw4e+jBvrc9LVCzHidfNflUujPoC2jCWu2/Z2ds6zl7Vd7hrqsDpq3Wn3C9Lc mQJe8fxUy9Z4xbU+F+6zzasJiUMAamQOBic+VBfyozxb2fwX0MBhzp5w1I+IIxI9K78p ZoFHiFjXNHoFCBUME6Njx76J4anbOb1yHAin9pF2zUUqGPNUUM6i09cIzEOAxCv9i5DY unMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719621703; x=1720226503; h=subject:to:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EwB7BPpBtWfvMOHg7oD7FAQruGED24NMohdvnAhJr8Y=; b=Y3pAzIQK1O88UQP5qaT674uIkyZkTtD1k5afWA7aSPJuZmuu8BH8+TECetPm27VF1I vAdk0vctVy2o5N/3x81yIVGr7ZqtdJ+Cxrf6/HgUl0xI41gQpaXc9IEjZKuZ6BEbIECz gTbdEcPbbRZTUpHiyQ+barROPT3ch0OxFM2Tz6B+/bqU1axrlGE0vjeJZYzJZs1oxAy1 WAtwJ5PvREVwlRczNjj93lGgw8Cj3Ea4BtcBmS3wkNyWdfAeOz07DIZDDuZCGaHUddJz 2Kvo03FZ03DsMJr5kSOxocfs+LFOam3C3z5SNop0epwjpCOQLUXrFq8enMxVP46ElB7E ddOQ== X-Gm-Message-State: AOJu0YxLwj9tUCTKuYSHWNR0kcpYlHWKjsNe88rgRfTkqHKcYObWXa7x W+IvJfYbMVwfIXMf33+XUmbeWIC90jNF62EnMhHgIGqKzhrw+I+Kugrzxw== X-Google-Smtp-Source: AGHT+IGwZiHu2GybTOukK252RypNzGt+6zgj/Qw7+gpeLEC9ygCR63oKg5PXKTQcfWZntTnC6lXjwg== X-Received: by 2002:a4a:5888:0:b0:5c4:57d:691e with SMTP id 006d021491bc7-5c4057d6c25mr7319497eaf.2.1719621702598; Fri, 28 Jun 2024 17:41:42 -0700 (PDT) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5c41480c3edsm387645eaf.7.2024.06.28.17.41.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 17:41:41 -0700 (PDT) Message-ID: <74c0d9e8-e73d-40e6-bc18-da56ab1e698b@gmail.com> Date: Fri, 28 Jun 2024 18:41:40 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Content-Language: en-US From: Jeff Law To: "gcc-patches@gcc.gnu.org" Subject: [committed] Fix mcore-elf regression after recent IRA change X-Spam-Status: No, score=-8.4 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 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 So the recent IRA change exposed a bug in the mcore backend. The mcore has a special instruction (xtrb3) which can zero extend a GPR into R1. It's useful because zextb requires a matching source/destination. Unfortunately xtrb3 modifies CC. The IRA changes twiddle register allocation such that we want to use xtrb3. Unfortunately CC is live at the point where we want to use xtrb3 and clobbering CC causes the test to fail. Exposing the clobber in the expander and insn seems like the best path forward. We could also drop the xtrb3 alternative, but that seems like it would hurt codegen more than exposing the clobber. The bitfield extraction patterns using xtrb look problematic as well, but I didn't try to fix those. This fixes the builtn-arith-overflow regressions and appears to fix 20010122-1.c as a side effect. Pushing to the trunk. Jeff commit 9fbbad9b6c6e7fa7eaf37552173f5b8b2958976b Author: Jeff Law Date: Fri Jun 28 18:36:50 2024 -0600 [committed] Fix mcore-elf regression after recent IRA change So the recent IRA change exposed a bug in the mcore backend. The mcore has a special instruction (xtrb3) which can zero extend a GPR into R1. It's useful because zextb requires a matching source/destination. Unfortunately xtrb3 modifies CC. The IRA changes twiddle register allocation such that we want to use xtrb3. Unfortunately CC is live at the point where we want to use xtrb3 and clobbering CC causes the test to fail. Exposing the clobber in the expander and insn seems like the best path forward. We could also drop the xtrb3 alternative, but that seems like it would hurt codegen more than exposing the clobber. The bitfield extraction patterns using xtrb look problematic as well, but I didn't try to fix those. This fixes the builtn-arith-overflow regressions and appears to fix 20010122-1.c as a side effect. gcc/ * config/mcore/mcore.md (zero_extendqihi2): Clobber CC in expander and matching insn. (zero_extendqisi2): Likewise. diff --git a/gcc/config/mcore/mcore.md b/gcc/config/mcore/mcore.md index d416ce24a97..432b89520d7 100644 --- a/gcc/config/mcore/mcore.md +++ b/gcc/config/mcore/mcore.md @@ -1057,15 +1057,17 @@ (define_insn "" [(set_attr "type" "load")]) (define_expand "zero_extendqisi2" - [(set (match_operand:SI 0 "mcore_arith_reg_operand" "") - (zero_extend:SI (match_operand:QI 1 "general_operand" "")))] + [(parallel [(set (match_operand:SI 0 "mcore_arith_reg_operand" "") + (zero_extend:SI (match_operand:QI 1 "general_operand" ""))) + (clobber (reg:CC 17))])] "" "") ;; RBE: XXX: we don't recognize that the xtrb3 kills the CC register. (define_insn "" [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,b,r") - (zero_extend:SI (match_operand:QI 1 "general_operand" "0,r,m")))] + (zero_extend:SI (match_operand:QI 1 "general_operand" "0,r,m"))) + (clobber (reg:CC 17))] "" "@ zextb %0 @@ -1091,15 +1093,17 @@ (define_insn "" [(set_attr "type" "load")]) (define_expand "zero_extendqihi2" - [(set (match_operand:HI 0 "mcore_arith_reg_operand" "") - (zero_extend:HI (match_operand:QI 1 "general_operand" "")))] + [(parallel [(set (match_operand:HI 0 "mcore_arith_reg_operand" "") + (zero_extend:HI (match_operand:QI 1 "general_operand" ""))) + (clobber (reg:CC 17))])] "" "") ;; RBE: XXX: we don't recognize that the xtrb3 kills the CC register. (define_insn "" [(set (match_operand:HI 0 "mcore_arith_reg_operand" "=r,b,r") - (zero_extend:HI (match_operand:QI 1 "general_operand" "0,r,m")))] + (zero_extend:HI (match_operand:QI 1 "general_operand" "0,r,m"))) + (clobber (reg:CC 17))] "" "@ zextb %0