73 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=gvn -S | FileCheck %s3 4; GVN should eliminate the fully redundant %9 GEP which5; allows DEAD to be removed. This is PR3198.6 7; The %7 and %4 loads combine to make %DEAD unneeded.8target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"9target triple = "i386-apple-darwin7"10@H = common global [100 x i32] zeroinitializer, align 32 ; <ptr> [#uses=3]11@G = common global i32 0 ; <ptr> [#uses=2]12 13define i32 @test(i32 %i) nounwind {14; CHECK-LABEL: @test(15; CHECK-NEXT: entry:16; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 (...) @foo() #[[ATTR0:[0-9]+]]17; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 018; CHECK-NEXT: br i1 [[TMP1]], label [[BB1:%.*]], label [[BB:%.*]]19; CHECK: bb:20; CHECK-NEXT: [[TMP2:%.*]] = tail call i32 (...) @bar() #[[ATTR0]]21; CHECK-NEXT: [[TMP3:%.*]] = getelementptr [100 x i32], ptr @H, i32 0, i32 [[I:%.*]]22; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[TMP3]], align 423; CHECK-NEXT: store i32 [[TMP4]], ptr @G, align 424; CHECK-NEXT: br label [[BB3:%.*]]25; CHECK: bb1:26; CHECK-NEXT: [[TMP5:%.*]] = tail call i32 (...) @baz() #[[ATTR0]]27; CHECK-NEXT: [[TMP6:%.*]] = getelementptr [100 x i32], ptr @H, i32 0, i32 [[I]]28; CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr [[TMP6]], align 429; CHECK-NEXT: store i32 [[TMP7]], ptr @G, align 430; CHECK-NEXT: [[TMP8:%.*]] = icmp eq i32 [[TMP7]], 031; CHECK-NEXT: br i1 [[TMP8]], label [[BB3]], label [[BB4:%.*]]32; CHECK: bb3:33; CHECK-NEXT: [[DEAD:%.*]] = phi i32 [ 0, [[BB1]] ], [ [[TMP4]], [[BB]] ]34; CHECK-NEXT: [[TMP9:%.*]] = getelementptr [100 x i32], ptr @H, i32 0, i32 [[I]]35; CHECK-NEXT: ret i32 [[DEAD]]36; CHECK: bb4:37; CHECK-NEXT: ret i32 038;39entry:40 %0 = tail call i32 (...) @foo() nounwind ; <i32> [#uses=1]41 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]42 br i1 %1, label %bb1, label %bb43 44bb: ; preds = %entry45 %2 = tail call i32 (...) @bar() nounwind ; <i32> [#uses=0]46 %3 = getelementptr [100 x i32], ptr @H, i32 0, i32 %i ; <ptr> [#uses=1]47 %4 = load i32, ptr %3, align 4 ; <i32> [#uses=1]48 store i32 %4, ptr @G, align 449 br label %bb350 51bb1: ; preds = %entry52 %5 = tail call i32 (...) @baz() nounwind ; <i32> [#uses=0]53 %6 = getelementptr [100 x i32], ptr @H, i32 0, i32 %i ; <ptr> [#uses=1]54 %7 = load i32, ptr %6, align 4 ; <i32> [#uses=2]55 store i32 %7, ptr @G, align 456 %8 = icmp eq i32 %7, 0 ; <i1> [#uses=1]57 br i1 %8, label %bb3, label %bb458 59bb3: ; preds = %bb1, %bb60 %9 = getelementptr [100 x i32], ptr @H, i32 0, i32 %i ; <ptr> [#uses=1]61 %DEAD = load i32, ptr %9, align 4 ; <i32> [#uses=1]62 ret i32 %DEAD63 64bb4: ; preds = %bb165 ret i32 066}67 68declare i32 @foo(...)69 70declare i32 @bar(...)71 72declare i32 @baz(...)73