1; RUN: opt -instcombine -S < %s | FileCheck %s 2 3%struct1 = type { %struct2*, i32, i32, i32 } 4%struct2 = type { i32, i32 } 5 6define i32 @test1(%struct1* %dm, i1 %tmp4, i64 %tmp9, i64 %tmp19) { 7bb: 8 %tmp = getelementptr inbounds %struct1* %dm, i64 0, i32 0 9 %tmp1 = load %struct2** %tmp, align 8 10 br i1 %tmp4, label %bb1, label %bb2 11 12bb1: 13 %tmp10 = getelementptr inbounds %struct2* %tmp1, i64 %tmp9 14 %tmp11 = getelementptr inbounds %struct2* %tmp10, i64 0, i32 0 15 store i32 0, i32* %tmp11, align 4 16 br label %bb3 17 18bb2: 19 %tmp20 = getelementptr inbounds %struct2* %tmp1, i64 %tmp19 20 %tmp21 = getelementptr inbounds %struct2* %tmp20, i64 0, i32 0 21 store i32 0, i32* %tmp21, align 4 22 br label %bb3 23 24bb3: 25 %phi = phi %struct2* [ %tmp10, %bb1 ], [ %tmp20, %bb2 ] 26 %tmp24 = getelementptr inbounds %struct2* %phi, i64 0, i32 1 27 %tmp25 = load i32* %tmp24, align 4 28 ret i32 %tmp25 29 30; CHECK-LABEL: @test1( 31; CHECK: getelementptr inbounds %struct2* %tmp1, i64 %tmp9, i32 0 32; CHECK: getelementptr inbounds %struct2* %tmp1, i64 %tmp19, i32 0 33; CHECK: %[[PHI:[0-9A-Za-z]+]] = phi i64 [ %tmp9, %bb1 ], [ %tmp19, %bb2 ] 34; CHECK: getelementptr inbounds %struct2* %tmp1, i64 %[[PHI]], i32 1 35 36} 37 38define i32 @test2(%struct1* %dm, i1 %tmp4, i64 %tmp9, i64 %tmp19) { 39bb: 40 %tmp = getelementptr inbounds %struct1* %dm, i64 0, i32 0 41 %tmp1 = load %struct2** %tmp, align 8 42 %tmp10 = getelementptr inbounds %struct2* %tmp1, i64 %tmp9 43 %tmp11 = getelementptr inbounds %struct2* %tmp10, i64 0, i32 0 44 store i32 0, i32* %tmp11, align 4 45 %tmp20 = getelementptr inbounds %struct2* %tmp1, i64 %tmp19 46 %tmp21 = getelementptr inbounds %struct2* %tmp20, i64 0, i32 0 47 store i32 0, i32* %tmp21, align 4 48 %tmp24 = getelementptr inbounds %struct2* %tmp10, i64 0, i32 1 49 %tmp25 = load i32* %tmp24, align 4 50 ret i32 %tmp25 51 52; CHECK-LABEL: @test2( 53; CHECK: getelementptr inbounds %struct2* %tmp1, i64 %tmp9, i32 0 54; CHECK: getelementptr inbounds %struct2* %tmp1, i64 %tmp19, i32 0 55; CHECK: getelementptr inbounds %struct2* %tmp1, i64 %tmp9, i32 1 56} 57