1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=mergeicmps -verify-dom-info | FileCheck %s
3 target triple = "x86_64"
5 %Triple = type { i32, i32, i32, i32 }
7 @g = external global i32
9 ; bb1 references a gep introduced in bb0. The gep must remain available after
11 define i1 @bug(ptr nonnull dereferenceable(16) %lhs, ptr nonnull dereferenceable(16) %rhs) nofree nosync {
14 ; CHECK-NEXT: [[L0:%.*]] = load i32, ptr [[LHS:%.*]], align 4
15 ; CHECK-NEXT: [[R0:%.*]] = load i32, ptr [[RHS:%.*]], align 4
16 ; CHECK-NEXT: store i32 1, ptr @g, align 4
17 ; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[L0]], [[R0]]
18 ; CHECK-NEXT: br i1 [[CMP0]], label %"bb1+bb2", label [[FINAL:%.*]]
20 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[TRIPLE:%.*]], ptr [[LHS]], i64 0, i32 2
21 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, ptr [[RHS]], i64 2
22 ; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(ptr [[TMP0]], ptr [[TMP1]], i64 8)
23 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[MEMCMP]], 0
24 ; CHECK-NEXT: br label [[FINAL]]
26 ; CHECK-NEXT: [[RET:%.*]] = phi i1 [ false, [[BB0:%.*]] ], [ [[TMP2]], %"bb1+bb2" ]
27 ; CHECK-NEXT: ret i1 [[RET]]
30 %l0 = load i32, ptr %lhs, align 4
31 %r0 = load i32, ptr %rhs, align 4
33 %cmp0 = icmp eq i32 %l0, %r0
34 br i1 %cmp0, label %bb1, label %final
37 %l1_addr = getelementptr inbounds %Triple, ptr %lhs, i64 0, i32 2
38 %l1 = load i32, ptr %l1_addr, align 4
39 %r1_addr = getelementptr inbounds i32, ptr %rhs, i64 2
40 %r1 = load i32, ptr %r1_addr, align 4
41 %cmp1 = icmp eq i32 %l1, %r1
42 br i1 %cmp1, label %bb2, label %final
45 %l2_addr = getelementptr inbounds %Triple, ptr %lhs, i64 0, i32 3
46 %l2 = load i32, ptr %l2_addr, align 4
47 %r2_addr = getelementptr inbounds i32, ptr %rhs, i64 3
48 %r2 = load i32, ptr %r2_addr, align 4
49 %cmp2 = icmp eq i32 %l2, %r2
52 final: ; preds = %bb2, %bb1, %bb0
53 %ret = phi i1 [ false, %bb0 ], [ false, %bb1 ], [ %cmp2, %bb2 ]