Skip to content

Commit d785e7c

Browse files
bowenxue-inteligcbot
authored andcommitted
Turn on Regkey EnableWaveShuffleIndexSinking
Turn on WaveShuffleIndexSinking by default
1 parent a6fda9e commit d785e7c

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

IGC/Compiler/Optimizer/WaveShuffleIndexSinking.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,15 @@ bool WaveShuffleIndexSinkingImpl::splitWaveShuffleIndexes()
404404
{
405405
if( auto* waveShuffleInst = dyn_cast<WaveShuffleIndexIntrinsic>( &I ) )
406406
{
407-
if( !waveShuffleInst->getUniqueUndroppableUser() )
407+
if( auto* constantChannel = dyn_cast<ConstantInt>( waveShuffleInst->getChannel() ) )
408408
{
409-
// More than one user, split to potentially uncover more chances sink each individual WaveShuffleIndex
410-
Changed = true;
411-
InstsToSplit.push_back( waveShuffleInst );
409+
// Do not split WaveShuffleIndex insts that do not have a constant index since they cannot be optimized by this pass anyways
410+
if( !waveShuffleInst->getUniqueUndroppableUser() )
411+
{
412+
// More than one user, split to potentially uncover more chances sink each individual WaveShuffleIndex
413+
Changed = true;
414+
InstsToSplit.push_back( waveShuffleInst );
415+
}
412416
}
413417
}
414418
}
@@ -423,7 +427,7 @@ bool WaveShuffleIndexSinkingImpl::splitWaveShuffleIndexes()
423427
auto* userInst = cast<Instruction>( user );
424428
auto* clonedWaveShuffleInst = instToSplit->clone();
425429
clonedWaveShuffleInst->setName( instToSplit->getName() + "_clone" );
426-
clonedWaveShuffleInst->insertBefore( userInst );
430+
clonedWaveShuffleInst->insertBefore( instToSplit );
427431
// Track replacement to perform after loop since iterators will be messed up if performed mid loop
428432
ReplacementPairs.emplace_back(userInst, clonedWaveShuffleInst );
429433
}

IGC/Compiler/tests/WaveShuffleIndexSinking/split-sink-merge.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ define void @test_split_sink_merge(i32 %a, i32 %b, i32 %c, i32 %d) {
2929
%use1_ws0 = shl i32 %ws0, 2
3030
; CHECK: add i32 [[WS0]], %c
3131
%anchor1_ws0 = add i32 %use1_ws0, %c
32-
; CHECK: [[WS1C1:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 [[USE1_WS0_WS1C1_HOISTED]], i32 1, i32 0)
32+
; CHECK: [[USE2_WS1C2_WS2C1_HOISTED:%.*]] = shl i32 %a, 3
33+
; CHECK-DAG: [[WS1C1:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 [[USE1_WS0_WS1C1_HOISTED]], i32 1, i32 0)
34+
; CHECK-DAG: [[WS1C2:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 [[USE2_WS1C2_WS2C1_HOISTED]], i32 1, i32 0)
3335
%ws1 = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 %a, i32 1, i32 0)
3436
%use1_ws1 = shl i32 %ws1, 2
3537
; CHECK: add i32 [[WS1C1]], %c
3638
%anchor1_ws1 = add i32 %use1_ws1, %c
37-
; CHECK: [[USE2_WS1C2_WS2C1_HOISTED:%.*]] = shl i32 %a, 3
38-
; CHECK: [[WS1C2:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 [[USE2_WS1C2_WS2C1_HOISTED]], i32 1, i32 0)
3939
%use2_ws1 = shl i32 %ws1, 3
4040
; CHECK: add i32 [[WS1C2]], %d
4141
%anchor2_ws1 = add i32 %use2_ws1, %d
42-
; CHECK: [[WS2C1:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 [[USE2_WS1C2_WS2C1_HOISTED]], i32 2, i32 0)
42+
; CHECK-DAG: [[WS2C1:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 [[USE2_WS1C2_WS2C1_HOISTED]], i32 2, i32 0)
43+
; CHECK-DAG: [[WS2C2:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 %a, i32 2, i32 0)
4344
%ws2 = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 %a, i32 2, i32 0)
4445
%use1_ws2 = shl i32 %ws2, 3
4546
; CHECK: add i32 [[WS2C1]], %d
4647
%anchor1_ws2 = add i32 %use1_ws2, %d
47-
; CHECK: [[WS2C2:%.*]] = call i32 @llvm.genx.GenISA.WaveShuffleIndex.i32(i32 %a, i32 2, i32 0)
4848
; CHECK: [[USE2_WS2C2_NOT_HOISTED:%.*]] = shl i32 [[WS2C2]], 4
4949
%use2_ws2 = shl i32 %ws2, 4
5050
; CHECK: add i32 [[USE2_WS2C2_NOT_HOISTED]], %d

IGC/common/igc_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ DECLARE_IGC_REGKEY(DWORD, FPRoundingModeCoalescingMaxDistance, 20, "Max distance
328328
DECLARE_IGC_REGKEY(bool, DisableDotAddToDp4aMerge, false, "Disable Dot and Add ops to Dp4a merge optimization.", false)
329329
DECLARE_IGC_REGKEY(bool, DisableLoopSplitWidePHIs, false, "Disable splitting of loop PHI values to eliminate subvector extract operations", false)
330330
DECLARE_IGC_REGKEY(bool, EnableBarrierControlFlowOptimizationPass, false, "Enable barrier control flow optimization pass", false)
331-
DECLARE_IGC_REGKEY(bool, EnableWaveShuffleIndexSinking, false, "Hoist identical instructions operating on WaveShuffleIndex instructions with the same source and a constant lane/channel", false)
331+
DECLARE_IGC_REGKEY(bool, EnableWaveShuffleIndexSinking, true, "Hoist identical instructions operating on WaveShuffleIndex instructions with the same source and a constant lane/channel", false)
332332
DECLARE_IGC_REGKEY(DWORD, WaveShuffleIndexSinkingMaxIterations, 3, "Max number of iterations to run iterative WaveShuffleIndexSinking", false)
333333
DECLARE_IGC_REGKEY(bool, EnableWaveAllJointReduction, false, "Enable Joint Reduction Optimization.", true)
334334

0 commit comments

Comments
 (0)