Skip to content

Commit dff1024

Browse files
KorovinVladigcbot
authored andcommitted
Set maximum alignment for zero constant
.
1 parent 141008e commit dff1024

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXAlignmentInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2023 Intel Corporation
3+
Copyright (C) 2017-2024 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -279,7 +279,7 @@ Alignment AlignmentInfo::get(Value *V)
279279
*/
280280
Alignment::Alignment(unsigned C)
281281
{
282-
LogAlign = countTrailingZeros(C);
282+
LogAlign = C ? countTrailingZeros(C) : 31;
283283
ExtraBits = 0;
284284
ConstBits = (C < MaskForUnknown) ? C : MaskForUnknown;
285285
}
@@ -296,7 +296,7 @@ Alignment Alignment::getAlignmentForConstant(Constant *C) {
296296
int64_t SVal = CI->getSExtValue();
297297
// Get least significant bits to count LogAlign
298298
unsigned LSBBits = SVal & UnsignedAllOnes;
299-
A.LogAlign = countTrailingZeros(LSBBits);
299+
A.LogAlign = LSBBits ? countTrailingZeros(LSBBits) : 31;
300300

301301
A.ExtraBits = 0;
302302
A.ConstBits = MaskForUnknown;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2024 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
9+
; RUN: %opt %use_old_pass_manager% -GenXLegalization -march=genx64 -mcpu=Gen11 -mtriple=spir64-unknown-unknown -S < %s | FileCheck %s
10+
11+
declare i16 @llvm.genx.rdregioni.i16.v2i16.i16(<2 x i16>, i32, i32, i32, i16, i32)
12+
declare <64 x i16> @llvm.genx.wrregioni.v64i16.v4i16.i16.i1(<64 x i16>, <4 x i16>, i32, i32, i32, i16, i32, i1)
13+
14+
define <64 x i16> @test(<64 x i16> %buff, <4 x i16> %insert, i1 %cmp.1, i1 %cmp.2, i1 %cmp.3) {
15+
entry:
16+
br i1 %cmp.1, label %l0, label %end
17+
18+
l0:
19+
br i1 %cmp.2, label %if, label %else
20+
21+
if:
22+
%ph.0 = phi i16 [ 0, %l0 ], [ %ph.1, %else]
23+
br label %else
24+
25+
else:
26+
%ph.1 = phi i16 [ 0, %l0 ], [ %ph.0, %if ]
27+
%val = sub i16 %ph.1, 0
28+
br i1 %cmp.3, label %end, label %if
29+
30+
end:
31+
%idx = phi i16 [ %val, %else ], [ 0, %entry ]
32+
; CHECK-NOT: call <1 x i16> @llvm.genx.rdregioni.v1i16.v4i16.i16
33+
%wrreg = tail call <64 x i16> @llvm.genx.wrregioni.v64i16.v4i16.i16.i1(<64 x i16> %buff, <4 x i16> %insert, i32 0, i32 2, i32 1, i16 %idx, i32 undef, i1 true)
34+
%res = add <64 x i16> %wrreg, %buff
35+
ret <64 x i16> %res
36+
}

0 commit comments

Comments
 (0)