Skip to content

Commit 47ba614

Browse files
mshelegoigcbot
authored andcommitted
Do not lower constant predicates
During predicate lowering we unbale, create new instructions and bale again. But in a case of constant input, instead of instruction creation constants are just folded. Such predicates should not be lowered - they are represented as SETP
1 parent 1a9a204 commit 47ba614

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPredRegionLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,11 @@ void GenXPredRegionLowering::processWrPredRegionBales() {
218218
void GenXPredRegionLowering::processWrPredRegion(Instruction &WrPredRegion) {
219219
IGC_ASSERT(vc::getAnyIntrinsicID(&WrPredRegion) ==
220220
GenXIntrinsic::genx_wrpredregion);
221-
IRBuilder<> IRB(&WrPredRegion);
222-
223221
Value *NewPred = WrPredRegion.getOperand(PredRegion::NewValueOperandNum);
222+
// If wrpred has a constant input, it will be represented as SETP in vISA
223+
if (isa<Constant>(NewPred))
224+
return;
225+
IRBuilder<> IRB(&WrPredRegion);
224226
Value *Sel = createSelect(*NewPred, IRB);
225227
NewPred = createPredWithICmp(*Sel, IRB);
226228

IGC/VectorCompiler/test/PredRegionLowering/basic.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,12 @@ define spir_func void @test_rd_and_wrpredregion_bale(<32 x i1> %pred, <32 x i1>
4747
; CHECK: %[[wrpr:.*]] = call <32 x i1> @llvm.genx.wrpredregion.v32i1.v16i1(<32 x i1> %pred2, <16 x i1> %[[cmp]], i32 16)
4848
}
4949

50+
; CHECK-LABEL: test_const_wrpredregion
51+
; CHECK-NOT: select
52+
; CHECK-NOT: icmp
53+
define spir_func void @test_const_wrpredregion(<32 x i1> %pred) #0 {
54+
%pred.wrpr = call <32 x i1> @llvm.genx.wrpredregion.v32i1.v16i1(<32 x i1> %pred, <16 x i1> <i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false>, i32 16)
55+
ret void
56+
}
57+
5058
attributes #0 = { "CMStackCall" }

0 commit comments

Comments
 (0)