Skip to content

Commit 302563b

Browse files
[AIE2][Combiner] Add generator for alternating sequences
1 parent 6aa86b5 commit 302563b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

llvm/lib/Target/AIE/AIE2PreLegalizerCombiner.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,30 @@ bool AIE2PreLegalizerCombinerImpl::tryToCombineIntrinsic(
152152
return false;
153153
}
154154

155+
CombinerHelper::GeneratorType sectionGenerator(const int32_t From,
156+
const int32_t To,
157+
const int32_t Partitions,
158+
const int32_t Increment) {
159+
int32_t RoundSize = To / Partitions;
160+
int32_t Index = 0;
161+
int32_t Round = 0;
162+
163+
return [=]() mutable {
164+
int32_t CurrentGroup = (Index / Increment) % Partitions;
165+
int32_t GroupFirstElement = CurrentGroup * RoundSize;
166+
int32_t IndexInGroup = Index % Increment;
167+
int32_t OffsetGroup = Round * Increment;
168+
int32_t Next = GroupFirstElement + IndexInGroup + OffsetGroup;
169+
if (++Index % (Partitions * Increment) == 0)
170+
Round++;
171+
172+
std::optional<int32_t> Return = std::optional<int32_t>(Next);
173+
if (Index == To + 1)
174+
Return = {};
175+
return Return;
176+
};
177+
}
178+
155179
bool AIE2PreLegalizerCombinerImpl::tryCombineShuffleVector(
156180
MachineInstr &MI) const {
157181
if (Helper.tryCombineShuffleVector(MI))

0 commit comments

Comments
 (0)