[llvm] [GlobalISel][AArch64] Do not remove dst type predicates from pattern children nodes. (PR #221576)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 03:49:19 PDT 2026
https://github.com/davemgreen updated https://github.com/llvm/llvm-project/pull/221576
>From 61b8f5672b4eec47bbbde5e67d85eb046a842046 Mon Sep 17 00:00:00 2001
From: David Green <david.green at arm.com>
Date: Mon, 7 Sep 2026 11:49:02 +0100
Subject: [PATCH] [GlobalISel][AArch64] Do not remove dst type predicates from
pattern children nodes.
Given an instruction with a non-concrete type (G_CONCAT_VECTOR), with a child
pattern instruction with a concrete type (G_FPTRUNC), the concrete type check
for the child would incorrectly be removed. This patch makes sure they remain.
This makes the match table a little larger, but many should be able to be
optimized away (providing that the two operands with the same type can be
matched up).
Fixes #221458
---
llvm/test/CodeGen/AArch64/fptrunc.ll | 1 +
.../TableGen/Common/GlobalISel/MatchTable/Matchers.cpp | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/test/CodeGen/AArch64/fptrunc.ll b/llvm/test/CodeGen/AArch64/fptrunc.ll
index 56b20eaac1c80..1e968eeea3d31 100644
--- a/llvm/test/CodeGen/AArch64/fptrunc.ll
+++ b/llvm/test/CodeGen/AArch64/fptrunc.ll
@@ -2,6 +2,7 @@
; RUN: llc -mtriple=aarch64 -global-isel=0 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
; RUN: llc -mtriple=aarch64 -global-isel=1 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
; RUN: llc -mtriple=aarch64 -global-isel=1 -mattr=+fullfp16,+bf16 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
+; RUN: llc -mtriple=aarch64 -global-isel=1 -mattr=+bf16 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
define float @fptrunc_f64_f32(double %a) {
; CHECK-LABEL: fptrunc_f64_f32:
diff --git a/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp b/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp
index cc1089fc316c7..5b750dceff325 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp
@@ -1628,8 +1628,15 @@ void InstructionMatcher::optimize() {
if (InsnVarID > 0) {
assert(!Operands.empty() && "Nested instruction is expected to def a vreg");
- for (auto &OP : Operands[0]->predicates())
+ for (auto &OP : Operands[0]->predicates()) {
+ // LLTOperandMatcher need to be kept as they may have a more specific type
+ // than the parent instruction type.
+ if (const auto *LLTPred = dyn_cast<LLTOperandMatcher>(&*OP))
+ if (!LLTPred->getTy().get().isAnyScalar() &&
+ !LLTPred->getTy().get().isAnyVector())
+ continue;
OP.reset();
+ }
Operands[0]->eraseNullPredicates();
}
for (auto &OM : Operands) {
More information about the llvm-commits
mailing list