diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -392,8 +392,33 @@ if (isa(Ty)) return false; + auto IsStored = [GV, &DL](Value *V) { + auto *SI = dyn_cast(V); + if (!SI) + return false; + + auto *GlobalVar = dyn_cast(GV); + Constant *StoredConst = dyn_cast(SI->getOperand(0)); + Constant *StoreAddr = dyn_cast(SI->getPointerOperand()); + if (!GlobalVar || !StoredConst || !StoreAddr) + return true; + + // Don't consider stores that only write the initializer value. + APInt Offset(DL.getIndexTypeSizeInBits(StoreAddr->getType()), 0); + Value *BasePtr = StoreAddr->stripAndAccumulateConstantOffsets( + DL, Offset, /* AllowNonInbounds */ true); + if (BasePtr != GlobalVar) + return true; + if (Constant *Result = + ConstantFoldLoadFromConst(GlobalVar->getInitializer(), + StoredConst->getType(), Offset, DL)) + return Result != StoredConst; + + return true; + }; + It->second.IsLoaded |= isa(V); - It->second.IsStored |= isa(V); + It->second.IsStored |= IsStored(V); continue; } diff --git a/llvm/test/Transforms/GlobalOpt/sra-many-stores-initializers.ll b/llvm/test/Transforms/GlobalOpt/sra-many-stores-initializers.ll --- a/llvm/test/Transforms/GlobalOpt/sra-many-stores-initializers.ll +++ b/llvm/test/Transforms/GlobalOpt/sra-many-stores-initializers.ll @@ -8,66 +8,30 @@ @c = global ptr null ;. -; CHECK: @[[GLOBAL_20PTR:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global [[STRUCT_20PTR:%.*]] zeroinitializer ; CHECK: @[[C:[a-zA-Z0-9_$"\\.-]+]] = global ptr null -; CHECK: @[[GLOBAL_20PTR_2:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global [[STRUCT_20PTR:%.*]] { ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr @c } ; CHECK: @[[GLOBAL_20PTR_3:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global [[STRUCT_20PTR:%.*]] { ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr null, ptr null, ptr null, ptr @c } -; CHECK: @[[GLOBAL_20PTR_4:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global [[STRUCT_20PTR:%.*]] { ptr null, ptr null, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr @c, ptr null, ptr null, ptr null, ptr @c } +; CHECK: @[[GLOBAL_20PTR_4_16:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global ptr null ;. define void @store_initializer() { ; CHECK-LABEL: @store_initializer( ; CHECK-NEXT: entry: -; CHECK-NEXT: store ptr null, ptr @global.20ptr, align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR:%.*]], ptr @global.20ptr, i64 0, i32 1), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 2), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 3), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 4), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 5), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 6), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 7), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 8), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 9), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 10), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 11), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 12), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 13), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 14), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 15), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 16), align 8 -; CHECK-NEXT: [[L0:%.*]] = load ptr, ptr @global.20ptr, align 8 -; CHECK-NEXT: store volatile ptr [[L0]], ptr @c, align 8 -; CHECK-NEXT: [[L1:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 1), align 8 -; CHECK-NEXT: store volatile ptr [[L1]], ptr @c, align 8 -; CHECK-NEXT: [[L2:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 2), align 8 -; CHECK-NEXT: store volatile ptr [[L2]], ptr @c, align 8 -; CHECK-NEXT: [[L3:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 3), align 8 -; CHECK-NEXT: store volatile ptr [[L3]], ptr @c, align 8 -; CHECK-NEXT: [[L4:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 4), align 8 -; CHECK-NEXT: store volatile ptr [[L4]], ptr @c, align 8 -; CHECK-NEXT: [[L5:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 5), align 8 -; CHECK-NEXT: store volatile ptr [[L5]], ptr @c, align 8 -; CHECK-NEXT: [[L6:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 6), align 8 -; CHECK-NEXT: store volatile ptr [[L6]], ptr @c, align 8 -; CHECK-NEXT: [[L7:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 7), align 8 -; CHECK-NEXT: store volatile ptr [[L7]], ptr @c, align 8 -; CHECK-NEXT: [[L8:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 8), align 8 -; CHECK-NEXT: store volatile ptr [[L8]], ptr @c, align 8 -; CHECK-NEXT: [[L9:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 9), align 8 -; CHECK-NEXT: store volatile ptr [[L9]], ptr @c, align 8 -; CHECK-NEXT: [[L10:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 10), align 8 -; CHECK-NEXT: store volatile ptr [[L10]], ptr @c, align 8 -; CHECK-NEXT: [[L11:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 11), align 8 -; CHECK-NEXT: store volatile ptr [[L11]], ptr @c, align 8 -; CHECK-NEXT: [[L12:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 12), align 8 -; CHECK-NEXT: store volatile ptr [[L12]], ptr @c, align 8 -; CHECK-NEXT: [[L13:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 13), align 8 -; CHECK-NEXT: store volatile ptr [[L13]], ptr @c, align 8 -; CHECK-NEXT: [[L14:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 14), align 8 -; CHECK-NEXT: store volatile ptr [[L14]], ptr @c, align 8 -; CHECK-NEXT: [[L15:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 15), align 8 -; CHECK-NEXT: store volatile ptr [[L15]], ptr @c, align 8 -; CHECK-NEXT: [[L16:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr, i64 0, i32 16), align 8 -; CHECK-NEXT: store volatile ptr [[L16]], ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 ; CHECK-NEXT: ret void ; entry: @@ -134,60 +98,24 @@ define void @store_null_initializer_2() { ; CHECK-LABEL: @store_null_initializer_2( ; CHECK-NEXT: entry: -; CHECK-NEXT: store ptr null, ptr @global.20ptr.2, align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR:%.*]], ptr @global.20ptr.2, i64 0, i32 1), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 2), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 3), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 4), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 5), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 6), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 7), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 8), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 9), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 10), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 11), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 12), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 13), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 14), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 15), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 16), align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 19), align 8 -; CHECK-NEXT: [[L0:%.*]] = load ptr, ptr @global.20ptr.2, align 8 -; CHECK-NEXT: store volatile ptr [[L0]], ptr @c, align 8 -; CHECK-NEXT: [[L1:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 1), align 8 -; CHECK-NEXT: store volatile ptr [[L1]], ptr @c, align 8 -; CHECK-NEXT: [[L2:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 2), align 8 -; CHECK-NEXT: store volatile ptr [[L2]], ptr @c, align 8 -; CHECK-NEXT: [[L3:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 3), align 8 -; CHECK-NEXT: store volatile ptr [[L3]], ptr @c, align 8 -; CHECK-NEXT: [[L4:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 4), align 8 -; CHECK-NEXT: store volatile ptr [[L4]], ptr @c, align 8 -; CHECK-NEXT: [[L5:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 5), align 8 -; CHECK-NEXT: store volatile ptr [[L5]], ptr @c, align 8 -; CHECK-NEXT: [[L6:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 6), align 8 -; CHECK-NEXT: store volatile ptr [[L6]], ptr @c, align 8 -; CHECK-NEXT: [[L7:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 7), align 8 -; CHECK-NEXT: store volatile ptr [[L7]], ptr @c, align 8 -; CHECK-NEXT: [[L8:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 8), align 8 -; CHECK-NEXT: store volatile ptr [[L8]], ptr @c, align 8 -; CHECK-NEXT: [[L9:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 9), align 8 -; CHECK-NEXT: store volatile ptr [[L9]], ptr @c, align 8 -; CHECK-NEXT: [[L10:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 10), align 8 -; CHECK-NEXT: store volatile ptr [[L10]], ptr @c, align 8 -; CHECK-NEXT: [[L11:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 11), align 8 -; CHECK-NEXT: store volatile ptr [[L11]], ptr @c, align 8 -; CHECK-NEXT: [[L12:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 12), align 8 -; CHECK-NEXT: store volatile ptr [[L12]], ptr @c, align 8 -; CHECK-NEXT: [[L13:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 13), align 8 -; CHECK-NEXT: store volatile ptr [[L13]], ptr @c, align 8 -; CHECK-NEXT: [[L14:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 14), align 8 -; CHECK-NEXT: store volatile ptr [[L14]], ptr @c, align 8 -; CHECK-NEXT: [[L15:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 15), align 8 -; CHECK-NEXT: store volatile ptr [[L15]], ptr @c, align 8 -; CHECK-NEXT: [[L16:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 16), align 8 -; CHECK-NEXT: store volatile ptr [[L16]], ptr @c, align 8 -; CHECK-NEXT: [[L19:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.2, i64 0, i32 19), align 8 -; CHECK-NEXT: store volatile ptr [[L19]], ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 ; CHECK-NEXT: ret void ; entry: @@ -380,56 +308,24 @@ define void @store_mixed_initializer() { ; CHECK-LABEL: @store_mixed_initializer( ; CHECK-NEXT: entry: -; CHECK-NEXT: store ptr null, ptr @global.20ptr.4, align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR:%.*]], ptr @global.20ptr.4, i64 0, i32 1), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 2), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 3), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 4), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 5), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 6), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 7), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 8), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 9), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 10), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 11), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 12), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 13), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 14), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 15), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 16), align 8 -; CHECK-NEXT: [[L0:%.*]] = load ptr, ptr @global.20ptr.4, align 8 -; CHECK-NEXT: store volatile ptr [[L0]], ptr @c, align 8 -; CHECK-NEXT: [[L1:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 1), align 8 -; CHECK-NEXT: store volatile ptr [[L1]], ptr @c, align 8 -; CHECK-NEXT: [[L2:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 2), align 8 -; CHECK-NEXT: store volatile ptr [[L2]], ptr @c, align 8 -; CHECK-NEXT: [[L3:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 3), align 8 -; CHECK-NEXT: store volatile ptr [[L3]], ptr @c, align 8 -; CHECK-NEXT: [[L4:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 4), align 8 -; CHECK-NEXT: store volatile ptr [[L4]], ptr @c, align 8 -; CHECK-NEXT: [[L5:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 5), align 8 -; CHECK-NEXT: store volatile ptr [[L5]], ptr @c, align 8 -; CHECK-NEXT: [[L6:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 6), align 8 -; CHECK-NEXT: store volatile ptr [[L6]], ptr @c, align 8 -; CHECK-NEXT: [[L7:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 7), align 8 -; CHECK-NEXT: store volatile ptr [[L7]], ptr @c, align 8 -; CHECK-NEXT: [[L8:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 8), align 8 -; CHECK-NEXT: store volatile ptr [[L8]], ptr @c, align 8 -; CHECK-NEXT: [[L9:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 9), align 8 -; CHECK-NEXT: store volatile ptr [[L9]], ptr @c, align 8 -; CHECK-NEXT: [[L10:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 10), align 8 -; CHECK-NEXT: store volatile ptr [[L10]], ptr @c, align 8 -; CHECK-NEXT: [[L11:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 11), align 8 -; CHECK-NEXT: store volatile ptr [[L11]], ptr @c, align 8 -; CHECK-NEXT: [[L12:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 12), align 8 -; CHECK-NEXT: store volatile ptr [[L12]], ptr @c, align 8 -; CHECK-NEXT: [[L13:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 13), align 8 -; CHECK-NEXT: store volatile ptr [[L13]], ptr @c, align 8 -; CHECK-NEXT: [[L14:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 14), align 8 -; CHECK-NEXT: store volatile ptr [[L14]], ptr @c, align 8 -; CHECK-NEXT: [[L15:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 15), align 8 -; CHECK-NEXT: store volatile ptr [[L15]], ptr @c, align 8 -; CHECK-NEXT: [[L16:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 16), align 8 +; CHECK-NEXT: store ptr @c, ptr @global.20ptr.4.16, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: [[L16:%.*]] = load ptr, ptr @global.20ptr.4.16, align 8 ; CHECK-NEXT: store volatile ptr [[L16]], ptr @c, align 8 ; CHECK-NEXT: ret void ; @@ -495,56 +391,24 @@ define void @store_mixed_initializer_geps_without_inbounds() { ; CHECK-LABEL: @store_mixed_initializer_geps_without_inbounds( ; CHECK-NEXT: entry: -; CHECK-NEXT: store ptr null, ptr @global.20ptr.4, align 8 -; CHECK-NEXT: store ptr null, ptr getelementptr inbounds ([[STRUCT_20PTR:%.*]], ptr @global.20ptr.4, i64 0, i32 1), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 2), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 3), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 4), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 5), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 6), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 7), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 8), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 9), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 10), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 11), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 12), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 13), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 14), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 15), align 8 -; CHECK-NEXT: store ptr @c, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 16), align 8 -; CHECK-NEXT: [[L0:%.*]] = load ptr, ptr @global.20ptr.4, align 8 -; CHECK-NEXT: store volatile ptr [[L0]], ptr @c, align 8 -; CHECK-NEXT: [[L1:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 1), align 8 -; CHECK-NEXT: store volatile ptr [[L1]], ptr @c, align 8 -; CHECK-NEXT: [[L2:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 2), align 8 -; CHECK-NEXT: store volatile ptr [[L2]], ptr @c, align 8 -; CHECK-NEXT: [[L3:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 3), align 8 -; CHECK-NEXT: store volatile ptr [[L3]], ptr @c, align 8 -; CHECK-NEXT: [[L4:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 4), align 8 -; CHECK-NEXT: store volatile ptr [[L4]], ptr @c, align 8 -; CHECK-NEXT: [[L5:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 5), align 8 -; CHECK-NEXT: store volatile ptr [[L5]], ptr @c, align 8 -; CHECK-NEXT: [[L6:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 6), align 8 -; CHECK-NEXT: store volatile ptr [[L6]], ptr @c, align 8 -; CHECK-NEXT: [[L7:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 7), align 8 -; CHECK-NEXT: store volatile ptr [[L7]], ptr @c, align 8 -; CHECK-NEXT: [[L8:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 8), align 8 -; CHECK-NEXT: store volatile ptr [[L8]], ptr @c, align 8 -; CHECK-NEXT: [[L9:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 9), align 8 -; CHECK-NEXT: store volatile ptr [[L9]], ptr @c, align 8 -; CHECK-NEXT: [[L10:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 10), align 8 -; CHECK-NEXT: store volatile ptr [[L10]], ptr @c, align 8 -; CHECK-NEXT: [[L11:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 11), align 8 -; CHECK-NEXT: store volatile ptr [[L11]], ptr @c, align 8 -; CHECK-NEXT: [[L12:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 12), align 8 -; CHECK-NEXT: store volatile ptr [[L12]], ptr @c, align 8 -; CHECK-NEXT: [[L13:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 13), align 8 -; CHECK-NEXT: store volatile ptr [[L13]], ptr @c, align 8 -; CHECK-NEXT: [[L14:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 14), align 8 -; CHECK-NEXT: store volatile ptr [[L14]], ptr @c, align 8 -; CHECK-NEXT: [[L15:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 15), align 8 -; CHECK-NEXT: store volatile ptr [[L15]], ptr @c, align 8 -; CHECK-NEXT: [[L16:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT_20PTR]], ptr @global.20ptr.4, i64 0, i32 16), align 8 +; CHECK-NEXT: store ptr @c, ptr @global.20ptr.4.16, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr null, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: store volatile ptr @c, ptr @c, align 8 +; CHECK-NEXT: [[L16:%.*]] = load ptr, ptr @global.20ptr.4.16, align 8 ; CHECK-NEXT: store volatile ptr [[L16]], ptr @c, align 8 ; CHECK-NEXT: ret void ;