1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -passes=mergeicmps < %s | FileCheck %s 3 4target triple = "x86_64-unknown-linux-gnu" 5 6%"struct.a::c" = type { i32, ptr, ptr } 7 8; The entry block cannot be merged as the comparison is not continuous. 9; While it compares the highest address, it should not be moved after the 10; other comparisons, as that would make the allocas non-dominating. 11 12define i1 @test() { 13; CHECK-LABEL: @test( 14; CHECK-NEXT: "land.lhs.true+entry": 15; CHECK-NEXT: [[H:%.*]] = alloca %"struct.a::c", align 8 16; CHECK-NEXT: [[I:%.*]] = alloca %"struct.a::c", align 8 17; CHECK-NEXT: call void @init(ptr [[H]]) 18; CHECK-NEXT: call void @init(ptr [[I]]) 19; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds %"struct.a::c", ptr [[H]], i64 0, i32 1 20; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds %"struct.a::c", ptr [[I]], i64 0, i32 1 21; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(ptr [[TMP0]], ptr [[TMP1]], i64 16) 22; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[MEMCMP]], 0 23; CHECK-NEXT: br i1 [[TMP2]], label [[LAND_RHS1:%.*]], label [[LAND_END:%.*]] 24; CHECK: land.rhs1: 25; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[H]], align 8 26; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[I]], align 8 27; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[TMP3]], [[TMP4]] 28; CHECK-NEXT: br label [[LAND_END]] 29; CHECK: land.end: 30; CHECK-NEXT: [[V9:%.*]] = phi i1 [ [[TMP5]], [[LAND_RHS1]] ], [ false, %"land.lhs.true+entry" ] 31; CHECK-NEXT: ret i1 [[V9]] 32; 33entry: 34 %h = alloca %"struct.a::c", align 8 35 %i = alloca %"struct.a::c", align 8 36 call void @init(ptr %h) 37 call void @init(ptr %i) 38 %e = getelementptr inbounds %"struct.a::c", ptr %h, i64 0, i32 2 39 %v3 = load ptr, ptr %e, align 8 40 %e2 = getelementptr inbounds %"struct.a::c", ptr %i, i64 0, i32 2 41 %v4 = load ptr, ptr %e2, align 8 42 %cmp = icmp eq ptr %v3, %v4 43 br i1 %cmp, label %land.lhs.true, label %land.end 44 45land.lhs.true: ; preds = %entry 46 %d = getelementptr inbounds %"struct.a::c", ptr %h, i64 0, i32 1 47 %v5 = load ptr, ptr %d, align 8 48 %d3 = getelementptr inbounds %"struct.a::c", ptr %i, i64 0, i32 1 49 %v6 = load ptr, ptr %d3, align 8 50 %cmp4 = icmp eq ptr %v5, %v6 51 br i1 %cmp4, label %land.rhs, label %land.end 52 53land.rhs: ; preds = %land.lhs.true 54 %v7 = load i32, ptr %h, align 8 55 %v8 = load i32, ptr %i, align 8 56 %cmp6 = icmp eq i32 %v7, %v8 57 br label %land.end 58 59land.end: ; preds = %land.rhs, %land.lhs.true, %entry 60 %v9 = phi i1 [ false, %land.lhs.true ], [ false, %entry ], [ %cmp6, %land.rhs ] 61 ret i1 %v9 62} 63 64declare void @init(ptr) 65