From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id D56793858D20 for ; Fri, 17 Nov 2023 08:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D56793858D20 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 D56793858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700210757; cv=none; b=MBMPXfWUSfI5cSyF6wVU6ychTqwxSeV6lVng5caBqUP6IyIfJnJz2Krva068l8nlhNjCMSiDw28UnY91np08Cb54nihCQHpONLqioMfCpfET+miX/rt+4SK7R3BBroC/DGIfemN+M81SuT8fZfcwAI2EQ6sb/MNsoh6NjQhKXwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700210757; c=relaxed/simple; bh=gAV5U2pI+J/20gb9OJQ4j3ZUO4m0SigAVgzi0n9UJOM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Nt7EYaaiyws2iGTEbQAQHeNHvcWGYMAY+dqcgwvmBuK/sb/kmlxv0BBj4tjTXJFUAWLaXLoyrcvquzH3c+SgbXeAYzAS6uG7k0NdG7cpZNUcvHCCOXX3diXtEm8yqlV3KjdWU9VN4f+uzqTnh+l0rurDvaDPYiRbdMXriITu3es= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5437269a661so5603208a12.0 for ; Fri, 17 Nov 2023 00:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700210755; x=1700815555; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kXuxMnqzOMjnfpJUD+CF3e/FWGaf2ceu4rV0BswzTmg=; b=m5hk/6QFNGiKkV49TKjQMtJtPRsrYBxqhQ0sFD9xfZmZLOL5kFu41EoQhddEFDGDR7 jyF9/sXj5MTfnqwaPLfkM/4nOeNtTXZHOHoGICw9h7w7xIc5j0trj1LgtiqsIHu7B/03 qMTfuLNlcE6TabOqnjRbwoqrs3uH5OjzN1D96EHUoz9Whn3S7dR/Gcf8TynTYn5Zhf58 DLYh9sHuiexvzpVP6mBrc1FfQhMHLiR6GNVBbjpTOg8TYBNpPhG0qMjW/xmH4yVbBxNr tzmYevDKBA0Lq+TCo7ZMA+4Qp3EAPNp+wlYhTykxRCugypzjvVvOt97Q3JI6gXwhoOWa rRqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700210755; x=1700815555; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kXuxMnqzOMjnfpJUD+CF3e/FWGaf2ceu4rV0BswzTmg=; b=gaSts6gD96a3KEmhqaCzcnkZFVQNZvpD7cIivspHukye8dPZOVH4v1QXULlsnhh61N 3cag38L0bHVEZZfA44z4CPTbsUeoxLCg2Xl4I8Z9nz4/lMehx5qgqKDv/JY0YUq5UujW QR8aUSnNI5LgC6b1brnPdI4gAWQ3m+GPXo6Lh9qLcUJGSMRFrD66LwHkc3Za3N6A8TrC loaKjSO/MVByO80kpSFJVkjnR7MlthKEzwdLFjcRJn4pfvnpz/Y/hEr3FA4fQDsGnTV5 3xCaBoy0Y7IL5KEf1GKxX+ZSa9xwwXnq36XKHDmwFWzeuBDMhqQAoBG6wsRkveBSZcjr acOg== X-Gm-Message-State: AOJu0YwrtHfXtjEb3fmNGcB75Uvf0LRZ/8rVk17+7BnjrDliBjDlEckB /mtr9scnvDKl7EDZfsVv/Gs= X-Google-Smtp-Source: AGHT+IH0TDQyxS0nBAwnkDd6lNW/7QG8fuvt7vWavpzE3qRnX3oeBZPsZexuyczfgMybAwOMefCa+Q== X-Received: by 2002:a17:906:1d08:b0:9e4:dc3f:ddae with SMTP id n8-20020a1709061d0800b009e4dc3fddaemr3626970ejh.33.1700210754604; Fri, 17 Nov 2023 00:45:54 -0800 (PST) Received: from [192.168.1.23] (ip-046-223-203-173.um13.pools.vodafone-ip.de. [46.223.203.173]) by smtp.gmail.com with ESMTPSA id k13-20020a170906128d00b009e609088c09sm551756ejb.1.2023.11.17.00.45.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Nov 2023 00:45:54 -0800 (PST) Message-ID: <0424a09b-6867-4be9-8207-9d92a6187191@gmail.com> Date: Fri, 17 Nov 2023 09:45:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: rdapp.gcc@gmail.com, gcc-patches , Tamar Christina Subject: Re: [PATCH] vect: Use statement vectype for conditional mask. Content-Language: en-US To: Richard Biener , Richard Sandiford References: From: Robin Dapp In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.2 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,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 List-Id: > But note you can explicitly specify a vector type as well, there's an > overload for it, so we can fix the "invariant" case with the following > (OK if you can test this on relevant targets) > > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > index 3f59139cb01..936a3de9534 100644 > --- a/gcc/tree-vect-loop.cc > +++ b/gcc/tree-vect-loop.cc > @@ -8450,12 +8450,14 @@ vect_transform_reduction (loop_vec_info loop_vinfo, > value. */ > bool cond_fn_p = code.is_internal_fn () > && conditional_internal_fn_code (internal_fn (code)) != ERROR_MARK; > + int cond_index = -1; > if (cond_fn_p) > { > gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB > || code == IFN_COND_MUL || code == IFN_COND_AND > || code == IFN_COND_IOR || code == IFN_COND_XOR); > gcc_assert (op.num_ops == 4 && (op.ops[1] == op.ops[3])); > + cond_index = 0; > } > > bool masked_loop_p = LOOP_VINFO_FULLY_MASKED_P (loop_vinfo); > @@ -8486,12 +8488,13 @@ vect_transform_reduction (loop_vec_info loop_vinfo, > vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, > single_defuse_cycle && reduc_index == 0 > ? NULL_TREE : op.ops[0], &vec_oprnds0, > + cond_index == 0 ? truth_type_for (vectype_in) : NULL_TREE, > single_defuse_cycle && reduc_index == 1 > - ? NULL_TREE : op.ops[1], &vec_oprnds1, > + ? NULL_TREE : op.ops[1], &vec_oprnds1, NULL_TREE, > op.num_ops == 4 > || (op.num_ops == 3 > && !(single_defuse_cycle && reduc_index == 2)) > - ? op.ops[2] : NULL_TREE, &vec_oprnds2); > + ? op.ops[2] : NULL_TREE, &vec_oprnds2, NULL_TREE); Ah, yes that's what I meant. I had something along those lines: + if (!cond_fn_p) + { + vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, + single_defuse_cycle && reduc_index == 0 + ? NULL_TREE : op.ops[0], &vec_oprnds0, + single_defuse_cycle && reduc_index == 1 + ? NULL_TREE : op.ops[1], &vec_oprnds1, + op.num_ops == 3 + && !(single_defuse_cycle && reduc_index == 2) + ? op.ops[2] : NULL_TREE, &vec_oprnds2); + } + else + { + /* For a conditional operation, pass the truth type as vectype for the + mask. */ + gcc_assert (single_defuse_cycle && reduc_index == 1); + vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies, + op.ops[0], &vec_oprnds0, + truth_type_for (vectype_in), + NULL_TREE, &vec_oprnds1, NULL_TREE, + op.ops[2], &vec_oprnds2, NULL_TREE); + } Even though this has a bit of duplication now I prefer it slightly because of the. I'd hope, once fully tested (it's already running but I'm having connection problems so don't know about the results yet), this could go in independently of the pattern fix? Regards Robin