This PR extends isSafeToCastConstAddrSpace to treat ConstantAggregateZero like ConstantPointerNull. Tests shows an extra addrspacecast instruction is removed and icmp pointer vector operand's address space is now inferred. This change is motivated by inspecting the test in commit f7629f5945f6.
36 lines
1.5 KiB
LLVM
36 lines
1.5 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -S -passes=infer-address-spaces %s | FileCheck %s
|
|
|
|
define void @phi_poison(ptr addrspace(1) %arg, <2 x ptr addrspace(1)> %arg1) {
|
|
; CHECK-LABEL: @phi_poison(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i1 @is_leader()
|
|
; CHECK-NEXT: br i1 [[TMP0]], label [[LEADER:%.*]], label [[MERGE:%.*]]
|
|
; CHECK: leader:
|
|
; CHECK-NEXT: br label [[MERGE]]
|
|
; CHECK: merge:
|
|
; CHECK-NEXT: [[I:%.*]] = phi ptr addrspace(1) [ [[ARG:%.*]], [[LEADER]] ], [ poison, [[ENTRY:%.*]] ]
|
|
; CHECK-NEXT: [[I2:%.*]] = phi <2 x ptr addrspace(1)> [ [[ARG1:%.*]], [[LEADER]] ], [ poison, [[ENTRY]] ]
|
|
; CHECK-NEXT: [[J:%.*]] = icmp eq ptr addrspace(1) [[I]], addrspacecast (ptr null to ptr addrspace(1))
|
|
; CHECK-NEXT: [[J1:%.*]] = icmp eq <2 x ptr addrspace(1)> [[I2]], <ptr addrspace(1) addrspacecast (ptr null to ptr addrspace(1)), ptr addrspace(1) addrspacecast (ptr null to ptr addrspace(1))>
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
%is = call i1 @is_leader()
|
|
br i1 %is, label %leader, label %merge
|
|
|
|
leader:
|
|
%cast = addrspacecast ptr addrspace(1) %arg to ptr
|
|
%cast1 = addrspacecast <2 x ptr addrspace(1)> %arg1 to <2 x ptr>
|
|
br label %merge
|
|
|
|
merge:
|
|
%i = phi ptr [%cast, %leader], [poison, %entry]
|
|
%i1 = phi <2 x ptr> [%cast1, %leader], [poison, %entry]
|
|
%j = icmp eq ptr %i, null
|
|
%j1 = icmp eq <2 x ptr> %i1, zeroinitializer
|
|
ret void
|
|
}
|
|
|
|
declare i1 @is_leader()
|