Skip to content

Commit 0139985

Browse files
committed
[SandboxVec] Early return checks
This patch implements a couple of early return checks.
1 parent 7ea9f0d commit 0139985

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@ PreservedAnalyses SandboxVectorizerPass::run(Function &F,
2929
}
3030

3131
bool SandboxVectorizerPass::runImpl(Function &F) {
32+
// If the target claims to have no vector registers early return.
33+
if (!TTI->getNumberOfRegisters(TTI->getRegisterClassForType(true))) {
34+
LLVM_DEBUG(dbgs() << "SBVec: Target has no vector registers, return.\n");
35+
return false;
36+
}
3237
LLVM_DEBUG(dbgs() << "SBVec: Analyzing " << F.getName() << ".\n");
38+
// Don't vectorize when the attribute NoImplicitFloat is used.
39+
if (F.hasFnAttribute(Attribute::NoImplicitFloat)) {
40+
LLVM_DEBUG(dbgs() << "SBVec: NoImplicitFloat attribute, return.\n");
41+
return false;
42+
}
43+
3344
sandboxir::Context Ctx(F.getContext());
3445
// Create SandboxIR for `F`.
3546
sandboxir::Function &SBF = *Ctx.createFunction(&F);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: opt -passes=sandbox-vectorizer -debug -mtriple=x86_64-- -mattr=-sse %s 2>&1 | FileCheck %s
2+
; REQUIRES: asserts
3+
; Please note that this won't update automatically with update_test_checks.py !
4+
5+
; Check that we early return if the target has no vector registers.
6+
define void @no_vector_regs() {
7+
; CHECK: SBVec: Target has no vector registers, return.
8+
ret void
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: opt -passes=sandbox-vectorizer -debug %s 2>&1 | FileCheck %s
2+
; REQUIRES: asserts
3+
; Please note that this won't update automatically with update_test_checks.py !
4+
5+
; Check that we early return if the function has the NoImplicitFloat attribute.
6+
define void @no_implicit_float() noimplicitfloat {
7+
; CHECK: SBVec: NoImplicitFloat attribute, return.
8+
ret void
9+
}

0 commit comments

Comments
 (0)