1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4 5@global = common global [1024 x i32] zeroinitializer, align 16 6 7;; We should be able to prove the equivalence of two of the phis, and then use that to eliminate 8;; one set of indexing calculations and a load 9 10; Function Attrs: nounwind ssp uwtable 11define i32 @bar(i32 %arg, i32 %arg1, i32 %arg2) #0 { 12; CHECK-LABEL: @bar( 13; CHECK-NEXT: bb: 14; CHECK-NEXT: br label %bb3 15; CHECK: bb3: 16; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ %arg, %bb ], [ [[TMP:%.*]]15, %bb17 ] 17; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ %arg2, %bb ], [ [[TMP18:%.*]], %bb17 ] 18; CHECK-NEXT: [[TMP6:%.*]] = phi i32 [ 0, %bb ], [ [[TMP14:%.*]], %bb17 ] 19; CHECK-NEXT: [[TMP7:%.*]] = sext i32 [[TMP]] to i64 20; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds [1024 x i32], [1024 x i32]* @global, i64 0, i64 [[TMP7]] 21; CHECK-NEXT: [[TMP9:%.*]] = load i32, i32* [[TMP8]], align 4 22; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP6]], [[TMP9]] 23; CHECK-NEXT: [[TMP14]] = add nsw i32 [[TMP10]], [[TMP9]] 24; CHECK-NEXT: [[TMP15:%.*]] = add nsw i32 [[TMP]], %arg1 25; CHECK-NEXT: br label %bb17 26; CHECK: bb17: 27; CHECK-NEXT: [[TMP18]] = add i32 [[TMP4]], -1 28; CHECK-NEXT: [[TMP19:%.*]] = icmp ne i32 [[TMP4]], 0 29; CHECK-NEXT: br i1 [[TMP19]], label %bb3, label %bb20 30; CHECK: bb20: 31; CHECK-NEXT: ret i32 [[TMP14]] 32; 33bb: 34 br label %bb3 35 36bb3: ; preds = %bb17, %bb 37 %tmp = phi i32 [ %arg, %bb ], [ %tmp15, %bb17 ] 38 %tmp4 = phi i32 [ %arg2, %bb ], [ %tmp18, %bb17 ] 39 %tmp5 = phi i32 [ %arg, %bb ], [ %tmp16, %bb17 ] 40 %tmp6 = phi i32 [ 0, %bb ], [ %tmp14, %bb17 ] 41 %tmp7 = sext i32 %tmp to i64 42 %tmp8 = getelementptr inbounds [1024 x i32], [1024 x i32]* @global, i64 0, i64 %tmp7 43 %tmp9 = load i32, i32* %tmp8, align 4 44 %tmp10 = add nsw i32 %tmp6, %tmp9 45 %tmp11 = sext i32 %tmp5 to i64 46 %tmp12 = getelementptr inbounds [1024 x i32], [1024 x i32]* @global, i64 0, i64 %tmp11 47 %tmp13 = load i32, i32* %tmp12, align 4 48 %tmp14 = add nsw i32 %tmp10, %tmp13 49 %tmp15 = add nsw i32 %tmp, %arg1 50 %tmp16 = add nsw i32 %tmp5, %arg1 51 br label %bb17 52 53bb17: ; preds = %bb3 54 %tmp18 = add i32 %tmp4, -1 55 %tmp19 = icmp ne i32 %tmp4, 0 56 br i1 %tmp19, label %bb3, label %bb20 57 58bb20: ; preds = %bb17 59 ret i32 %tmp14 60} 61 62attributes #0 = { nounwind ssp uwtable "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-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3" "unsafe-fp-math"="false" "use-soft-float"="false" } 63 64!llvm.module.flags = !{!0} 65!llvm.ident = !{!1} 66 67!0 = !{i32 1, !"PIC Level", i32 2} 68!1 = !{!"Apple LLVM version 8.0.0 (clang-800.0.42.1)"} 69