1; RUN: opt -O3 -S < %s | FileCheck %s 2; XFAIL: * 3 4declare i32 @doo(...) 5 6; PR6627 - This whole nasty sequence should be flattened down to a single 7; 32-bit comparison. 8define void @test2(ptr %arrayidx) nounwind ssp { 9entry: 10 %x1 = load i32, ptr %arrayidx, align 4 11 %tmp = trunc i32 %x1 to i8 12 %conv = zext i8 %tmp to i32 13 %cmp = icmp eq i32 %conv, 127 14 br i1 %cmp, label %land.lhs.true, label %if.end 15 16land.lhs.true: ; preds = %entry 17 %arrayidx4 = getelementptr inbounds i8, ptr %arrayidx, i64 1 18 %tmp5 = load i8, ptr %arrayidx4, align 1 19 %conv6 = zext i8 %tmp5 to i32 20 %cmp7 = icmp eq i32 %conv6, 69 21 br i1 %cmp7, label %land.lhs.true9, label %if.end 22 23land.lhs.true9: ; preds = %land.lhs.true 24 %arrayidx12 = getelementptr inbounds i8, ptr %arrayidx, i64 2 25 %tmp13 = load i8, ptr %arrayidx12, align 1 26 %conv14 = zext i8 %tmp13 to i32 27 %cmp15 = icmp eq i32 %conv14, 76 28 br i1 %cmp15, label %land.lhs.true17, label %if.end 29 30land.lhs.true17: ; preds = %land.lhs.true9 31 %arrayidx20 = getelementptr inbounds i8, ptr %arrayidx, i64 3 32 %tmp21 = load i8, ptr %arrayidx20, align 1 33 %conv22 = zext i8 %tmp21 to i32 34 %cmp23 = icmp eq i32 %conv22, 70 35 br i1 %cmp23, label %if.then, label %if.end 36 37if.then: ; preds = %land.lhs.true17 38 %call25 = call i32 (...) @doo() 39 br label %if.end 40 41if.end: 42 ret void 43 44; CHECK-LABEL: @test2( 45; CHECK: %x1 = load i32, ptr %arrayidx, align 4 46; CHECK-NEXT: icmp eq i32 %x1, 1179403647 47; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end 48} 49 50; PR6627 - This should all be flattened down to one compare. This is the same 51; as test2, except that the initial load is done as an i8 instead of i32, thus 52; requiring widening. 53define void @test2a(ptr %arrayidx) nounwind ssp { 54entry: 55 %x1 = load i8, ptr %arrayidx, align 4 56 %conv = zext i8 %x1 to i32 57 %cmp = icmp eq i32 %conv, 127 58 br i1 %cmp, label %land.lhs.true, label %if.end 59 60land.lhs.true: ; preds = %entry 61 %arrayidx4 = getelementptr inbounds i8, ptr %arrayidx, i64 1 62 %tmp5 = load i8, ptr %arrayidx4, align 1 63 %conv6 = zext i8 %tmp5 to i32 64 %cmp7 = icmp eq i32 %conv6, 69 65 br i1 %cmp7, label %land.lhs.true9, label %if.end 66 67land.lhs.true9: ; preds = %land.lhs.true 68 %arrayidx12 = getelementptr inbounds i8, ptr %arrayidx, i64 2 69 %tmp13 = load i8, ptr %arrayidx12, align 1 70 %conv14 = zext i8 %tmp13 to i32 71 %cmp15 = icmp eq i32 %conv14, 76 72 br i1 %cmp15, label %land.lhs.true17, label %if.end 73 74land.lhs.true17: ; preds = %land.lhs.true9 75 %arrayidx20 = getelementptr inbounds i8, ptr %arrayidx, i64 3 76 %tmp21 = load i8, ptr %arrayidx20, align 1 77 %conv22 = zext i8 %tmp21 to i32 78 %cmp23 = icmp eq i32 %conv22, 70 79 br i1 %cmp23, label %if.then, label %if.end 80 81if.then: ; preds = %land.lhs.true17 82 %call25 = call i32 (...) @doo() 83 br label %if.end 84 85if.end: 86 ret void 87 88; CHECK-LABEL: @test2a( 89; CHECK: %x1 = load i32, ptr {{.*}}, align 4 90; CHECK-NEXT: icmp eq i32 %x1, 1179403647 91; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end 92} 93