Skip to content

Commit d31c3af

Browse files
committed
[VPlan] Add scalar inferencing support for addrspace cast
1 parent afc10fc commit d31c3af

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
185185
case Instruction::FPToUI:
186186
case Instruction::PtrToInt:
187187
case Instruction::IntToPtr:
188+
case Instruction::AddrSpaceCast:
188189
return R->getUnderlyingInstr()->getType();
189190
case Instruction::Freeze:
190191
case Instruction::FNeg:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; RUN: opt -passes=loop-vectorize %s
2+
; ModuleID = '<bc file>'
3+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
4+
target triple = "x86_64-unknown-linux-gnu"
5+
6+
define void @foo(ptr addrspace(1) %in) {
7+
entry:
8+
br label %for.body.i.epil
9+
10+
for.body.i.epil: ; preds = %for.body.i.epil, %entry
11+
%epil.iter = phi i64 [ %epil.iter.next, %for.body.i.epil ], [ 0, %entry ]
12+
%arrayidx.ascast.i.epil = addrspacecast ptr addrspace(1) %in to ptr
13+
%epil.iter.next = add i64 %epil.iter, 1
14+
%arrayidx = getelementptr inbounds i64, ptr %arrayidx.ascast.i.epil, i64 %epil.iter.next
15+
store i64 %epil.iter.next, ptr %arrayidx, align 4
16+
%epil.iter.cmp.not = icmp eq i64 %epil.iter.next, 7
17+
br i1 %epil.iter.cmp.not, label %loop.exit, label %for.body.i.epil
18+
19+
loop.exit: ; preds = %for.body.i.epil
20+
ret void
21+
}

0 commit comments

Comments
 (0)