[llvm] [SPIRV] Add logic for OpGenericCastToPtrExplicit rewriting (PR #146596)
Marcos Maronas via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 07:14:15 PDT 2025
================
@@ -0,0 +1,95 @@
+; This test checks that the address space casts for SPIR-V generic pointer casts
+; are lowered correctly by the infer-address-spaces pass.
+; RUN: opt < %s -passes=infer-address-spaces -S --mtriple=spirv64-unknown-unknown | FileCheck %s
+
+; Casting a global pointer to a global pointer.
+; The uses of c2 will be replaced with %global.
+; CHECK: @kernel1(ptr addrspace(1) %global)
+define i1 @kernel1(ptr addrspace(1) %global) {
+ %c1 = addrspacecast ptr addrspace(1) %global to ptr addrspace(4)
+ %c2 = call ptr addrspace(1) @llvm.spv.generic.cast.to.ptr.explicit(ptr addrspace(4) %c1)
+ ; CHECK: %b1 = icmp eq ptr addrspace(1) %global, null
+ %b1 = icmp eq ptr addrspace(1) %c2, null
+ ret i1 %b1
+}
+
+; Casting a global pointer to a local pointer.
+; The uses of c2 will be replaced with null.
----------------
maarquitos14 wrote:
I think this kind of comment is quite helpful, can we add something similar for the test cases below?
https://github.com/llvm/llvm-project/pull/146596
More information about the llvm-commits
mailing list