1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -passes=gvn -S < %s | FileCheck %s 3 4@Data = common local_unnamed_addr global [32 x i32] zeroinitializer, align 4 5 6; Function Attrs: norecurse nounwind 7define void @testshl() local_unnamed_addr #0 { 8; CHECK-LABEL: @testshl( 9; CHECK-NEXT: entry: 10; CHECK-NEXT: br label [[FOR_BODY:%.*]] 11; CHECK: for.body: 12; CHECK-NEXT: [[K_031:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[INC9:%.*]], [[FOR_INC8:%.*]] ] 13; CHECK-NEXT: [[SHL:%.*]] = shl i32 1, [[K_031]] 14; CHECK-NEXT: [[SHR:%.*]] = ashr exact i32 [[SHL]], 1 15; CHECK-NEXT: [[CMP229:%.*]] = icmp slt i32 [[SHL]], 64 16; CHECK-NEXT: br i1 [[CMP229]], label [[FOR_BODY3_PREHEADER:%.*]], label [[FOR_INC8]] 17; CHECK: for.body3.preheader: 18; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[SHR]], 2 19; CHECK-NEXT: br label [[FOR_BODY3:%.*]] 20; CHECK: for.body3: 21; CHECK-NEXT: [[I_030:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY3]] ], [ [[DIV]], [[FOR_BODY3_PREHEADER]] ] 22; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[I_030]], [[SHR]] 23; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [32 x i32], ptr @Data, i32 0, i32 [[ADD]] 24; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds [32 x i32], ptr @Data, i32 0, i32 [[I_030]] 25; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4, [[TBAA3:!tbaa !.*]] 26; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX4]], align 4, [[TBAA3]] 27; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP1]], [[TMP0]] 28; CHECK-NEXT: store i32 [[SUB]], ptr [[ARRAYIDX]], align 4, [[TBAA3]] 29; CHECK-NEXT: [[ADD7:%.*]] = add nsw i32 [[TMP1]], [[TMP0]] 30; CHECK-NEXT: store i32 [[ADD7]], ptr [[ARRAYIDX4]], align 4, [[TBAA3]] 31; CHECK-NEXT: [[INC]] = add nsw i32 [[I_030]], 1 32; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[I_030]], 15 33; CHECK-NEXT: br i1 [[CMP2]], label [[FOR_BODY3]], label [[FOR_INC8]] 34; CHECK: for.inc8: 35; CHECK-NEXT: [[INC9]] = add nuw nsw i32 [[K_031]], 1 36; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC9]], 8 37; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END10:%.*]], label [[FOR_BODY]] 38; CHECK: for.end10: 39; CHECK-NEXT: ret void 40; 41entry: 42 br label %for.body 43 44for.body: ; preds = %for.inc8, %entry 45 %k.031 = phi i32 [ 1, %entry ], [ %inc9, %for.inc8 ] 46 %shl = shl i32 1, %k.031 47 %shr = ashr exact i32 %shl, 1 48 %cmp229 = icmp slt i32 %shl, 64 49 br i1 %cmp229, label %for.body3.preheader, label %for.inc8 50 51for.body3.preheader: ; preds = %for.body 52 %div = sdiv i32 %shr, 2 53 br label %for.body3 54 55for.body3: ; preds = %for.body3.preheader, %for.body3 56 %i.030 = phi i32 [ %inc, %for.body3 ], [ %div, %for.body3.preheader ] 57 %add = add nsw i32 %i.030, %shr 58 %arrayidx = getelementptr inbounds [32 x i32], ptr @Data, i32 0, i32 %add 59 %arrayidx4 = getelementptr inbounds [32 x i32], ptr @Data, i32 0, i32 %i.030 60 %0 = load i32, ptr %arrayidx, align 4, !tbaa !3 61 %1 = load i32, ptr %arrayidx4, align 4, !tbaa !3 62 %sub = sub nsw i32 %1, %0 63 store i32 %sub, ptr %arrayidx, align 4, !tbaa !3 64 %2 = load i32, ptr %arrayidx4, align 4, !tbaa !3 65 %add7 = add nsw i32 %2, %0 66 store i32 %add7, ptr %arrayidx4, align 4, !tbaa !3 67 %inc = add nsw i32 %i.030, 1 68 %cmp2 = icmp slt i32 %i.030, 15 69 br i1 %cmp2, label %for.body3, label %for.inc8 70 71for.inc8: ; preds = %for.body3, %for.body 72 %inc9 = add nuw nsw i32 %k.031, 1 73 %exitcond = icmp eq i32 %inc9, 8 74 br i1 %exitcond, label %for.end10, label %for.body 75 76for.end10: ; preds = %for.inc8 77 ret void 78} 79 80attributes #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" } 81 82!llvm.module.flags = !{!0, !1} 83!llvm.ident = !{!2} 84 85!0 = !{i32 1, !"wchar_size", i32 4} 86!1 = !{i32 1, !"min_enum_size", i32 4} 87!2 = !{!"clang version 5.0.0 (http://llvm.org/git/clang.git 100ecde90ef26ee81763214d5fb335415ffc2b53) (http://llvm.org/git/llvm.git f2fe26d60eb81a699f2d565e8baabcaf32f9c5ea)"} 88!3 = !{!4, !4, i64 0} 89!4 = !{!"int", !5, i64 0} 90!5 = !{!"omnipotent char", !6, i64 0} 91!6 = !{!"Simple C/C++ TBAA"} 92