Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ SOURCE_FILES = \
ImageParam.cpp \
InferArguments.cpp \
InjectHostDevBufferCopies.cpp \
InjectModuloVars.cpp \
Inline.cpp \
InlineReductions.cpp \
IntegerDivisionTable.cpp \
Expand Down Expand Up @@ -730,6 +731,7 @@ HEADER_FILES = \
ImageParam.h \
InferArguments.h \
InjectHostDevBufferCopies.h \
InjectModuloVars.h \
Inline.h \
InlineReductions.h \
IntegerDivisionTable.h \
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ target_sources(
ImageParam.h
InferArguments.h
InjectHostDevBufferCopies.h
InjectModuloVars.h
Inline.h
InlineReductions.h
IntegerDivisionTable.h
Expand Down Expand Up @@ -319,6 +320,7 @@ target_sources(
ImageParam.cpp
InferArguments.cpp
InjectHostDevBufferCopies.cpp
InjectModuloVars.cpp
Inline.cpp
InlineReductions.cpp
IntegerDivisionTable.cpp
Expand Down
15 changes: 13 additions & 2 deletions src/Deinterleave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,17 @@ class Interleaver : public IRMutator {
return visit_let(op);
}

// The largest stride we'll deinterleave a ramp by. This is what decides
// whether a vectorized loop over a repeating pattern -- a sensor's colour
// filter array, say -- gets split into one slice per phase, so that each
// slice has a phase known at compile time. Bayer needs two and X-Trans
// needs six.
//
// It stops below eight because a permute with a period of eight is often
// better done as a single shuffle than as eight slices: on Hexagon, for
// instance, deinterleaving (x/8)*9 + x%8 displaces a single vdelta.
static constexpr int max_deinterleave_stride = 7;

Expr visit(const Ramp *op) override {
if (op->stride.type().is_vector() &&
is_const_one(op->stride) &&
Expand All @@ -536,7 +547,7 @@ class Interleaver : public IRMutator {

Expr visit(const Mod *op) override {
const Ramp *r = op->a.as<Ramp>();
for (int i = 2; i <= 4; ++i) {
for (int i = 2; i <= max_deinterleave_stride; ++i) {
if (r &&
is_const(op->b, i) &&
(r->type.lanes() % i) == 0) {
Expand All @@ -550,7 +561,7 @@ class Interleaver : public IRMutator {

Expr visit(const Div *op) override {
const Ramp *r = op->a.as<Ramp>();
for (int i = 2; i <= 4; ++i) {
for (int i = 2; i <= max_deinterleave_stride; ++i) {
if (r &&
is_const(op->b, i) &&
(r->type.lanes() % i) == 0 &&
Expand Down
Loading
Loading