1; RUN: llc %s -o - -verify-machineinstrs | FileCheck %s
2
3target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
4target triple = "thumbv7-unknown-unknown"
5
6%struct.ref_s = type { %union.v, i16, i16 }
7%union.v = type { i32 }
8%struct.gs_color_s = type { i16, i16, i16, i16, i8, i8 }
9
10; In this case, the if converter was cloning the return instruction so that we had
11;   r2<def> = ...
12;   return [pred] r2<dead,def>
13;   ldr <r2, kill>
14;   return
15; The problem here was that the dead def on the first return was making the machine verifier
16; think that the load read from an undefined register.  We need to remove the dead flag from
17; the return, and also add an implicit use of the prior value of r2.
18
19; CHECK: ldrh
20
21; Function Attrs: minsize nounwind optsize ssp
22define i32 @test(%struct.ref_s* %pref1, %struct.ref_s* %pref2, %struct.gs_color_s** %tmp152) #0 {
23bb:
24  %nref = alloca %struct.ref_s, align 4
25  %tmp46 = call %struct.ref_s* @name_string_ref(%struct.ref_s* %pref1, %struct.ref_s* %nref) #2
26  %tmp153 = load %struct.gs_color_s*, %struct.gs_color_s** %tmp152, align 4
27  %tmp154 = bitcast %struct.ref_s* %pref2 to %struct.gs_color_s**
28  %tmp155 = load %struct.gs_color_s*, %struct.gs_color_s** %tmp154, align 4
29  %tmp162 = getelementptr inbounds %struct.gs_color_s, %struct.gs_color_s* %tmp153, i32 0, i32 1
30  %tmp163 = load i16, i16* %tmp162, align 2
31  %tmp164 = getelementptr inbounds %struct.gs_color_s, %struct.gs_color_s* %tmp155, i32 0, i32 1
32  %tmp165 = load i16, i16* %tmp164, align 2
33  %tmp166 = icmp eq i16 %tmp163, %tmp165
34  br i1 %tmp166, label %bb167, label %bb173
35
36bb167:                                            ; preds = %bb
37  %tmp168 = getelementptr inbounds %struct.gs_color_s, %struct.gs_color_s* %tmp153, i32 0, i32 2
38  %tmp169 = load i16, i16* %tmp168, align 2
39  %tmp170 = getelementptr inbounds %struct.gs_color_s, %struct.gs_color_s* %tmp155, i32 0, i32 2
40  %tmp171 = load i16, i16* %tmp170, align 2
41  %tmp172 = icmp eq i16 %tmp169, %tmp171
42  br label %bb173
43
44bb173:                                            ; preds = %bb167, %bb
45  %tmp174 = phi i1 [ false, %bb ], [ %tmp172, %bb167 ]
46  %tmp175 = zext i1 %tmp174 to i32
47  ret i32 %tmp175
48}
49
50; Function Attrs: minsize optsize
51declare %struct.ref_s* @name_string_ref(%struct.ref_s*, %struct.ref_s*) #1
52
53attributes #0 = { minsize nounwind optsize }
54attributes #1 = { minsize optsize }
55attributes #2 = { minsize nounwind optsize }
56