1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes=newgvn -S < %s | FileCheck %s
4 target datalayout = "e-p:64:64:64"
6 ; GVN should ignore the store to p[1] to see that the load from p[0] is
9 define void @yes(i1 %c, ptr %p, ptr %q) nounwind {
10 ; CHECK-LABEL: define void @yes
11 ; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], ptr [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
13 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
14 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1
15 ; CHECK-NEXT: store i32 1, ptr [[P1]], align 4
16 ; CHECK-NEXT: br i1 [[C]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
18 ; CHECK-NEXT: store i32 0, ptr [[Q]], align 4
19 ; CHECK-NEXT: ret void
21 ; CHECK-NEXT: ret void
25 %p1 = getelementptr inbounds i32, ptr %p, i64 1
27 br i1 %c, label %if.else, label %if.then
38 ; GVN should ignore the store to p[1] to see that the first load from p[0] is
39 ; fully redundant. However, the second load is larger, so it's not a simple
42 define void @watch_out_for_size_change(i1 %c, ptr %p, ptr %q) nounwind {
43 ; CHECK-LABEL: define void @watch_out_for_size_change
44 ; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], ptr [[Q:%.*]]) #[[ATTR0]] {
46 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
47 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1
48 ; CHECK-NEXT: store i32 1, ptr [[P1]], align 4
49 ; CHECK-NEXT: br i1 [[C]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
51 ; CHECK-NEXT: store i32 0, ptr [[Q]], align 4
52 ; CHECK-NEXT: ret void
54 ; CHECK-NEXT: [[T64:%.*]] = load i64, ptr [[P]], align 4
55 ; CHECK-NEXT: store i64 [[T64]], ptr [[Q]], align 4
56 ; CHECK-NEXT: ret void
60 %p1 = getelementptr inbounds i32, ptr %p, i64 1
62 br i1 %c, label %if.else, label %if.then
70 %t64 = load i64, ptr %p
71 store i64 %t64, ptr %q