Skip to content

Commit f8a991b

Browse files
pkwasnie-inteligcbot
authored andcommitted
GEP Loop Strength Reduction pass - don't truncate index type
Don't truncate index type when inserting new GEP instructions.
1 parent 5953f09 commit f8a991b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ void Analyzer::analyzeGEP(GetElementPtrInst *GEP)
817817
return;
818818

819819
if (S->getType() != Start->getType())
820-
Start = SE.getZeroExtendExpr(Start, S->getType());
820+
Start = isa<SCEVSignExtendExpr>(S) ? SE.getSignExtendExpr(Start, S->getType()) : SE.getZeroExtendExpr(Start, S->getType());
821821

822822
// Try adding reduction to existing group
823823
for (auto &c : Candidates)

IGC/Compiler/tests/GEPLoopStrengthReduction/three_accesses_addexpr.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ entry:
4545
br i1 %cmp33, label %for.body.lr.ph, label %for.end
4646

4747
; CHECK-LABEL: for.body.lr.ph:
48-
; CHECK: [[ZEXT:%.*]] = zext i32 %add4.i.i.i to i64
49-
; CHECK: [[GEP_PHI1:%.*]] = getelementptr i32, i32 addrspace(1)* %p, i64 [[ZEXT]]
48+
; CHECK: [[SEXT:%.*]] = sext i32 %add4.i.i.i to i64
49+
; CHECK: [[GEP_PHI1:%.*]] = getelementptr i32, i32 addrspace(1)* %p, i64 [[SEXT]]
5050
; CHECK: br label %for.body
5151
for.body.lr.ph: ; preds = %entry
5252
br label %for.body

IGC/Compiler/tests/GEPLoopStrengthReduction/two_accesses_licm.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ entry:
3333

3434
; CHECK-LABEL: for.body.lr.ph:
3535
; CHECK: [[ADD:%.*]] = add i32 %delta, 2
36-
; CHECK: [[ZEXT:%.*]] = zext i32 [[ADD]] to i64
37-
; CHECK: [[GEP1:%.*]] = getelementptr i32, i32 addrspace(1)* %p, i64 [[ZEXT]]
36+
; CHECK: [[SEXT:%.*]] = sext i32 [[ADD]] to i64
37+
; CHECK: [[GEP1:%.*]] = getelementptr i32, i32 addrspace(1)* %p, i64 [[SEXT]]
3838
; CHECK: br label %for.body
3939
for.body.lr.ph: ; preds = %entry
4040
br label %for.body

0 commit comments

Comments
 (0)