@@ -96,6 +96,56 @@ for.body5: ; preds = %for.body, %for.body
96
96
br i1 %exitcond16.not , label %for.cond.cleanup4 , label %for.body5 , !llvm.loop !2
97
97
}
98
98
99
+ ; test3 is to check if .p2align can be correctly set on loops with multi latches.
100
+ ; The test IR is generated from below simple C file:
101
+ ; $ clang -O0 -S -emit-llvm loop.c
102
+ ; $ cat loop.c
103
+ ; int test3() {
104
+ ; int i = 0;
105
+ ; [[clang::code_align(32)]]
106
+ ; while (i < 10) {
107
+ ; if (i % 2) {
108
+ ; continue;
109
+ ; }
110
+ ; i++;
111
+ ; }
112
+ ; }
113
+ ; CHECK-LABEL: test3_multilatch:
114
+ ; ALIGN: .p2align 4, 0x90
115
+ ; ALIGN-NEXT: .LBB2_1: # %while.cond
116
+ define dso_local i32 @test3_multilatch () #0 {
117
+ entry:
118
+ %retval = alloca i32 , align 4
119
+ %i = alloca i32 , align 4
120
+ store i32 0 , ptr %retval , align 4
121
+ store i32 0 , ptr %i , align 4
122
+ br label %while.cond
123
+
124
+ while.cond: ; preds = %if.end, %if.then, %entry
125
+ %0 = load i32 , ptr %i , align 4
126
+ %cmp = icmp slt i32 %0 , 10
127
+ br i1 %cmp , label %while.body , label %while.end
128
+
129
+ while.body: ; preds = %while.cond
130
+ %1 = load i32 , ptr %i , align 4
131
+ %rem = srem i32 %1 , 2
132
+ %tobool = icmp ne i32 %rem , 0
133
+ br i1 %tobool , label %if.then , label %if.end
134
+
135
+ if.then: ; preds = %while.body
136
+ br label %while.cond , !llvm.loop !0
137
+
138
+ if.end: ; preds = %while.body
139
+ %2 = load i32 , ptr %i , align 4
140
+ %inc = add nsw i32 %2 , 1
141
+ store i32 %inc , ptr %i , align 4
142
+ br label %while.cond , !llvm.loop !0
143
+
144
+ while.end: ; preds = %while.cond
145
+ %3 = load i32 , ptr %retval , align 4
146
+ ret i32 %3
147
+ }
148
+
99
149
declare void @bar ()
100
150
declare void @var ()
101
151
0 commit comments