Skip to content

Commit a925591

Browse files
pkwasnie-inteligcbot
authored andcommitted
GEPLSR: disable any int bit width by default
Disable support for any integer bit width in GEPLSR pass.
1 parent 496d487 commit a925591

File tree

3 files changed

+21
-31
lines changed

3 files changed

+21
-31
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,15 +1438,16 @@ bool SCEVHelper::isValid(const SCEV *S)
14381438
if (!Ty->isIntegerTy())
14391439
return false;
14401440

1441-
switch (Ty->getScalarSizeInBits())
1441+
auto bits = Ty->getScalarSizeInBits();
1442+
switch (bits)
14421443
{
14431444
case 8:
14441445
case 16:
14451446
case 32:
14461447
case 64:
14471448
return false;
14481449
default:
1449-
return true;
1450+
return bits > 8;
14501451
}
14511452
};
14521453

IGC/Compiler/tests/GEPLoopStrengthReduction/illegal_types-typed-pointers.ll

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
;============================ end_copyright_notice =============================
88

99
; REQUIRES: regkeys
10-
; RUN: igc_opt --regkey=EnableGEPLSRMulExpr=1 --regkey=EnableGEPLSRAnyIntBitWidth=0 -debugify --igc-gep-loop-strength-reduction -check-debugify -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK-BLOCK-ILLEGAL
11-
; RUN: igc_opt --regkey=EnableGEPLSRMulExpr=1 --regkey=EnableGEPLSRAnyIntBitWidth=1 -debugify --igc-gep-loop-strength-reduction -check-debugify -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ALLOW-ILLEGAL
10+
; RUN: igc_opt --regkey=EnableGEPLSRMulExpr=1 --regkey=EnableGEPLSRAnyIntBitWidth=0 -debugify --igc-gep-loop-strength-reduction -check-debugify -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-BLOCK-ILLEGAL
11+
; RUN: igc_opt --regkey=EnableGEPLSRMulExpr=1 --regkey=EnableGEPLSRAnyIntBitWidth=1 -debugify --igc-gep-loop-strength-reduction -check-debugify -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-ALLOW-ILLEGAL
1212
;
1313
; Test for illegal types in SCEV expressions.
1414

@@ -75,40 +75,29 @@ for.end: ; preds = %for.cond.for.end_cr
7575

