mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
ConstantFold: Handle gep nonnull, undef as well
llvm-svn: 302447
This commit is contained in:
parent
7e86e4b1f7
commit
66d32d31c4
@ -2041,9 +2041,6 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
|
||||
Optional<unsigned> InRangeIndex,
|
||||
ArrayRef<Value *> Idxs) {
|
||||
if (Idxs.empty()) return C;
|
||||
Constant *Idx0 = cast<Constant>(Idxs[0]);
|
||||
if ((Idxs.size() == 1 && Idx0->isNullValue()))
|
||||
return C;
|
||||
|
||||
if (isa<UndefValue>(C)) {
|
||||
Type *GEPTy = GetElementPtrInst::getGEPReturnType(
|
||||
@ -2051,6 +2048,10 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
|
||||
return UndefValue::get(GEPTy);
|
||||
}
|
||||
|
||||
Constant *Idx0 = cast<Constant>(Idxs[0]);
|
||||
if (Idxs.size() == 1 && (Idx0->isNullValue() || isa<UndefValue>(Idx0)))
|
||||
return C;
|
||||
|
||||
if (C->isNullValue()) {
|
||||
bool isNull = true;
|
||||
for (unsigned i = 0, e = Idxs.size(); i != e; ++i)
|
||||
|
@ -6,7 +6,7 @@ target datalayout = "e-p3:32:32-p4:64:64-n32"
|
||||
@lds = internal addrspace(3) global [64 x i64] zeroinitializer
|
||||
|
||||
; CHECK-LABEL: @constexpr_addrspacecast_ptr_size_change(
|
||||
; CHECK: load i64, i64 addrspace(4)* getelementptr (i64, i64 addrspace(4)* addrspacecast (i64 addrspace(3)* getelementptr inbounds ([64 x i64], [64 x i64] addrspace(3)* @lds, i32 0, i32 0) to i64 addrspace(4)*), i64 undef)
|
||||
; CHECK: load i64, i64 addrspace(4)* addrspacecast (i64 addrspace(3)* getelementptr inbounds ([64 x i64], [64 x i64] addrspace(3)* @lds, i32 0, i32 0) to i64 addrspace(4)*)
|
||||
; CHECK-NEXT: br
|
||||
define void @constexpr_addrspacecast_ptr_size_change() #0 {
|
||||
%tmp0 = call i32 @foo(i64 addrspace(4)* addrspacecast (i64 addrspace(3)* getelementptr inbounds ([64 x i64], [64 x i64] addrspace(3)* @lds, i32 0, i32 0) to i64 addrspace(4)*)) #1
|
||||
|
Loading…
Reference in New Issue
Block a user