From e781a5a548c8a16ecfb7e191de86e6eae86dc40e Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Thu, 13 Nov 2025 14:11:00 -0800 Subject: [PATCH] [profcheck] Disable verification of selects on vector conditions. --- llvm/lib/Transforms/Utils/ProfileVerify.cpp | 16 ++++++---- .../Transforms/PGOProfile/profcheck-select.ll | 22 ++++++++++++-- llvm/utils/profcheck-xfail.txt | 30 ------------------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/llvm/lib/Transforms/Utils/ProfileVerify.cpp b/llvm/lib/Transforms/Utils/ProfileVerify.cpp index c578b4b839258..149c0879edcdd 100644 --- a/llvm/lib/Transforms/Utils/ProfileVerify.cpp +++ b/llvm/lib/Transforms/Utils/ProfileVerify.cpp @@ -102,9 +102,11 @@ bool ProfileInjector::inject() { for (auto &BB : F) { if (AnnotateSelect) { for (auto &I : BB) { - if (isa(I) && !I.getMetadata(LLVMContext::MD_prof)) - setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight}, - /*IsExpected=*/false); + if (auto *SI = dyn_cast(&I)) + if (!SI->getCondition()->getType()->isVectorTy() && + !I.getMetadata(LLVMContext::MD_prof)) + setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight}, + /*IsExpected=*/false); } } auto *Term = getTerminatorBenefitingFromMDProf(BB); @@ -185,9 +187,11 @@ PreservedAnalyses ProfileVerifierPass::run(Function &F, for (const auto &BB : F) { if (AnnotateSelect) { for (const auto &I : BB) - if (isa(I) && !I.getMetadata(LLVMContext::MD_prof)) - F.getContext().emitError( - "Profile verification failed: select annotation missing"); + if (auto *SI = dyn_cast(&I)) + if (!SI->getCondition()->getType()->isVectorTy() && + !I.getMetadata(LLVMContext::MD_prof)) + F.getContext().emitError( + "Profile verification failed: select annotation missing"); } if (const auto *Term = ProfileInjector::getTerminatorBenefitingFromMDProf(BB)) diff --git a/llvm/test/Transforms/PGOProfile/profcheck-select.ll b/llvm/test/Transforms/PGOProfile/profcheck-select.ll index 74bcb3f52428b..e6b3ddd42fcb0 100644 --- a/llvm/test/Transforms/PGOProfile/profcheck-select.ll +++ b/llvm/test/Transforms/PGOProfile/profcheck-select.ll @@ -15,7 +15,11 @@ ; RUN: not opt -passes=prof-verify %t/verify-missing.ll 2>&1 | FileCheck %t/verify-missing.ll ; verify we can disable it. It's sufficient to see opt not failing. -; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 %t/verify-missing.ll +; RUN: opt -passes=prof-verify -profcheck-annotate-select=0 --disable-output %t/verify-missing.ll + +; verify vector selects without profiles are OK. It's sufficient opt doesn't fail. +; RUN: opt -passes=prof-verify --disable-output %t/verify-vec.ll + ;--- inject.ll declare void @foo(i32 %a); @@ -24,8 +28,16 @@ define void @bar(i1 %c) { call void @foo(i32 %v) ret void } + +define <2 x i32> @vec(<2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2) { + %r = select <2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2 + ret <2 x i32> %r +} + ; CHECK-LABEL: @bar ; CHECK: %v = select i1 %c, i32 1, i32 2, !prof !1 +; CHECK-LABEL: @vec +; CHECK-NOT: select {{.*}} !prof ; CHECK: !0 = !{!"function_entry_count", i64 1000} ; CHECK: !1 = !{!"branch_weights", i32 2, i32 3} @@ -64,4 +76,10 @@ define void @bar(i1 %c) !prof !0 { ret void } !0 = !{!"function_entry_count", i64 1000} -; CHECK: Profile verification failed: select annotation missing \ No newline at end of file +; CHECK: Profile verification failed: select annotation missing + +;--- verify-vec.ll +define <2 x i32> @vec(<2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2) !prof !{!"function_entry_count", i32 10} { + %r = select <2 x i1> %c, <2 x i32> %v1, <2 x i32> %v2 + ret <2 x i32> %r +} diff --git a/llvm/utils/profcheck-xfail.txt b/llvm/utils/profcheck-xfail.txt index 10a7b62229b8d..a8cf2b1625f8f 100644 --- a/llvm/utils/profcheck-xfail.txt +++ b/llvm/utils/profcheck-xfail.txt @@ -24,7 +24,6 @@ DebugInfo/Generic/block-asan.ll DebugInfo/X86/asan_debug_info.ll LTO/X86/diagnostic-handler-remarks-with-hotness.ll Other/optimization-remarks-auto.ll -Other/X86/debugcounter-partiallyinlinelibcalls.ll Transforms/AtomicExpand/ARM/atomic-expansion-v7.ll Transforms/AtomicExpand/SPARC/partword.ll Transforms/Attributor/align.ll @@ -94,8 +93,6 @@ Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-constant-numerator.ll Transforms/CodeGenPrepare/NVPTX/bypass-slow-div.ll Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-not-exact.ll Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-special-cases.ll -Transforms/CodeGenPrepare/X86/vec-shift-inseltpoison.ll -Transforms/CodeGenPrepare/X86/vec-shift.ll Transforms/Coroutines/coro-await-suspend-lower-invoke.ll Transforms/Coroutines/coro-await-suspend-lower.ll Transforms/Coroutines/coro-byval-param.ll @@ -182,8 +179,6 @@ Transforms/GlobalOpt/shrink-global-to-bool-check-debug.ll Transforms/GlobalOpt/shrink-global-to-bool-opaque-ptrs.ll Transforms/GVN/debugloc-load-select.ll Transforms/GVN/load-through-select-dbg.ll -Transforms/GVN/masked-load-store.ll -Transforms/GVN/masked-load-store-no-mem-dep.ll Transforms/GVN/opaque-ptr.ll Transforms/GVN/pr69301.ll Transforms/GVN/pre-invalid-prof-metadata.ll @@ -236,9 +231,6 @@ Transforms/IndVarSimplify/pr45835.ll Transforms/IndVarSimplify/preserving-debugloc-rem-div.ll Transforms/InstCombine/2004-09-20-BadLoadCombine.ll Transforms/InstCombine/2005-04-07-UDivSelectCrash.ll -Transforms/InstCombine/AArch64/sve-intrinsic-sel.ll -Transforms/InstCombine/AArch64/sve-intrinsic-simplify-binop.ll -Transforms/InstCombine/AArch64/sve-intrinsic-simplify-shift.ll Transforms/InstCombine/add-mask.ll Transforms/InstCombine/add-shl-mul-umax.ll Transforms/InstCombine/and2.ll @@ -274,7 +266,6 @@ Transforms/InstCombine/fmul-bool.ll Transforms/InstCombine/fmul.ll Transforms/InstCombine/fneg.ll Transforms/InstCombine/fold-ctpop-of-not.ll -Transforms/InstCombine/fold-ext-eq-c-with-op.ll Transforms/InstCombine/free-inversion.ll Transforms/InstCombine/icmp-and-lowbit-mask.ll Transforms/InstCombine/icmp.ll @@ -294,8 +285,6 @@ Transforms/InstCombine/loadstore-metadata.ll Transforms/InstCombine/logical-select-inseltpoison.ll Transforms/InstCombine/logical-select.ll Transforms/InstCombine/lshr.ll -Transforms/InstCombine/masked_intrinsics-inseltpoison.ll -Transforms/InstCombine/masked_intrinsics.ll Transforms/InstCombine/memchr-11.ll Transforms/InstCombine/memchr-2.ll Transforms/InstCombine/memchr-3.ll @@ -332,14 +321,11 @@ Transforms/InstCombine/select-and-or.ll Transforms/InstCombine/select-cmp-br.ll Transforms/InstCombine/select-cmp.ll Transforms/InstCombine/select-factorize.ll -Transforms/InstCombine/select_frexp.ll Transforms/InstCombine/select.ll Transforms/InstCombine/select-min-max.ll Transforms/InstCombine/select-of-symmetric-selects.ll Transforms/InstCombine/select-select.ll Transforms/InstCombine/shift.ll -Transforms/InstCombine/shuffle-select-narrow-inseltpoison.ll -Transforms/InstCombine/shuffle-select-narrow.ll Transforms/InstCombine/simplify-demanded-fpclass.ll Transforms/InstCombine/sink-not-into-another-hand-of-logical-and.ll Transforms/InstCombine/sink-not-into-another-hand-of-logical-or.ll @@ -355,11 +341,8 @@ Transforms/InstCombine/sub-xor-cmp.ll Transforms/InstCombine/truncating-saturate.ll Transforms/InstCombine/unordered-fcmp-select.ll Transforms/InstCombine/urem-via-cmp-select.ll -Transforms/InstCombine/vec_sext.ll -Transforms/InstCombine/vector-urem.ll Transforms/InstCombine/wcslen-1.ll Transforms/InstCombine/wcslen-3.ll -Transforms/InstCombine/X86/blend_x86.ll Transforms/InstCombine/X86/x86-avx512-inseltpoison.ll Transforms/InstCombine/X86/x86-avx512.ll Transforms/InstCombine/xor-and-or.ll @@ -607,28 +590,18 @@ Transforms/OpenMP/spmdization_indirect.ll Transforms/OpenMP/spmdization.ll Transforms/OpenMP/spmdization_no_guarding_two_reaching_kernels.ll Transforms/OpenMP/spmdization_remarks.ll -Transforms/PartiallyInlineLibCalls/X86/good-prototype.ll Transforms/PGOProfile/comdat.ll Transforms/PGOProfile/memop_profile_funclet_wasm.ll Transforms/PGOProfile/X86/macho.ll Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll Transforms/PhaseOrdering/AArch64/globals-aa-required-for-vectorization.ll -Transforms/PhaseOrdering/AArch64/hoisting-sinking-required-for-vectorization.ll -Transforms/PhaseOrdering/AArch64/predicated-reduction.ll -Transforms/PhaseOrdering/AArch64/quant_4x4.ll -Transforms/PhaseOrdering/ARM/arm_mean_q7.ll -Transforms/PhaseOrdering/vector-select.ll -Transforms/PhaseOrdering/X86/blendv-select.ll Transforms/PhaseOrdering/X86/merge-functions2.ll Transforms/PhaseOrdering/X86/merge-functions3.ll Transforms/PhaseOrdering/X86/merge-functions.ll Transforms/PhaseOrdering/X86/pr52078.ll -Transforms/PhaseOrdering/X86/pr67803.ll Transforms/PhaseOrdering/X86/preserve-access-group.ll -Transforms/PhaseOrdering/X86/vector-reductions.ll Transforms/PreISelIntrinsicLowering/AArch64/expand-exp.ll Transforms/PreISelIntrinsicLowering/AArch64/expand-log.ll -Transforms/PreISelIntrinsicLowering/expand-vp.ll Transforms/PreISelIntrinsicLowering/PowerPC/memset-pattern.ll Transforms/PreISelIntrinsicLowering/RISCV/memset-pattern.ll Transforms/PreISelIntrinsicLowering/X86/memcpy-inline-non-constant-len.ll @@ -636,7 +609,6 @@ Transforms/PreISelIntrinsicLowering/X86/memset-inline-non-constant-len.ll Transforms/PreISelIntrinsicLowering/X86/memset-pattern.ll Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll Transforms/SampleProfile/remarks-hotness.ll -Transforms/SandboxVectorizer/special_opcodes.ll Transforms/ScalarizeMaskedMemIntrin/AArch64/expand-masked-load.ll Transforms/ScalarizeMaskedMemIntrin/AArch64/expand-masked-store.ll Transforms/ScalarizeMaskedMemIntrin/AArch64/streaming-compatible-expand-masked-gather-scatter.ll @@ -675,5 +647,3 @@ Transforms/UnifyLoopExits/switch.ll Transforms/UnifyLoopExits/undef-phis.ll Transforms/Util/libcalls-opt-remarks.ll Transforms/Util/lowerswitch.ll -Transforms/VectorCombine/AArch64/shuffletoidentity.ll -Transforms/VectorCombine/X86/shuffle-of-selects.ll