1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -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(%Triple* nonnull dereferenceable(16) %lhs, %Triple* nonnull dereferenceable(16) %rhs) nofree nosync {
14 ; CHECK-NEXT: store i32 1, i32* @g, align 4
15 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr [[TRIPLE:%.*]], %Triple* [[RHS:%.*]], i64 0, i32 0
16 ; CHECK-NEXT: [[L0_ADDR:%.*]] = getelementptr inbounds [[TRIPLE]], %Triple* [[LHS:%.*]], i64 0, i32 0
17 ; CHECK-NEXT: [[L0:%.*]] = load i32, i32* [[L0_ADDR]], align 4
18 ; CHECK-NEXT: [[R0_ADDR:%.*]] = getelementptr inbounds [[TRIPLE]], %Triple* [[RHS]], i64 0, i32 0
19 ; CHECK-NEXT: [[R0:%.*]] = load i32, i32* [[R0_ADDR]], align 4
20 ; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[L0]], [[R0]]
21 ; CHECK-NEXT: br i1 [[CMP0]], label %"bb1+bb2", label [[FINAL:%.*]]
23 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[TRIPLE]], %Triple* [[LHS]], i64 0, i32 2
24 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[GEP]], i64 2
25 ; CHECK-NEXT: [[CSTR:%.*]] = bitcast i32* [[TMP0]] to i8*
26 ; CHECK-NEXT: [[CSTR1:%.*]] = bitcast i32* [[TMP1]] to i8*
27 ; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 8)
28 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[MEMCMP]], 0
29 ; CHECK-NEXT: br label [[FINAL]]
31 ; CHECK-NEXT: [[RET:%.*]] = phi i1 [ false, [[BB0:%.*]] ], [ [[TMP2]], %"bb1+bb2" ]
32 ; CHECK-NEXT: ret i1 [[RET]]
36 %gep = getelementptr %Triple, %Triple* %rhs, i64 0, i32 0
37 %l0_addr = getelementptr inbounds %Triple, %Triple* %lhs, i64 0, i32 0
38 %l0 = load i32, i32* %l0_addr, align 4
39 %r0_addr = getelementptr inbounds %Triple, %Triple* %rhs, i64 0, i32 0
40 %r0 = load i32, i32* %r0_addr, align 4
41 %cmp0 = icmp eq i32 %l0, %r0
42 br i1 %cmp0, label %bb1, label %final
45 %l1_addr = getelementptr inbounds %Triple, %Triple* %lhs, i64 0, i32 2
46 %l1 = load i32, i32* %l1_addr, align 4
47 %r1_addr = getelementptr inbounds i32, i32* %gep, i64 2
48 %r1 = load i32, i32* %r1_addr, align 4
49 %cmp1 = icmp eq i32 %l1, %r1
50 br i1 %cmp1, label %bb2, label %final
53 %l2_addr = getelementptr inbounds %Triple, %Triple* %lhs, i64 0, i32 3
54 %l2 = load i32, i32* %l2_addr, align 4
55 %r2_addr = getelementptr inbounds i32, i32* %gep, i64 3
56 %r2 = load i32, i32* %r2_addr, align 4
57 %cmp2 = icmp eq i32 %l2, %r2
60 final: ; preds = %bb2, %bb1, %bb0
61 %ret = phi i1 [ false, %bb0 ], [ false, %bb1 ], [ %cmp2, %bb2 ]