7676
; Instruction "and" creates SCEV with i7 type:
7777
; (zext i7 {(trunc i64 %b to i7),+,(trunc i64 %a to i7)}<%for.body> to i64)
78+
; Types <= i8 are correctly legalized.
7879
define spir_kernel void @test_and(i32 addrspace(1)* %p, i64 %n, i64 %a, i64 %b) {
7980
entry:
8081
%cmp1 = icmp slt i64 0, %n
8182
br i1 %cmp1, label %for.body.lr.ph, label %for.end
8283

83-
; CHECK-BLOCK-ILLEGAL-LABEL: for.body.lr.ph:
84-
; CHECK-BLOCK-ILLEGAL: br label %for.body
85-
; CHECK-ALLOW-ILLEGAL-LABEL: for.body.lr.ph:
86-
; CHECK-ALLOW-ILLEGAL: [[TRUNC1:%.*]] = trunc i64 %b to i7
87-
; CHECK-ALLOW-ILLEGAL: [[INDEX:%.*]] = zext i7 [[TRUNC1]] to i64
88-
; CHECK-ALLOW-ILLEGAL: [[GEP_PHI1:%.*]] = getelementptr i32, i32 addrspace(1)* %p, i64 [[INDEX]]
89-
; CHECK-ALLOW-ILLEGAL: [[TRUNC2:%.*]] = trunc i64 %a to i7
90-
; CHECK-ALLOW-ILLEGAL: br label %for.body
84+
; CHECK-LABEL: for.body.lr.ph:
85+
; CHECK: [[TRUNC1:%.*]] = trunc i64 %b to i7
86+
; CHECK: [[INDEX:%.*]] = zext i7 [[TRUNC1]] to i64
87+
; CHECK: [[GEP_PHI1:%.*]] = getelementptr i32, i32 addrspace(1)* %p, i64 [[INDEX]]
88+
; CHECK: [[TRUNC2:%.*]] = trunc i64 %a to i7
89+
; CHECK: br label %for.body
9190
for.body.lr.ph: ; preds = %entry
9291
br label %for.body
9392

94-
; CHECK-BLOCK-ILLEGAL-LABEL: for.body:
95-
; CHECK-BLOCK-ILLEGAL: %i.02 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
96-
; CHECK-BLOCK-ILLEGAL: %0 = mul i64 %i.02, %a
97-
; CHECK-BLOCK-ILLEGAL: %1 = add i64 %0, %b
98-
; CHECK-BLOCK-ILLEGAL: %idxprom = and i64 %1, 127
99-
; CHECK-BLOCK-ILLEGAL: %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %p, i64 %idxprom
100-
; CHECK-BLOCK-ILLEGAL: store i32 39, i32 addrspace(1)* %arrayidx, align 4
101-
; CHECK-BLOCK-ILLEGAL: %inc = add nuw nsw i64 %i.02, 1
102-
; CHECK-BLOCK-ILLEGAL: %cmp = icmp slt i64 %inc, %n
103-
; CHECK-BLOCK-ILLEGAL: br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
104-
; CHECK-ALLOW-ILLEGAL-LABEL: for.body:
105-
; CHECK-ALLOW-ILLEGAL: [[GEP:%.*]] = phi i32 addrspace(1)* [ [[GEP_PHI1]], %for.body.lr.ph ], [ [[GEP_PHI2:%.*]], %for.body ]
106-
; CHECK-ALLOW-ILLEGAL: %i.02 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
107-
; CHECK-ALLOW-ILLEGAL: store i32 39, i32 addrspace(1)* [[GEP]], align 4
108-
; CHECK-ALLOW-ILLEGAL: %inc = add nuw nsw i64 %i.02, 1
109-
; CHECK-ALLOW-ILLEGAL: %cmp = icmp slt i64 %inc, %n
110-
; CHECK-ALLOW-ILLEGAL: [[GEP_PHI2]] = getelementptr i32, i32 addrspace(1)* [[GEP]], i7 [[TRUNC2]]
111-
; CHECK-ALLOW-ILLEGAL: br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
93+
; CHECK-LABEL: for.body:
94+
; CHECK: [[GEP:%.*]] = phi i32 addrspace(1)* [ [[GEP_PHI1]], %for.body.lr.ph ], [ [[GEP_PHI2:%.*]], %for.body ]
95+
; CHECK: %i.02 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
96+
; CHECK: store i32 39, i32 addrspace(1)* [[GEP]], align 4
97+
; CHECK: %inc = add nuw nsw i64 %i.02, 1
98+
; CHECK: %cmp = icmp slt i64 %inc, %n
99+
; CHECK: [[GEP_PHI2]] = getelementptr i32, i32 addrspace(1)* [[GEP]], i7 [[TRUNC2]]
100+
; CHECK: br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
112101
for.body: ; preds = %for.body.lr.ph, %for.body
113102
%i.02 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
114103
%0 = mul i64 %i.02, %a

IGC/common/igc_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ DECLARE_IGC_REGKEY(bool, EnableGEPLSR, true, "Enables GEP Loop Strength Reductio
313313
DECLARE_IGC_REGKEY(bool, RunGEPLSRAfterLICM, false, "Runs GEP Loop Strength Reduction pass after first LICM", true)
314314
DECLARE_IGC_REGKEY(DWORD, GEPLSRThresholdRatio, 100, "Ratio for register pressure threshold in GEP Loop Strength Reduction pass", true)
315315
DECLARE_IGC_REGKEY(bool, EnableGEPLSRToPreheader, true, "Enables reduction to loop's preheader in GEP Loop Strength Reduction pass", true)
316-
DECLARE_IGC_REGKEY(bool, EnableGEPLSRAnyIntBitWidth, true, "Enables reduction of SCEV with illegal integers. Requires legalization pass to clear up expanded code.", true)
316+
DECLARE_IGC_REGKEY(bool, EnableGEPLSRAnyIntBitWidth, false, "Enables reduction of SCEV with illegal integers. Requires legalization pass to clear up expanded code.", true)
317317
DECLARE_IGC_REGKEY(bool, EnableGEPLSRMulExpr, true, "Experimental: Enables reduction of SCEV with mul expression.", true)
318318
DECLARE_IGC_REGKEY(bool, EnableGEPLSRUnknownConstantStep, false, "Experimental: Enables reduction of SCEV with step expressed with constant value unknown at compilation time.", true)
319319
DECLARE_IGC_REGKEY(bool, PrintWaveClusteredInterleave, false, "(Debug) Print if WaveClusteredInterleave pattern was found.", true)

0 commit comments

Comments
 (0)