[PATCH] D32423: Constant fold barriers of null and undef
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 8 12:03:27 PDT 2017
davide added inline comments.
================
Comment at: lib/Analysis/ConstantFolding.cpp:1779-1783
+ if (isa<ConstantPointerNull>(Operands[0])) {
+ if (IntrinsicID == Intrinsic::invariant_group_barrier)
return Operands[0];
return nullptr;
}
----------------
Prazek wrote:
> majnemer wrote:
> > Isn't this only valid if the address space is zero?
> True, but can you pass pointer from another addrspace to invariant.group.barrier?
>
> When I try
> %X = addrspacecast i8* null to i8 addrspace(1)*
> %b2 = call i8* @llvm.invariant.group.barrier(i8* %X)
>
> I get
> error: '%X' defined with type 'i8 addrspace(1)*'
>
> I could add this line:
> cast<PointerType>(Operands[0]->getType())->getAddressSpace() == 0
> but I won't be able to test it in any way if I am not wrong.
>
Not positive about this, but does it work if you do:
```
%b2 = call i8* @llvm.invariant.group.barrier(i8* addrspace(4)* @global0)
```
where
```
@global0 = addrspace(4) constant i8* null
```
https://reviews.llvm.org/D32423
More information about the llvm-commits
mailing list