[all-commits] [llvm/llvm-project] 9d570d: [ValueTracking] Return true for AddrSpaceCast in c...
Wenju He via All-commits
all-commits at lists.llvm.org
Mon Jun 23 17:44:09 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9d570d568b37249ddcff8319c5965c4bdc4f7ca2
https://github.com/llvm/llvm-project/commit/9d570d568b37249ddcff8319c5965c4bdc4f7ca2
Author: Wenju He <wenju.he at intel.com>
Date: 2025-06-24 (Tue, 24 Jun 2025)
Changed paths:
M clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl
M clang/test/CodeGenOpenCL/as_type.cl
M llvm/docs/LangRef.rst
M llvm/lib/Analysis/ValueTracking.cpp
M llvm/test/Transforms/Attributor/reduced/aapointer_info_map_invalidation.ll
A llvm/test/Transforms/InstCombine/AMDGPU/addrspacecast.ll
Log Message:
-----------
[ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (#144686)
In our downstream GPU target, following IR is valid before instcombine
although the second addrspacecast causes UB.
define i1 @test(ptr addrspace(1) noundef %v) {
%0 = addrspacecast ptr addrspace(1) %v to ptr addrspace(4)
%1 = call i32 @llvm.xxxx.isaddr.shared(ptr addrspace(4) %0)
%2 = icmp eq i32 %1, 0
%3 = addrspacecast ptr addrspace(4) %0 to ptr addrspace(3)
%4 = select i1 %2, ptr addrspace(3) null, ptr addrspace(3) %3
%5 = icmp eq ptr addrspace(3) %4, null
ret i1 %5
}
We have a custom optimization that replaces invalid addrspacecast with
poison, and IR is still valid since `select` stops poison propagation.
However, instcombine pass optimizes `select` to `or`:
%0 = addrspacecast ptr addrspace(1) %v to ptr addrspace(4)
%1 = call i32 @llvm.xxxx.isaddr.shared(ptr addrspace(4) %0)
%2 = icmp eq i32 %1, 0
%3 = addrspacecast ptr addrspace(1) %v to ptr addrspace(3)
%4 = icmp eq ptr addrspace(3) %3, null
%5 = or i1 %2, %4
ret i1 %5
The transform is invalid for our target.
---------
Co-authored-by: Nikita Popov <github at npopov.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list