; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; RUN: opt < %s -passes=licm -S | FileCheck %s
; PR9634
@g_58 = common global i32 0, align 4
@g_116 = common global ptr null, align 8
define void @f() {
; CHECK-LABEL: define void @f() {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[L_87_I:%.*]] = alloca [9 x i16], align 16
; CHECK-NEXT: [[G_58_PROMOTED:%.*]] = load i32, ptr @g_58, align 4, !tbaa [[TBAA0:![0-9]+]]
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[TMP31:%.*]] = phi i32 [ [[G_58_PROMOTED]], [[ENTRY:%.*]] ], [ [[OR:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[INC12:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT: [[OR]] = or i32 [[TMP31]], 10
; CHECK-NEXT: [[INC]] = add nsw i32 [[INC12]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], 4
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
; CHECK: for.end:
; CHECK-NEXT: [[OR_LCSSA:%.*]] = phi i32 [ [[OR]], [[FOR_BODY]] ]
; CHECK-NEXT: store ptr @g_58, ptr @g_116, align 8, !tbaa [[TBAA4:![0-9]+]]
; CHECK-NEXT: store i32 [[OR_LCSSA]], ptr @g_58, align 4, !tbaa [[TBAA0]]
; CHECK-NEXT: ret void
;
entry:
%l_87.i = alloca [9 x i16], align 16
br label %for.body
for.body: ; preds = %entry, %for.inc
%inc12 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
store ptr @g_58, ptr @g_116, align 8, !tbaa !0
%tmp2 = load ptr, ptr @g_116, align 8, !tbaa !0
%tmp3 = load i32, ptr %tmp2, !tbaa !4
%or = or i32 %tmp3, 10
store i32 %or, ptr %tmp2, !tbaa !4
%inc = add nsw i32 %inc12, 1
%cmp = icmp slt i32 %inc, 4
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.inc
ret void
}
!0 = !{!5, !5, i64 0}
!1 = !{!"omnipotent char", !2}
!2 = !{!"Simple C/C++ TBAA"}
!3 = !{!"short", !1}
!4 = !{!6, !6, i64 0}
!5 = !{!"any pointer", !1}
!6 = !{!"int", !1}