[llvm] llvm-reduce: Fix operand reduction asserting on target ext types (PR #132732)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 24 06:05:22 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/132732
Not all TargetExtTypes support zeroinit, so use poison as a substitute
if unavailable.
>From 9fe77abbcf6819c420ae8ae0c47790523c7682b4 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 24 Mar 2025 20:02:27 +0700
Subject: [PATCH] llvm-reduce: Fix operand reduction asserting on target ext
types
Not all TargetExtTypes support zeroinit, so use poison as a substitute
if unavailable.
---
.../reduce-operands-target-ext-ty.ll | 25 +++++++++++++++++++
.../llvm-reduce/deltas/ReduceOperands.cpp | 7 ++++++
2 files changed, 32 insertions(+)
create mode 100644 llvm/test/tools/llvm-reduce/reduce-operands-target-ext-ty.ll
diff --git a/llvm/test/tools/llvm-reduce/reduce-operands-target-ext-ty.ll b/llvm/test/tools/llvm-reduce/reduce-operands-target-ext-ty.ll
new file mode 100644
index 0000000000000..b975a8542fca6
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-operands-target-ext-ty.ll
@@ -0,0 +1,25 @@
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-zero --test FileCheck --test-arg %s --test-arg --input-file %s -o %t
+; RUN: FileCheck --check-prefixes=CHECK,ZERO %s < %t
+
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-one --test FileCheck --test-arg %s --test-arg --input-file %s -o %t
+; RUN: FileCheck --check-prefixes=CHECK,ONE %s < %t
+
+declare void @uses_ext_ty(target("sometarget.sometype"))
+
+; CHECK-LABEL: @foo(
+; ZERO: call void @uses_ext_ty(target("sometarget.sometype") poison)
+; ONE: call void @uses_ext_ty(target("sometarget.sometype") %arg)
+define void @foo(target("sometarget.sometype") %arg) {
+ call void @uses_ext_ty(target("sometarget.sometype") %arg)
+ ret void
+}
+
+declare void @uses_zeroinit_ext_ty(target("sometarget.sometype"))
+
+; CHECK-LABEL: @bar(
+; ZERO: call void @uses_zeroinit_ext_ty(target("spirv.sometype") zeroinitializer)
+; ONE: call void @uses_zeroinit_ext_ty(target("spirv.sometype") %arg)
+define void @bar(target("spirv.sometype") %arg) {
+ call void @uses_zeroinit_ext_ty(target("spirv.sometype") %arg)
+ ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
index 6bf84f2985dc2..97761860131c2 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
@@ -135,6 +135,13 @@ void llvm::reduceOperandsZeroDeltaPass(TestRunner &Test) {
if (switchCaseExists(Op, ConstantInt::get(IntTy, 0)))
return nullptr;
// Don't replace existing zeroes.
+
+ if (auto *TET = dyn_cast<TargetExtType>(Op->getType())) {
+ if (TET->hasProperty(TargetExtType::HasZeroInit))
+ return ConstantTargetNone::get(TET);
+ return PoisonValue::get(TET);
+ }
+
return isZero(Op) ? nullptr : Constant::getNullValue(Op->getType());
};
runDeltaPass(
More information about the llvm-commits
mailing list