; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -gvn -S < %s | FileCheck %s @Data = common local_unnamed_addr global [32 x i32] zeroinitializer, align 4 ; Function Attrs: norecurse nounwind define void @testshl() local_unnamed_addr #0 { ; CHECK-LABEL: @testshl( ; CHECK-NEXT: entry: ; CHECK-NEXT: br label [[FOR_BODY:%.*]] ; CHECK: for.body: ; CHECK-NEXT: [[K_031:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[INC9:%.*]], [[FOR_INC8:%.*]] ] ; CHECK-NEXT: [[SHL:%.*]] = shl i32 1, [[K_031]] ; CHECK-NEXT: [[SHR:%.*]] = ashr exact i32 [[SHL]], 1 ; CHECK-NEXT: [[CMP229:%.*]] = icmp slt i32 [[SHL]], 64 ; CHECK-NEXT: br i1 [[CMP229]], label [[FOR_BODY3_PREHEADER:%.*]], label [[FOR_INC8]] ; CHECK: for.body3.preheader: ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[SHR]], 2 ; CHECK-NEXT: br label [[FOR_BODY3:%.*]] ; CHECK: for.body3: ; CHECK-NEXT: [[I_030:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY3]] ], [ [[DIV]], [[FOR_BODY3_PREHEADER]] ] ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[I_030]], [[SHR]] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [32 x i32], [32 x i32]* @Data, i32 0, i32 [[ADD]] ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds [32 x i32], [32 x i32]* @Data, i32 0, i32 [[I_030]] ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4, [[TBAA3:!tbaa !.*]] ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[ARRAYIDX4]], align 4, [[TBAA3]] ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP1]], [[TMP0]] ; CHECK-NEXT: store i32 [[SUB]], i32* [[ARRAYIDX]], align 4, [[TBAA3]] ; CHECK-NEXT: [[ADD7:%.*]] = add nsw i32 [[TMP1]], [[TMP0]] ; CHECK-NEXT: store i32 [[ADD7]], i32* [[ARRAYIDX4]], align 4, [[TBAA3]] ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_030]], 1 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[I_030]], 15 ; CHECK-NEXT: br i1 [[CMP2]], label [[FOR_BODY3]], label [[FOR_INC8]] ; CHECK: for.inc8: ; CHECK-NEXT: [[INC9]] = add nuw nsw i32 [[K_031]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC9]], 8 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END10:%.*]], label [[FOR_BODY]] ; CHECK: for.end10: ; CHECK-NEXT: ret void ; entry: br label %for.body for.body: ; preds = %for.inc8, %entry %k.031 = phi i32 [ 1, %entry ], [ %inc9, %for.inc8 ] %shl = shl i32 1, %k.031 %shr = ashr exact i32 %shl, 1 %cmp229 = icmp slt i32 %shl, 64 br i1 %cmp229, label %for.body3.preheader, label %for.inc8 for.body3.preheader: ; preds = %for.body %div = sdiv i32 %shr, 2 br label %for.body3 for.body3: ; preds = %for.body3.preheader, %for.body3 %i.030 = phi i32 [ %inc, %for.body3 ], [ %div, %for.body3.preheader ] %add = add nsw i32 %i.030, %shr %arrayidx = getelementptr inbounds [32 x i32], [32 x i32]* @Data, i32 0, i32 %add %arrayidx4 = getelementptr inbounds [32 x i32], [32 x i32]* @Data, i32 0, i32 %i.030 %0 = load i32, i32* %arrayidx, align 4, !tbaa !3 %1 = load i32, i32* %arrayidx4, align 4, !tbaa !3 %sub = sub nsw i32 %1, %0 store i32 %sub, i32* %arrayidx, align 4, !tbaa !3 %2 = load i32, i32* %arrayidx4, align 4, !tbaa !3 %add7 = add nsw i32 %2, %0 store i32 %add7, i32* %arrayidx4, align 4, !tbaa !3 %inc = add nsw i32 %i.030, 1 %cmp2 = icmp slt i32 %i.030, 15 br i1 %cmp2, label %for.body3, label %for.inc8 for.inc8: ; preds = %for.body3, %for.body %inc9 = add nuw nsw i32 %k.031, 1 %exitcond = icmp eq i32 %inc9, 8 br i1 %exitcond, label %for.end10, label %for.body for.end10: ; preds = %for.inc8 ret void } attributes #0 = { norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-m7" "target-features"="+d16,+dsp,+fp-armv8,+hwdiv,+strict-align,+thumb-mode" "unsafe-fp-math"="false" "use-soft-float"="false" } !llvm.module.flags = !{!0, !1} !llvm.ident = !{!2} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{i32 1, !"min_enum_size", i32 4} !2 = !{!"clang version 5.0.0 (http://llvm.org/git/clang.git 100ecde90ef26ee81763214d5fb335415ffc2b53) (http://llvm.org/git/llvm.git f2fe26d60eb81a699f2d565e8baabcaf32f9c5ea)"} !3 = !{!4, !4, i64 0} !4 = !{!"int", !5, i64 0} !5 = !{!"omnipotent char", !6, i64 0} !6 = !{!"Simple C/C++ TBAA"}