Skip to content

Commit 51d71dd

Browse files
vmustyaigcbot
authored andcommitted
Fix pattern matching pass in VC
Write region related transformations require DataLayout to detect pointer bit width.
1 parent dd055a9 commit 51d71dd

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ void GenXPatternMatch::visitICmpInst(ICmpInst &I) {
633633
BC->setDebugLoc(I.getDebugLoc());
634634

635635
// Create the new rdregion.
636-
vc::Region R(BC);
636+
vc::Region R(BC, DL);
637637
R.NumElements = NElts;
638638
R.Stride = Stride;
639639
R.Width = NElts;
@@ -2262,7 +2262,7 @@ bool GenXPatternMatch::propagateFoldableRegion(Function *F) {
22622262
if (WII->getOperand(1) != Mul)
22632263
continue;
22642264
auto W = makeRegionFromBaleInfo(WII, BaleInfo());
2265-
vc::Region V(Mul);
2265+
vc::Region V(Mul, DL);
22662266
// TODO: Consider the broadcast and similar cases.
22672267
if (!W.isStrictlySimilar(V))
22682268
continue;
@@ -2439,7 +2439,7 @@ bool GenXPatternMatch::simplifyWrRegion(CallInst *Inst) {
24392439
IRBuilder<> B(Inst);
24402440
NewV = B.CreateBitCast(NewV, IGCLLVM::FixedVectorType::get(NewVTy, 1));
24412441
}
2442-
vc::Region R(Inst->getType());
2442+
vc::Region R(Inst->getType(), DL);
24432443
R.Width = R.NumElements;
24442444
R.Stride = 0;
24452445
NewV = R.createRdRegion(NewV, "splat", Inst, Inst->getDebugLoc(),
@@ -3446,15 +3446,15 @@ bool GenXPatternMatch::vectorizeConstants(Function *F) {
34463446
IRBuilder<> Builder(Inst);
34473447
unsigned Width = cast<IGCLLVM::FixedVectorType>(ShtAmt[0]->getType())
34483448
->getNumElements();
3449-
vc::Region R(C->getType());
3449+
vc::Region R(C->getType(), DL);
34503450
R.getSubregion(0, Width);
34513451
Value *Val = UndefValue::get(C->getType());
34523452
Val = R.createWrRegion(Val, Base, "", Inst, Inst->getDebugLoc());
34533453
for (unsigned j = 1; j < (unsigned)ShtAmt.size(); ++j) {
34543454
auto Opc = C->getType()->isFPOrFPVectorTy() ? Instruction::FAdd
34553455
: Instruction::Add;
34563456
auto Input = Builder.CreateBinOp(Opc, Base, ShtAmt[j]);
3457-
vc::Region R1(C->getType());
3457+
vc::Region R1(C->getType(), DL);
34583458
R1.getSubregion(Width * j, Width);
34593459
Val = R1.createWrRegion(Val, Input, "", Inst, Inst->getDebugLoc());
34603460
}

IGC/VectorCompiler/test/PatternMatch/WrRegion_optimize.ll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;=========================== begin_copyright_notice ============================
22
;
3-
; Copyright (C) 2021 Intel Corporation
3+
; Copyright (C) 2021-2023 Intel Corporation
44
;
55
; SPDX-License-Identifier: MIT
66
;
@@ -20,3 +20,14 @@ define <16 x i32> @test(<64 x i32> %val, <16 x i1> %cond) {
2020
%3 = tail call <16 x i32> @llvm.genx.wrregioni.v16i32.v16i32.i16.v16i1(<16 x i32> %2, <16 x i32> %1, i32 0, i32 16, i32 1, i16 0, i32 16, <16 x i1> %cond)
2121
ret <16 x i32> %3
2222
}
23+
24+
declare <16 x i8 addrspace(1)*> @llvm.genx.wrregioni.v16p1i8.i16.i1(<16 x i8 addrspace(1)*>, i8 addrspace(1)*, i32, i32, i32, i16, i32, i1)
25+
26+
; CHECK-LABEL: @test_ptr_vector
27+
define <16 x i8 addrspace(1)*> @test_ptr_vector(i8 addrspace(1)* %p) {
28+
; CHECK: [[CAST:%[^ ]+]] = bitcast i8 addrspace(1)* %p to <1 x i8 addrspace(1)*>
29+
; CHECK: [[SPLAT:%[^ ]+]] = call <16 x i8 addrspace(1)*> @llvm.genx.rdregioni.v16p1i8.v1p1i8.i16(<1 x i8 addrspace(1)*> [[CAST]], i32 0, i32 16, i32 0, i16 0, i32 undef)
30+
; CHECK: ret <16 x i8 addrspace(1)*> [[SPLAT]]
31+
%broadcast = call <16 x i8 addrspace(1)*> @llvm.genx.wrregioni.v16p1i8.i16.i1(<16 x i8 addrspace(1)*> undef, i8 addrspace(1)* %p, i32 0, i32 1, i32 0, i16 0, i32 undef, i1 true)
32+
ret <16 x i8 addrspace(1)*> %broadcast
33+
}

0 commit comments

Comments
 (0)