Skip to content

Commit abb6673

Browse files
committed
[SandboxVec] Early return checks
This patch implements a couple of early return checks.
1 parent 52dca6f commit abb6673

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
@@ -28,7 +28,18 @@ PreservedAnalyses SandboxVectorizerPass::run(Function &F,
2828
}
2929

3030
bool SandboxVectorizerPass::runImpl(Function &F) {
31+
// If the target claims to have no vector registers early return.
32+
if (!TTI->getNumberOfRegisters(TTI->getRegisterClassForType(true))) {
33+
LLVM_DEBUG(dbgs() << "SBVec: Target has no vector registers, return.\n");
34+
return false;
35+
}
3136
LLVM_DEBUG(dbgs() << "SBVec: Analyzing " << F.getName() << ".\n");
37+
// Don't vectorize when the attribute NoImplicitFloat is used.
38+
if (F.hasFnAttribute(Attribute::NoImplicitFloat)) {
39+
LLVM_DEBUG(dbgs() << "SBVec: NoImplicitFloat attribute, return.\n");
40+
return false;
41+
}
42+
3243
sandboxir::Context Ctx(F.getContext());
3344
// Create SandboxIR for `F`.
3445
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)