From patchwork Fri Feb 16 14:34:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 85883 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 58B943858016 for ; Fri, 16 Feb 2024 14:35:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 252FC38582B1 for ; Fri, 16 Feb 2024 14:34:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 252FC38582B1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 252FC38582B1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708094083; cv=none; b=fHECmmCAsAEjMorkJNSeawGzSrp3POSj5OSKIDDC5htKDx82Crku6Czn8MOqrJHF0ACqHpl5gcnp6qeD5ntOiaETmZfIgRyDNOUgU7oM1YXpn+oUxvLl5jCHbttpCkic57w1eiMYcyGvRzCvaWpt2MGhVyNT7wLezQqYrRnsguA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708094083; c=relaxed/simple; bh=ry38ScB4WxTdpTgi4K4z3qKP1Mg3fKcfqJzXus3F3SE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aijEtOc3JVIEGNjXC/fZ3LElpocEc2Ac5jIHjG99xs136Uw3YckZAPK1w+yArB8n6N4TBmmGPFIcyPH8SwjQxqMREAEER85nF2MClXckTp5hEFoLsDNoiMPtjjZUsp3IUwAX04PQNw3fkR+BzWlZg7bHW32w1EoivU26uCea7+E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so624104f8f.1 for ; Fri, 16 Feb 2024 06:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708094073; x=1708698873; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=58GeEm7wzvFId/BJWSYpjlGG9vHsRYFqHkoQfO6L8Kw=; b=nbmmHkKn1PN1URsvgxlWEooTjPjKDOm96Xs7vl/sk7H3S6b4XmIIQsFuE62Jupjcqg zqv7yK2/J+vH0uA372+PJ2e89XnePh23bJKvmb4+pnLN317RDH/UboDyN7VgWoy2hJEi 3Jq5FbzT4HPi08FKNkrFI7iYZ3vzeER+28LTmPN3lpkO78WVFUNIk0on4jKBWdujdjrq AhAH6/ASoKtwnl1Ut1mYmz357kRHjTeYIMBG/uNBcRSBvZyXg4fM/Z8Vgr4DNibKNXH7 pKZkrjlrFvkmuawIjVktdqKUXh9Z20aR7KC/u3AFL1K28BjjrvHOO8f68N8yw5OJhnUj 5oIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708094073; x=1708698873; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=58GeEm7wzvFId/BJWSYpjlGG9vHsRYFqHkoQfO6L8Kw=; b=ZbvM1de921oR/fkq4fpu5vWNgNxcaHWsLy6NJ/YDNRL9PDb5oN9RHGeAZMRP1h8VYU hyXVYH9u0KEQTRtVPo+p1V5QdjAVlj3DXPAs8g7JCDt08wD9iFiTrBsB31mKkDWjJXJ8 4VqYhkg1Ng+lQbKruvWWwj7FqYdxQrRGvj+FZBevV1FhQYfdm9OOQxRs0PdmZ1pRbO9l okOK7oG77bMrGCN7678oLQWCwnX+HV3hjxgO27RmqPmFdtFn7I2hYHzDNoAeoetchS0o HWYnnAE1OZJn8Wc8HkyoXm1zRY4dmRj+yr+oultVPsXdctJ3FeLWR0OYOKjArOC7zGUu 8Nig== X-Gm-Message-State: AOJu0YwFrc6gMStgjgnyZbW846fSHdFBnyBRAcE5SFZu9CKvoQeEO09B q7vmjHny2rmzxi04ZlAxPpvkZbaJaq5Z2/T6OQA8UA8oTcG65ki/m2QFgqXWONgHFj3rdh9Fx+y I X-Google-Smtp-Source: AGHT+IGMBK2N73w9FW3UEA2qOBzfPZdBxwTHW+FHs/DIBcS4SyCuQ/EsgAIHV7OUsk5Gy/07zrBgUA== X-Received: by 2002:a5d:464a:0:b0:33b:7892:2ea7 with SMTP id j10-20020a5d464a000000b0033b78922ea7mr3400564wrs.5.1708094072805; Fri, 16 Feb 2024 06:34:32 -0800 (PST) Received: from euler.schwinge.homeip.net (p200300c8b7344200b5efa23283b9f09b.dip0.t-ipconnect.de. [2003:c8:b734:4200:b5ef:a232:83b9:f09b]) by smtp.gmail.com with ESMTPSA id h7-20020a056000000700b0033ce214a97csm2372417wrx.17.2024.02.16.06.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 06:34:32 -0800 (PST) From: Thomas Schwinge To: gcc-patches@gcc.gnu.org, Andrew Stubbs Cc: Tobias Burnus , Richard Biener Subject: GCN: Conditionalize 'define_expand "reduc__scal_"' on '!TARGET_RDNA2_PLUS' [PR113615] (was: [patch] gcn/gcn-valu.md: Disable fold_left_plus for TARGET_RDNA2_PLUS [PR113615]) In-Reply-To: References: User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/29.1 (x86_64-pc-linux-gnu) Date: Fri, 16 Feb 2024 15:34:30 +0100 Message-ID: <87plwwjx55.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, MEDICAL_SUBJECT, 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+patchwork=sourceware.org@gcc.gnu.org Hi! On 2024-01-29T11:34:05+0100, Tobias Burnus wrote: > Andrew wrote off list: > "Vector reductions don't work on RDNA, as is, but they're > supposed to be disabled by the insn condition" > > This patch disables "fold_left_plus_", which is about > vectorization and in the code path shown in the backtrace. > I can also confirm manually that it fixes the ICE I saw and > also the ICE for the testfile that Richard's PR shows at the > end of his backtrace. (-O3 is needed to trigger the ICE.) On top of that, OK to push the attached "GCN: Conditionalize 'define_expand "reduc__scal_"' on '!TARGET_RDNA2_PLUS' [PR113615]"? Which of the 'assert's are worth keeping? Only tested 'vect.exp' for 'check-gcc-c' so far; full testing to run later. Please confirm I'm understanding this correctly: Andrew's original commit c7ec7bd1c6590cf4eed267feab490288e0b8d691 "amdgcn: add -march=gfx1030 EXPERIMENTAL" did this: (define_expand "reduc__scal_" [(set (match_operand: 0 "register_operand") (unspec: [(match_operand:V_ALL 1 "register_operand")] REDUC_UNSPEC))] - "" + "!TARGET_RDNA2" [later '!TARGET_RDNA2_PLUS'] { [...] This conditional, however, does *not* govern any explicit 'gen_reduc_plus_scal_', and therefore Tobias in commit 7cc2262ec9a410dc56d1c1c6b950c922e14f621d "gcn/gcn-valu.md: Disable fold_left_plus for TARGET_RDNA2_PLUS [PR113615]" had to replicate the '!TARGET_RDNA2_PLUS' condition: > @@ -4274,7 +4274,8 @@ (define_expand "fold_left_plus_" > [(match_operand: 0 "register_operand") > (match_operand: 1 "gcn_alu_operand") > (match_operand:V_FP 2 "gcn_alu_operand")] > - "can_create_pseudo_p () > + "!TARGET_RDNA2_PLUS > + && can_create_pseudo_p () > && (flag_openacc || flag_openmp > || flag_associative_math)" > { | rtx dest = operands[0]; | rtx scalar = operands[1]; | rtx vector = operands[2]; | rtx tmp = gen_reg_rtx (mode); | | emit_insn (gen_reduc_plus_scal_ (tmp, vector)); | [...] ..., and I thus now have to do similar for 'gen_reduc__scal_' use in here: (define_expand "reduc__scal_" [(match_operand: 0 "register_operand") (fminmaxop:V_FP (match_operand:V_FP 1 "register_operand"))] - "" + "!TARGET_RDNA2_PLUS" { /* fmin/fmax are identical to smin/smax. */ emit_insn (gen_reduc__scal_ (operands[0], operands[1])); [...] Grüße Thomas From 1ca37da07f0fd3fa2e87fcbde9f2c2aadbe320dc Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 16 Feb 2024 13:04:00 +0100 Subject: [PATCH] GCN: Conditionalize 'define_expand "reduc__scal_"' on '!TARGET_RDNA2_PLUS' [PR113615] On top of commit c7ec7bd1c6590cf4eed267feab490288e0b8d691 "amdgcn: add -march=gfx1030 EXPERIMENTAL" conditionalizing 'define_expand "reduc__scal_"' on '!TARGET_RDNA2' (later: '!TARGET_RDNA2_PLUS'), we then did similar in commit 7cc2262ec9a410dc56d1c1c6b950c922e14f621d "gcn/gcn-valu.md: Disable fold_left_plus for TARGET_RDNA2_PLUS [PR113615]" to conditionalize 'define_expand "fold_left_plus_"' on '!TARGET_RDNA2_PLUS', but I found we also need to conditionalize the related 'define_expand "reduc__scal_"' on '!TARGET_RDNA2_PLUS', to avoid ICEs like: [...]/gcc.dg/vect/pr108608.c: In function 'foo': [...]/gcc.dg/vect/pr108608.c:9:1: error: unrecognizable insn: (insn 34 33 35 2 (set (reg:V64DF 723) (unspec:V64DF [ (reg:V64DF 690 [ vect_m_11.20 ]) (const_int 1 [0x1]) ] UNSPEC_MOV_DPP_SHR)) -1 (nil)) during RTL pass: vregs Similar for 'gcc.dg/vect/vect-fmax-2.c', 'gcc.dg/vect/vect-fmin-2.c', and 'UNSPEC_SMAX_DPP_SHR' for 'gcc.dg/vect/vect-fmax-1.c', and 'UNSPEC_SMIN_DPP_SHR' for 'gcc.dg/vect/vect-fmin-1.c', when running 'vect.exp' for 'check-gcc-c'. PR target/113615 gcc/ * config/gcn/gcn-valu.md (define_expand "reduc__scal_"): Conditionalize on '!TARGET_RDNA2_PLUS'. --- gcc/config/gcn/gcn-valu.md | 6 +++++- gcc/config/gcn/gcn.cc | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md index 59e27d0aed79..973a72e3fc41 100644 --- a/gcc/config/gcn/gcn-valu.md +++ b/gcc/config/gcn/gcn-valu.md @@ -4247,6 +4247,8 @@ REDUC_UNSPEC))] "!TARGET_RDNA2_PLUS" { + gcc_checking_assert (!TARGET_RDNA2_PLUS); + rtx tmp = gcn_expand_reduc_scalar (mode, operands[1], ); @@ -4261,8 +4263,10 @@ [(match_operand: 0 "register_operand") (fminmaxop:V_FP (match_operand:V_FP 1 "register_operand"))] - "" + "!TARGET_RDNA2_PLUS" { + gcc_checking_assert (!TARGET_RDNA2_PLUS); + /* fmin/fmax are identical to smin/smax. */ emit_insn (gen_reduc__scal_ (operands[0], operands[1])); DONE; diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index fce2d4d30c9d..8fa445deda53 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -5449,6 +5449,8 @@ char * gcn_expand_dpp_shr_insn (machine_mode mode, const char *insn, int unspec, int shift) { + gcc_checking_assert (!TARGET_RDNA2_PLUS); + static char buf[128]; const char *dpp; const char *vcc_in = ""; @@ -5510,6 +5512,8 @@ gcn_expand_dpp_shr_insn (machine_mode mode, const char *insn, rtx gcn_expand_reduc_scalar (machine_mode mode, rtx src, int unspec) { + gcc_checking_assert (!TARGET_RDNA2_PLUS); + machine_mode orig_mode = mode; machine_mode scalar_mode = GET_MODE_INNER (mode); int vf = GET_MODE_NUNITS (mode); -- 2.43.0