1 ; RUN: opt < %s -basicaa -inline -instcombine -reassociate -dse -disable-output 2 ; PR12245 3 4 @a = common global i32 0, align 4 5 @d = common global i32 0, align 4 6 7 define i32 @fn2() nounwind uwtable ssp { 8 entry: 9 %0 = load i32* @a, align 4, !tbaa !0 10 %dec = add nsw i32 %0, -1 11 store i32 %dec, i32* @a, align 4, !tbaa !0 12 %1 = load i32* @d, align 4, !tbaa !0 13 %sub = sub nsw i32 %dec, %1 14 store i32 %sub, i32* @d, align 4, !tbaa !0 15 %2 = load i32* @a, align 4, !tbaa !0 16 %dec1 = add nsw i32 %2, -1 17 store i32 %dec1, i32* @a, align 4, !tbaa !0 18 %3 = load i32* @d, align 4, !tbaa !0 19 %sub2 = sub nsw i32 %dec1, %3 20 store i32 %sub2, i32* @d, align 4, !tbaa !0 21 %4 = load i32* @a, align 4, !tbaa !0 22 %dec3 = add nsw i32 %4, -1 23 store i32 %dec3, i32* @a, align 4, !tbaa !0 24 %5 = load i32* @d, align 4, !tbaa !0 25 %sub4 = sub nsw i32 %dec3, %5 26 store i32 %sub4, i32* @d, align 4, !tbaa !0 27 %6 = load i32* @a, align 4, !tbaa !0 28 %dec5 = add nsw i32 %6, -1 29 store i32 %dec5, i32* @a, align 4, !tbaa !0 30 %7 = load i32* @d, align 4, !tbaa !0 31 %sub6 = sub nsw i32 %dec5, %7 32 store i32 %sub6, i32* @d, align 4, !tbaa !0 33 %8 = load i32* @a, align 4, !tbaa !0 34 %dec7 = add nsw i32 %8, -1 35 store i32 %dec7, i32* @a, align 4, !tbaa !0 36 %9 = load i32* @d, align 4, !tbaa !0 37 %sub8 = sub nsw i32 %dec7, %9 38 store i32 %sub8, i32* @d, align 4, !tbaa !0 39 ret i32 0 40 } 41 42 define i32 @fn1() nounwind uwtable ssp { 43 entry: 44 %call = call i32 @fn2() 45 ret i32 %call 46 } 47 48 !0 = metadata !{metadata !"int", metadata !1} 49 !1 = metadata !{metadata !"omnipotent char", metadata !2} 50 !2 = metadata !{metadata !"Simple C/C++ TBAA"} 51