Skip to content

Commit 7732c57

Browse files
vmustyaigcbot
authored andcommitted
Fix LSC address operands folding in VC
When the LSC operation immediate offset is not a multiple of the element size, the finalizer shoud re-materialize the address arithmetic operation instead of fusing it with the LSC operation. VC can handle this case more efficiently by not folding the illegal immediate offset.
1 parent 1734d78 commit 7732c57

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXLscAddrCalcFolding.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2024 Intel Corporation
3+
Copyright (C) 2024-2025 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -60,6 +60,9 @@ class GenXLscAddrCalcFolding : public FunctionPass,
6060

6161
unsigned Supported2DOffsetBits = 0;
6262
bool Changed = false;
63+
64+
unsigned OffsetAlignment = 0;
65+
6366
};
6467

6568
} // namespace
@@ -213,6 +216,9 @@ bool GenXLscAddrCalcFolding::foldLscAddrCalculation(CallInst &Inst) {
213216
auto Scale = cast<ConstantInt>(Inst.getOperand(ScaleIndex))->getValue();
214217
auto Offset = cast<ConstantInt>(Inst.getOperand(OffsetIndex))->getValue();
215218

219+
OffsetAlignment = vc::InternalIntrinsic::getMemoryRegisterElementSize(&Inst) /
220+
genx::ByteBits;
221+
216222
while (auto *NewIndex = applyLscAddrFolding(Index, Scale, Offset)) {
217223
Index = NewIndex;
218224
Changed = true;
@@ -299,6 +305,10 @@ Value *GenXLscAddrCalcFolding::applyLscAddrFolding(Value *Offsets, APInt &Scale,
299305
if (Overflow)
300306
return nullptr;
301307

308+
if (auto NewOffsetVal = NewOffset.getSExtValue();
309+
NewOffsetVal % OffsetAlignment != 0)
310+
return nullptr;
311+
302312
Scale = std::move(NewScale);
303313
Offset = std::move(NewOffset);
304314

0 commit comments

Comments
 (0)