[llvm] [VPlan] Add scalar inferencing support for addrspace cast (PR #92107)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 05:10:58 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: None (PietroGhg)
<details>
<summary>Changes</summary>
This PR addresses https://github.com/llvm/llvm-project/issues/91434
---
Full diff: https://github.com/llvm/llvm-project/pull/92107.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp (+1)
- (added) llvm/test/Transforms/LoopVectorize/as_cast.ll (+21)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index 5f93339083f0c..681cb43d44f66 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -185,6 +185,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
case Instruction::FPToUI:
case Instruction::PtrToInt:
case Instruction::IntToPtr:
+ case Instruction::AddrSpaceCast:
return R->getUnderlyingInstr()->getType();
case Instruction::Freeze:
case Instruction::FNeg:
diff --git a/llvm/test/Transforms/LoopVectorize/as_cast.ll b/llvm/test/Transforms/LoopVectorize/as_cast.ll
new file mode 100644
index 0000000000000..ff5f818e95e45
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/as_cast.ll
@@ -0,0 +1,21 @@
+; RUN: opt -passes=loop-vectorize %s
+; ModuleID = '<bc file>'
+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"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo(ptr addrspace(1) %in) {
+entry:
+ br label %for.body.i.epil
+
+for.body.i.epil: ; preds = %for.body.i.epil, %entry
+ %epil.iter = phi i64 [ %epil.iter.next, %for.body.i.epil ], [ 0, %entry ]
+ %arrayidx.ascast.i.epil = addrspacecast ptr addrspace(1) %in to ptr
+ %epil.iter.next = add i64 %epil.iter, 1
+ %arrayidx = getelementptr inbounds i64, ptr %arrayidx.ascast.i.epil, i64 %epil.iter.next
+ store i64 %epil.iter.next, ptr %arrayidx, align 4
+ %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, 7
+ br i1 %epil.iter.cmp.not, label %loop.exit, label %for.body.i.epil
+
+loop.exit: ; preds = %for.body.i.epil
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/92107
More information about the llvm-commits
mailing list