From: Sander de Smalen Date: Thu, 15 Jul 2021 11:22:24 +0000 (+0100) Subject: [LV] Fix determinism for failing scalable-call.ll test. X-Git-Tag: llvmorg-14-init~1383 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc7bdc1e7121693df112f2fdb11cc6b88580ba4b;p=platform%2Fupstream%2Fllvm.git [LV] Fix determinism for failing scalable-call.ll test. The sort function for emitting an OptRemark was not deterministic, which caused scalable-call.ll to fail on some buildbots. This patch fixes that. This patch also fixes an issue where `Instruction::comesBefore()` is called when two Instructions are in different basic blocks, which would otherwise cause an assertion failure. --- diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index e70c7f1..e263a5d 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -6111,10 +6111,15 @@ VectorizationFactor LoopVectorizationCostModel::selectVectorizationFactor( // Emit a report of VFs with invalid costs in the loop. if (!InvalidCosts.empty()) { - // Sort/group per instruction + // Sort/group per instruction (lexicographically within basic blocks). llvm::sort(InvalidCosts, [](InstructionVFPair &A, InstructionVFPair &B) { + const Instruction *AI = A.first, *BI = B.first; + if (AI->getParent() != BI->getParent()) + return AI->getParent() < BI->getParent(); ElementCountComparator ECC; - return A.first->comesBefore(B.first) || ECC(A.second, B.second); + if (AI != BI) + return AI->comesBefore(BI); + return ECC(A.second, B.second); }); // For a list of ordered instruction-vf pairs: diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll b/llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll index e118e98..28270e8 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/scalable-call.ll @@ -125,6 +125,42 @@ for.cond.cleanup: ; preds = %for.body ; CHECK-REMARKS: UserVF ignored because of invalid costs. ; CHECK-REMARKS-NEXT: t.c:3:10: Instruction with invalid costs prevented vectorization at VF=(vscale x 1): load +; CHECK-REMARKS-NEXT: t.c:3:40: Instruction with invalid costs prevented vectorization at VF=(vscale x 1): store +; CHECK-REMARKS-NEXT: t.c:3:20: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2): call to llvm.sin.f32 +; CHECK-REMARKS-NEXT: t.c:3:30: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2): call to llvm.sin.f32 +define void @vec_sin_no_mapping_ite(float* noalias nocapture %dst, float* noalias nocapture readonly %src, i64 %n) { +; CHECK: @vec_sin_no_mapping_ite +; CHECK-NOT: