| 1 |
; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -pass-remarks='loop-interchange' -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -disable-output -S |
| 2 |
; RUN: FileCheck --input-file=%t %s |
| 3 |
|
| 4 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" |
| 5 |
|
| 6 |
; The IR test case below is a full and representative motivating example |
| 7 |
; for loop-interchange containing a more complex loop nest structure that |
| 8 |
; corresponds to this pseudo-code: |
| 9 |
; |
| 10 |
; for L=1 to NX |
| 11 |
; for M=1 to NY |
| 12 |
; for i=1 to NX |
| 13 |
; for j=1 to NY |
| 14 |
; for IL=1 to NX |
| 15 |
; load GlobC(i,IL,L) |
| 16 |
; load GlobG(i,IL,L) |
| 17 |
; load GlobE(i,IL,L) |
| 18 |
; load GlobI(i,IL,L) |
| 19 |
; for JL=1 to NY |
| 20 |
; load GlobD(j,JL,M) |
| 21 |
; load GlobH(j,JL,M) |
| 22 |
; load GlobF(j,JL,M) |
| 23 |
; load GlobJ(j,JL,M) |
| 24 |
; store GlobL(NY*i+j,NY*IL+JL) |
| 25 |
; End |
| 26 |
; End |
| 27 |
; End |
| 28 |
; End |
| 29 |
; // Stmt 2 |
| 30 |
; // Stmt 3 |
| 31 |
; // Stmt 4 |
| 32 |
; End |
| 33 |
; End |
| 34 |
; |
| 35 |
; It is important to note here that this comes from Fortran code, which uses a |
| 36 |
; column-major data layout, so loops 'j' and 'JL' should be interchanged. I.e. |
| 37 |
; in the IR below, basic block JL.body is part of the loop that we would like |
| 38 |
; like to see interchanged as there are 4 loads and 1 store that are |
| 39 |
; unit-strided over 'j', so making 'j' loop the innermost is preferable here. |
| 40 |
; |
| 41 |
; TODO: |
| 42 |
; |
| 43 |
; There are a few issues that prevent loop-interchange to perform its |
| 44 |
; transformation on this test case: |
| 45 |
; |
| 46 |
; 1. LoopNest checks: the first check that is perform is whether loop 'L.header' |
| 47 |
; and 'M.header' are perfectly nested, which they are not. It needs to be |
| 48 |
; investigate why the whole loop nest rooted under L is rejected as a |
| 49 |
; candidate. |
| 50 |
; |
| 51 |
; 2. DependenceAnalysis: it finds this dependency: |
| 52 |
; |
| 53 |
; Found output dependency between Src and Dst |
| 54 |
; Src: store double %46, ptr %48, align 8 |
| 55 |
; Dst: store double %46, ptr %48, align 8 |
| 56 |
; |
| 57 |
; |
| 58 |
; CHECK: --- !Missed |
| 59 |
; CHECK-NEXT: Pass: loop-interchange |
| 60 |
; CHECK-NEXT: Name: UnsupportedLoopNestDepth |
| 61 |
; CHECK-NEXT: Function: test |
| 62 |
; CHECK-NEXT: Args: |
| 63 |
; CHECK-NEXT: - String: 'Unsupported depth of loop nest, the supported range is [' |
| 64 |
; CHECK-NEXT: - String: '2' |
| 65 |
; CHECK-NEXT: - String: ', ' |
| 66 |
; CHECK-NEXT: - String: '10' |
| 67 |
; CHECK-NEXT: - String: "].\n" |
| 68 |
; CHECK-NEXT: ... |
| 69 |
; CHECK-NEXT: --- !Analysis |
| 70 |
; CHECK-NEXT: Pass: loop-interchange |
| 71 |
; CHECK-NEXT: Name: Dependence |
| 72 |
; CHECK-NEXT: Function: test |
| 73 |
; CHECK-NEXT: Args: |
| 74 |
; CHECK-NEXT: - String: Computed dependence info, invoking the transform. |
| 75 |
; CHECK-NEXT: ... |
| 76 |
; CHECK-NEXT: --- !Missed |
| 77 |
; CHECK-NEXT: Pass: loop-interchange |
| 78 |
; CHECK-NEXT: Name: Dependence |
| 79 |
; CHECK-NEXT: Function: test |
| 80 |
; CHECK-NEXT: Args: |
| 81 |
; CHECK-NEXT: - String: Cannot interchange loops due to dependences. |
| 82 |
; CHECK-NEXT: ... |
| 83 |
; CHECK-NEXT: --- !Missed |
| 84 |
; CHECK-NEXT: Pass: loop-interchange |
| 85 |
; CHECK-NEXT: Name: UnsupportedLoopNestDepth |
| 86 |
; CHECK-NEXT: Function: test |
| 87 |
; CHECK-NEXT: Args: |
| 88 |
; CHECK-NEXT: - String: 'Unsupported depth of loop nest, the supported range is [' |
| 89 |
; CHECK-NEXT: - String: '2' |
| 90 |
; CHECK-NEXT: - String: ', ' |
| 91 |
; CHECK-NEXT: - String: '10' |
| 92 |
; CHECK-NEXT: - String: "].\n" |
| 93 |
; CHECK-NEXT: ... |
| 94 |
; CHECK-NEXT: --- !Analysis |
| 95 |
; CHECK-NEXT: Pass: loop-interchange |
| 96 |
; CHECK-NEXT: Name: Dependence |
| 97 |
; CHECK-NEXT: Function: test |
| 98 |
; CHECK-NEXT: Args: |
| 99 |
; CHECK-NEXT: - String: Computed dependence info, invoking the transform. |
| 100 |
; CHECK-NEXT: ... |
| 101 |
; CHECK-NEXT: --- !Missed |
| 102 |
; CHECK-NEXT: Pass: loop-interchange |
| 103 |
; CHECK-NEXT: Name: NotTightlyNested |
| 104 |
; CHECK-NEXT: Function: test |
| 105 |
; CHECK-NEXT: Args: |
| 106 |
; CHECK-NEXT: - String: Cannot interchange loops because they are not tightly nested. |
| 107 |
; CHECK-NEXT: ... |
| 108 |
; CHECK-NEXT: --- !Missed |
| 109 |
; CHECK-NEXT: Pass: loop-interchange |
| 110 |
; CHECK-NEXT: Name: Dependence |
| 111 |
; CHECK-NEXT: Function: test |
| 112 |
; CHECK-NEXT: Args: |
| 113 |
; CHECK-NEXT: - String: Cannot interchange loops due to dependences. |
| 114 |
; CHECK-NEXT: ... |
| 115 |
; CHECK-NEXT: --- !Analysis |
| 116 |
; CHECK-NEXT: Pass: loop-interchange |
| 117 |
; CHECK-NEXT: Name: Dependence |
| 118 |
; CHECK-NEXT: Function: test |
| 119 |
; CHECK-NEXT: Args: |
| 120 |
; CHECK-NEXT: - String: Computed dependence info, invoking the transform. |
| 121 |
; CHECK-NEXT: ... |
| 122 |
; CHECK-NEXT: --- !Missed |
| 123 |
; CHECK-NEXT: Pass: loop-interchange |
| 124 |
; CHECK-NEXT: Name: Dependence |
| 125 |
; CHECK-NEXT: Function: test |
| 126 |
; CHECK-NEXT: Args: |
| 127 |
; CHECK-NEXT: - String: All loops have dependencies in all directions. |
| 128 |
; CHECK-NEXT: ... |
| 129 |
|
| 130 |
@GlobC = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 131 |
@GlobD = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 132 |
@GlobE = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 133 |
@GlobF = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 134 |
@GlobG = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 135 |
@GlobH = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 136 |
@GlobI = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 137 |
@GlobJ = local_unnamed_addr global [54 x [54 x [54 x double]]] zeroinitializer |
| 138 |
@GlobK = local_unnamed_addr global [1000 x [1000 x double]] zeroinitializer |
| 139 |
@GlobL = local_unnamed_addr global [1000 x [1000 x double]] zeroinitializer |
| 140 |
@GlobM = local_unnamed_addr global [2500 x double] zeroinitializer |
| 141 |
|
| 142 |
define void @test(ptr noalias readonly captures(none) %0, ptr noalias readonly captures(none) %1, ptr noalias captures(none) %2, ptr noalias captures(none) %3, ptr noalias readonly captures(none) %4, ptr noalias readonly captures(none) %5, ptr noalias readonly captures(none) %6, ptr noalias readonly captures(none) %7, ptr noalias readonly captures(none) %8, ptr noalias readonly captures(none) %9) { |
| 143 |
%11 = alloca [2500 x double], align 8 |
| 144 |
%12 = load i32, ptr %4, align 4 |
| 145 |
%13 = tail call i32 @llvm.smax.i32(i32 %12, i32 0) |
| 146 |
%14 = zext nneg i32 %13 to i64 |
| 147 |
%15 = load i32, ptr %9, align 4 |
| 148 |
%.not = icmp eq i32 %15, 1 |
| 149 |
br i1 %.not, label %171, label %16 |
| 150 |
|
| 151 |
16: |
| 152 |
%17 = load i32, ptr %7, align 4 |
| 153 |
%18 = sext i32 %17 to i64 |
| 154 |
%19 = icmp sgt i32 %17, 0 |
| 155 |
br i1 %19, label %.lr.ph286, label %._crit_edge287 |
| 156 |
|
| 157 |
.lr.ph286: |
| 158 |
%20 = load i32, ptr %8, align 4 |
| 159 |
%21 = sext i32 %20 to i64 |
| 160 |
%22 = icmp sgt i32 %20, 0 |
| 161 |
br i1 %22, label %preheader.L, label %._crit_edge287 |
| 162 |
|
| 163 |
preheader.L: |
| 164 |
%23 = load i32, ptr %5, align 4 |
| 165 |
%24 = tail call i32 @llvm.smax.i32(i32 %23, i32 0) |
| 166 |
%25 = zext nneg i32 %24 to i64 |
| 167 |
%26 = load i32, ptr %6, align 4 |
| 168 |
%27 = sext i32 %26 to i64 |
| 169 |
%28 = getelementptr double, ptr %1, i64 %27 |
| 170 |
%.not241270.us = icmp slt i32 %23, 1 |
| 171 |
%29 = shl nuw nsw i64 %25, 3 |
| 172 |
%30 = add nuw nsw i64 %25, 2 |
| 173 |
%31 = icmp sgt i32 %23, 0 |
| 174 |
%.neg = sext i1 %31 to i64 |
| 175 |
%32 = add nsw i64 %30, %.neg |
| 176 |
br label %L.header |
| 177 |
|
| 178 |
L.header: |
| 179 |
%L = phi i64 [ %L.next, %L.latch ], [ 1, %preheader.L ] |
| 180 |
%33 = mul nuw nsw i64 %L, 2916 |
| 181 |
%34 = add nsw i64 %33, -2971 |
| 182 |
%35 = add nsw i64 %L, -1 |
| 183 |
%36 = mul nsw i64 %35, %21 |
| 184 |
br label %M.header |
| 185 |
|
| 186 |
exit.i: |
| 187 |
br i1 %.not241270.us, label %._crit_edge275.us.thread, label %.preheader258.us.preheader |
| 188 |
|
| 189 |
.lr.ph274.us: |
| 190 |
%37 = phi i64 [ %48, %.lr.ph274.us ], [ %25, %.preheader260.us ] |
| 191 |
%38 = phi double [ %46, %.lr.ph274.us ], [ 0.000000e+00, %.preheader260.us ] |
| 192 |
%39 = phi i64 [ %47, %.lr.ph274.us ], [ 1, %.preheader260.us ] |
| 193 |
%40 = add nsw i64 %39, -1 |
| 194 |
%41 = getelementptr double, ptr %28, i64 %40 |
| 195 |
%42 = load double, ptr %41, align 8 |
| 196 |
%43 = getelementptr double, ptr @GlobM, i64 %40 |
| 197 |
%44 = load double, ptr %43, align 8 |
| 198 |
%45 = fmul fast double %44, %42 |
| 199 |
%46 = fadd fast double %45, %38 |
| 200 |
%47 = add nuw nsw i64 %39, 1 |
| 201 |
%48 = add nsw i64 %37, -1 |
| 202 |
%.not242.us = icmp eq i64 %48, 0 |
| 203 |
br i1 %.not242.us, label %.lr.ph278.us.preheader, label %.lr.ph274.us |
| 204 |
|
| 205 |
.lr.ph278.us.preheader: |
| 206 |
%.lcssa = phi double [ %46, %.lr.ph274.us ] |
| 207 |
%49 = add nsw i64 %M, %36 |
| 208 |
%50 = getelementptr double, ptr %11, i64 %49 |
| 209 |
%51 = getelementptr i8, ptr %50, i64 -8 |
| 210 |
store double %.lcssa, ptr %51, align 8 |
| 211 |
%52 = getelementptr double, ptr @GlobK, i64 %49 |
| 212 |
%53 = getelementptr i8, ptr %52, i64 -8 |
| 213 |
br label %.lr.ph278.us |
| 214 |
|
| 215 |
latch.M.loopexit: |
| 216 |
br label %latch.M |
| 217 |
|
| 218 |
latch.M: |
| 219 |
%M.next = add nuw nsw i64 %M, 1 |
| 220 |
%exitcond335.not = icmp eq i64 %M, %21 |
| 221 |
br i1 %exitcond335.not, label %L.latch, label %M.header |
| 222 |
|
| 223 |
.lr.ph278.us: |
| 224 |
%54 = phi i64 [ %133, %._crit_edge279.us ], [ 1, %.lr.ph278.us.preheader ] |
| 225 |
%55 = add nsw i64 %54, -1 |
| 226 |
%.idx244.us = mul nuw nsw i64 %55, 8000 |
| 227 |
%56 = getelementptr i8, ptr @GlobL, i64 %.idx244.us |
| 228 |
br label %57 |
| 229 |
|
| 230 |
57: |
| 231 |
%58 = phi i64 [ %25, %.lr.ph278.us ], [ %69, %57 ] |
| 232 |
%59 = phi double [ 0.000000e+00, %.lr.ph278.us ], [ %67, %57 ] |
| 233 |
%60 = phi i64 [ 1, %.lr.ph278.us ], [ %68, %57 ] |
| 234 |
%61 = add nsw i64 %60, -1 |
| 235 |
%62 = getelementptr double, ptr %56, i64 %61 |
| 236 |
%63 = load double, ptr %62, align 8 |
| 237 |
%64 = getelementptr double, ptr %28, i64 %61 |
| 238 |
%65 = load double, ptr %64, align 8 |
| 239 |
%66 = fmul fast double %65, %63 |
| 240 |
%67 = fadd fast double %66, %59 |
| 241 |
%68 = add nuw nsw i64 %60, 1 |
| 242 |
%69 = add nsw i64 %58, -1 |
| 243 |
%.not243.us = icmp eq i64 %69, 0 |
| 244 |
br i1 %.not243.us, label %._crit_edge279.us, label %57 |
| 245 |
|
| 246 |
70: |
| 247 |
%71 = phi i64 [ %25, %.preheader258.us ], [ %81, %70 ] |
| 248 |
%72 = phi i64 [ 1, %.preheader258.us ], [ %80, %70 ] |
| 249 |
%73 = add nsw i64 %72, -1 |
| 250 |
%74 = getelementptr double, ptr @GlobM, i64 %73 |
| 251 |
%75 = load double, ptr %74, align 8 |
| 252 |
%76 = getelementptr double, ptr %84, i64 %73 |
| 253 |
%77 = load double, ptr %76, align 8 |
| 254 |
%78 = fmul fast double %86, %77 |
| 255 |
%79 = fadd fast double %78, %75 |
| 256 |
store double %79, ptr %74, align 8 |
| 257 |
%80 = add nuw nsw i64 %72, 1 |
| 258 |
%81 = add nsw i64 %71, -1 |
| 259 |
%.not245.us = icmp eq i64 %81, 0 |
| 260 |
br i1 %.not245.us, label %._crit_edge.us, label %70 |
| 261 |
|
| 262 |
.preheader258.us: |
| 263 |
%82 = phi i64 [ %128, %._crit_edge.us ], [ 1, %.preheader258.us.preheader ] |
| 264 |
%83 = add nsw i64 %82, -1 |
| 265 |
%.idx246.us = mul nuw nsw i64 %83, 8000 |
| 266 |
%84 = getelementptr i8, ptr @GlobL, i64 %.idx246.us |
| 267 |
%85 = getelementptr double, ptr %28, i64 %83 |
| 268 |
%86 = load double, ptr %85, align 8 |
| 269 |
br label %70 |
| 270 |
|
| 271 |
.preheader260.us: |
| 272 |
br label %.lr.ph274.us |
| 273 |
|
| 274 |
._crit_edge275.us.thread: |
| 275 |
%87 = getelementptr double, ptr %11, i64 %M |
| 276 |
%88 = getelementptr double, ptr %87, i64 %36 |
| 277 |
%89 = getelementptr i8, ptr %88, i64 -8 |
| 278 |
store double 0.000000e+00, ptr %89, align 8 |
| 279 |
br label %latch.M |
| 280 |
|
| 281 |
.preheader258.us.preheader: |
| 282 |
call void @llvm.memset.p0.i64(ptr nonnull align 16 @GlobM, i8 0, i64 %29, i1 false) |
| 283 |
br label %.preheader258.us |
| 284 |
|
| 285 |
M.header: |
| 286 |
%M = phi i64 [ 1, %L.header ], [ %M.next, %latch.M ] |
| 287 |
%90 = mul nuw nsw i64 %M, 2916 |
| 288 |
%91 = add nsw i64 %90, -2971 |
| 289 |
br label %i.header |
| 290 |
|
| 291 |
i.header: |
| 292 |
%i = phi i64 [ %i.next, %i.latch ], [ 1, %M.header ] |
| 293 |
%92 = add nsw i64 %34, %i |
| 294 |
%93 = add nsw i64 %i, -1 |
| 295 |
%94 = mul nsw i64 %93, %21 |
| 296 |
%invariant.gep = getelementptr double, ptr @GlobL, i64 %94 |
| 297 |
br label %j.header |
| 298 |
|
| 299 |
j.header: |
| 300 |
%j = phi i64 [ %j.next, %j.latch ], [ 1, %i.header ] |
| 301 |
%95 = add nsw i64 %91, %j |
| 302 |
%gep358 = getelementptr double, ptr %invariant.gep, i64 %j |
| 303 |
br label %IL.header |
| 304 |
|
| 305 |
IL.header: |
| 306 |
%IL = phi i64 [ %IL.next, %IL.latch ], [ 1, %j.header ] |
| 307 |
%96 = mul nuw nsw i64 %IL, 54 |
| 308 |
%97 = add nsw i64 %92, %96 |
| 309 |
%98 = getelementptr double, ptr @GlobC, i64 %97 |
| 310 |
%99 = load double, ptr %98, align 8 |
| 311 |
%100 = getelementptr double, ptr @GlobG, i64 %97 |
| 312 |
%101 = load double, ptr %100, align 8 |
| 313 |
%102 = getelementptr double, ptr @GlobE, i64 %97 |
| 314 |
%103 = load double, ptr %102, align 8 |
| 315 |
%104 = getelementptr double, ptr @GlobI, i64 %97 |
| 316 |
%105 = load double, ptr %104, align 8 |
| 317 |
%106 = add nsw i64 %IL, -1 |
| 318 |
%107 = mul nsw i64 %106, %21 |
| 319 |
br label %JL.body |
| 320 |
|
| 321 |
JL.body: |
| 322 |
%JL = phi i64 [ %JL.next, %JL.body ], [ 1, %IL.header ] |
| 323 |
%109 = mul nuw nsw i64 %JL, 54 |
| 324 |
%110 = add nsw i64 %95, %109 |
| 325 |
%111 = getelementptr double, ptr @GlobD, i64 %110 |
| 326 |
%112 = load double, ptr %111, align 8 |
| 327 |
%113 = fmul fast double %112, %99 |
| 328 |
%114 = getelementptr double, ptr @GlobH, i64 %110 |
| 329 |
%115 = load double, ptr %114, align 8 |
| 330 |
%116 = fmul fast double %115, %101 |
| 331 |
%117 = fadd fast double %116, %113 |
| 332 |
%118 = getelementptr double, ptr @GlobF, i64 %110 |
| 333 |
%119 = load double, ptr %118, align 8 |
| 334 |
%120 = fmul fast double %119, %103 |
| 335 |
%121 = fadd fast double %117, %120 |
| 336 |
%122 = getelementptr double, ptr @GlobJ, i64 %110 |
| 337 |
%123 = load double, ptr %122, align 8 |
| 338 |
%124 = fmul fast double %123, %105 |
| 339 |
%125 = fadd fast double %121, %124 |
| 340 |
%126 = add nsw i64 %JL, %107 |
| 341 |
%.idx247.us.us.us.us.us.us = mul nsw i64 %126, 8000 |
| 342 |
%gep.us.us.us.us.us.us = getelementptr i8, ptr %gep358, i64 %.idx247.us.us.us.us.us.us |
| 343 |
%127 = getelementptr i8, ptr %gep.us.us.us.us.us.us, i64 -8008 |
| 344 |
store double %125, ptr %127, align 8 |
| 345 |
%JL.next = add nuw nsw i64 %JL, 1 |
| 346 |
%exitcond.not = icmp eq i64 %JL, %21 |
| 347 |
br i1 %exitcond.not, label %IL.latch, label %JL.body |
| 348 |
|
| 349 |
IL.latch: |
| 350 |
%IL.next = add nuw nsw i64 %IL, 1 |
| 351 |
%exitcond320.not = icmp eq i64 %IL, %18 |
| 352 |
br i1 %exitcond320.not, label %j.latch, label %IL.header |
| 353 |
|
| 354 |
j.latch: |
| 355 |
%j.next = add nuw nsw i64 %j, 1 |
| 356 |
%exitcond324.not = icmp eq i64 %j, %21 |
| 357 |
br i1 %exitcond324.not, label %i.latch, label %j.header |
| 358 |
|
| 359 |
i.latch: |
| 360 |
%i.next = add nuw nsw i64 %i, 1 |
| 361 |
%exitcond328.not = icmp eq i64 %i, %18 |
| 362 |
br i1 %exitcond328.not, label %exit.i, label %i.header |
| 363 |
|
| 364 |
._crit_edge.us: |
| 365 |
%128 = add nuw nsw i64 %82, 1 |
| 366 |
%exitcond329.not = icmp eq i64 %128, %32 |
| 367 |
br i1 %exitcond329.not, label %.preheader260.us, label %.preheader258.us |
| 368 |
|
| 369 |
._crit_edge279.us: |
| 370 |
%.lcssa360 = phi double [ %67, %57 ] |
| 371 |
%129 = getelementptr double, ptr @GlobM, i64 %55 |
| 372 |
%130 = load double, ptr %129, align 8 |
| 373 |
%131 = fadd fast double %130, %.lcssa360 |
| 374 |
%132 = getelementptr i8, ptr %53, i64 %.idx244.us |
| 375 |
store double %131, ptr %132, align 8 |
| 376 |
%133 = add nuw nsw i64 %54, 1 |
| 377 |
%exitcond331.not = icmp eq i64 %133, %32 |
| 378 |
br i1 %exitcond331.not, label %latch.M.loopexit, label %.lr.ph278.us |
| 379 |
|
| 380 |
L.latch: |
| 381 |
%L.next = add nuw nsw i64 %L, 1 |
| 382 |
%exitcond339.not = icmp eq i64 %L, %18 |
| 383 |
br i1 %exitcond339.not, label %exit.L, label %L.header |
| 384 |
|
| 385 |
exit.L: |
| 386 |
br label %._crit_edge287 |
| 387 |
|
| 388 |
._crit_edge287: |
| 389 |
%134 = load i32, ptr %6, align 4 |
| 390 |
%135 = load i32, ptr %5, align 4 |
| 391 |
%136 = tail call i32 @llvm.smax.i32(i32 %135, i32 0) |
| 392 |
%137 = zext nneg i32 %136 to i64 |
| 393 |
%138 = sext i32 %134 to i64 |
| 394 |
%139 = getelementptr double, ptr %2, i64 %138 |
| 395 |
%140 = shl nuw nsw i64 %137, 3 |
| 396 |
%.not236 = icmp slt i32 %135, 1 |
| 397 |
%141 = select i1 %.not236, i64 1, i64 %140 |
| 398 |
%142 = tail call ptr @malloc(i64 %141) |
| 399 |
br i1 %.not236, label %._crit_edge294, label %.preheader254.preheader |
| 400 |
|
| 401 |
.preheader254.preheader: |
| 402 |
call void @llvm.memset.p0.i64(ptr align 8 %142, i8 0, i64 %140, i1 false) |
| 403 |
br label %.preheader254 |
| 404 |
|
| 405 |
.preheader254: |
| 406 |
%143 = phi i64 [ %160, %._crit_edge ], [ 1, %.preheader254.preheader ] |
| 407 |
%144 = add nsw i64 %143, -1 |
| 408 |
%.idx240 = mul nuw nsw i64 %144, 8000 |
| 409 |
%145 = getelementptr i8, ptr %0, i64 %.idx240 |
| 410 |
%146 = getelementptr double, ptr %11, i64 %144 |
| 411 |
%147 = load double, ptr %146, align 8 |
| 412 |
br label %148 |
| 413 |
|
| 414 |
.preheader253: |
| 415 |
br label %.lr.ph293 |
| 416 |
|
| 417 |
148: |
| 418 |
%149 = phi i64 [ %137, %.preheader254 ], [ %159, %148 ] |
| 419 |
%150 = phi i64 [ 1, %.preheader254 ], [ %158, %148 ] |
| 420 |
%151 = add nsw i64 %150, -1 |
| 421 |
%152 = getelementptr double, ptr %142, i64 %151 |
| 422 |
%153 = load double, ptr %152, align 8 |
| 423 |
%154 = getelementptr double, ptr %145, i64 %151 |
| 424 |
%155 = load double, ptr %154, align 8 |
| 425 |
%156 = fmul fast double %147, %155 |
| 426 |
%157 = fadd fast double %156, %153 |
| 427 |
store double %157, ptr %152, align 8 |
| 428 |
%158 = add nuw nsw i64 %150, 1 |
| 429 |
%159 = add nsw i64 %149, -1 |
| 430 |
%.not239 = icmp eq i64 %159, 0 |
| 431 |
br i1 %.not239, label %._crit_edge, label %148 |
| 432 |
|
| 433 |
._crit_edge: |
| 434 |
%160 = add nuw nsw i64 %143, 1 |
| 435 |
%exitcond341.not = icmp eq i64 %143, %137 |
| 436 |
br i1 %exitcond341.not, label %.preheader253, label %.preheader254 |
| 437 |
|
| 438 |
.lr.ph293: |
| 439 |
%161 = phi i64 [ %170, %.lr.ph293 ], [ %137, %.preheader253 ] |
| 440 |
%162 = phi i64 [ %169, %.lr.ph293 ], [ 1, %.preheader253 ] |
| 441 |
%163 = add nsw i64 %162, -1 |
| 442 |
%164 = getelementptr double, ptr %139, i64 %163 |
| 443 |
%165 = getelementptr double, ptr %142, i64 %163 |
| 444 |
%166 = load double, ptr %165, align 8 |
| 445 |
%167 = load double, ptr %164, align 8 |
| 446 |
%168 = fsub fast double %167, %166 |
| 447 |
store double %168, ptr %164, align 8 |
| 448 |
%169 = add nuw nsw i64 %162, 1 |
| 449 |
%170 = add nsw i64 %161, -1 |
| 450 |
%.not238 = icmp eq i64 %170, 0 |
| 451 |
br i1 %.not238, label %._crit_edge294.loopexit359, label %.lr.ph293 |
| 452 |
|
| 453 |
171: |
| 454 |
%172 = load i32, ptr %6, align 4 |
| 455 |
%173 = load i32, ptr %5, align 4 |
| 456 |
%174 = tail call i32 @llvm.smax.i32(i32 %173, i32 0) |
| 457 |
%175 = zext nneg i32 %174 to i64 |
| 458 |
%176 = shl nuw nsw i64 %175, 3 |
| 459 |
%177 = mul i64 %176, %175 |
| 460 |
%178 = tail call i64 @llvm.smax.i64(i64 %177, i64 1) |
| 461 |
%179 = tail call ptr @malloc(i64 %178) |
| 462 |
%.not311 = icmp slt i32 %173, 1 |
| 463 |
br i1 %.not311, label %._crit_edge294, label %.preheader250.us.preheader |
| 464 |
|
| 465 |
.preheader250.us.preheader: |
| 466 |
%180 = mul nuw nsw i64 %175, %175 |
| 467 |
%181 = shl i64 %180, 3 |
| 468 |
call void @llvm.memset.p0.i64(ptr align 8 %179, i8 0, i64 %181, i1 false) |
| 469 |
br label %.preheader250.us |
| 470 |
|
| 471 |
.preheader250.us: |
| 472 |
%182 = phi i64 [ %203, %._crit_edge301.split.us ], [ 1, %.preheader250.us.preheader ] |
| 473 |
%183 = add nsw i64 %182, -1 |
| 474 |
%.idx.us = mul nuw nsw i64 %183, 8000 |
| 475 |
%184 = getelementptr i8, ptr %0, i64 %.idx.us |
| 476 |
%invariant.gep.us = getelementptr double, ptr @GlobK, i64 %183 |
| 477 |
br label %.preheader249.us |
| 478 |
|
| 479 |
185: |
| 480 |
%186 = phi i64 [ %175, %.preheader249.us ], [ %196, %185 ] |
| 481 |
%187 = phi i64 [ 1, %.preheader249.us ], [ %195, %185 ] |
| 482 |
%188 = add nsw i64 %187, -1 |
| 483 |
%189 = getelementptr double, ptr %200, i64 %188 |
| 484 |
%190 = load double, ptr %189, align 8 |
| 485 |
%191 = getelementptr double, ptr %184, i64 %188 |
| 486 |
%192 = load double, ptr %191, align 8 |
| 487 |
%193 = fmul fast double %201, %192 |
| 488 |
%194 = fadd fast double %193, %190 |
| 489 |
store double %194, ptr %189, align 8 |
| 490 |
%195 = add nuw nsw i64 %187, 1 |
| 491 |
%196 = add nsw i64 %186, -1 |
| 492 |
%.not233.us = icmp eq i64 %196, 0 |
| 493 |
br i1 %.not233.us, label %._crit_edge300.us, label %185 |
| 494 |
|
| 495 |
.preheader249.us: |
| 496 |
%197 = phi i64 [ 1, %.preheader250.us ], [ %202, %._crit_edge300.us ] |
| 497 |
%198 = add nsw i64 %197, -1 |
| 498 |
%199 = mul nuw nsw i64 %198, %175 |
| 499 |
%200 = getelementptr double, ptr %179, i64 %199 |
| 500 |
%.idx234.us = mul nuw nsw i64 %198, 8000 |
| 501 |
%gep.us = getelementptr i8, ptr %invariant.gep.us, i64 %.idx234.us |
| 502 |
%201 = load double, ptr %gep.us, align 8 |
| 503 |
br label %185 |
| 504 |
|
| 505 |
._crit_edge300.us: |
| 506 |
%202 = add nuw nsw i64 %197, 1 |
| 507 |
%exitcond344.not = icmp eq i64 %197, %175 |
| 508 |
br i1 %exitcond344.not, label %._crit_edge301.split.us, label %.preheader249.us |
| 509 |
|
| 510 |
._crit_edge301.split.us: |
| 511 |
%203 = add nuw nsw i64 %182, 1 |
| 512 |
%exitcond345.not = icmp eq i64 %182, %175 |
| 513 |
br i1 %exitcond345.not, label %.preheader248, label %.preheader250.us |
| 514 |
|
| 515 |
.preheader248: |
| 516 |
br label %.preheader.lr.ph |
| 517 |
|
| 518 |
.preheader.lr.ph: |
| 519 |
%204 = sext i32 %172 to i64 |
| 520 |
%invariant.gep306 = getelementptr double, ptr %3, i64 %204 |
| 521 |
br label %.preheader |
| 522 |
|
| 523 |
.preheader: |
| 524 |
%205 = phi i64 [ 1, %.preheader.lr.ph ], [ %221, %._crit_edge304 ] |
| 525 |
%206 = add nsw i64 %205, -1 |
| 526 |
%207 = add nsw i64 %206, %204 |
| 527 |
%208 = mul nsw i64 %207, %14 |
| 528 |
%gep307 = getelementptr double, ptr %invariant.gep306, i64 %208 |
| 529 |
%209 = mul nuw nsw i64 %206, %175 |
| 530 |
%210 = getelementptr double, ptr %179, i64 %209 |
| 531 |
br label %211 |
| 532 |
|
| 533 |
211: |
| 534 |
%212 = phi i64 [ %175, %.preheader ], [ %220, %211 ] |
| 535 |
%213 = phi i64 [ 1, %.preheader ], [ %219, %211 ] |
| 536 |
%214 = add nsw i64 %213, -1 |
| 537 |
%gep = getelementptr double, ptr %gep307, i64 %214 |
| 538 |
%215 = getelementptr double, ptr %210, i64 %214 |
| 539 |
%216 = load double, ptr %215, align 8 |
| 540 |
%217 = load double, ptr %gep, align 8 |
| 541 |
%218 = fsub fast double %217, %216 |
| 542 |
store double %218, ptr %gep, align 8 |
| 543 |
%219 = add nuw nsw i64 %213, 1 |
| 544 |
%220 = add nsw i64 %212, -1 |
| 545 |
%.not232 = icmp eq i64 %220, 0 |
| 546 |
br i1 %.not232, label %._crit_edge304, label %211 |
| 547 |
|
| 548 |
._crit_edge304: |
| 549 |
%221 = add nuw nsw i64 %205, 1 |
| 550 |
%exitcond347.not = icmp eq i64 %205, %175 |
| 551 |
br i1 %exitcond347.not, label %._crit_edge294.loopexit, label %.preheader |
| 552 |
|
| 553 |
._crit_edge294.loopexit: |
| 554 |
br label %._crit_edge294 |
| 555 |
|
| 556 |
._crit_edge294.loopexit359: |
| 557 |
br label %._crit_edge294 |
| 558 |
|
| 559 |
._crit_edge294: |
| 560 |
%.sink = phi ptr [ %142, %._crit_edge287 ], [ %179, %171 ], [ %179, %._crit_edge294.loopexit ], [ %142, %._crit_edge294.loopexit359 ] |
| 561 |
tail call void @free(ptr %.sink) |
| 562 |
ret void |
| 563 |
} |
| 564 |
|
| 565 |
declare i64 @llvm.smax.i64(i64, i64) |
| 566 |
declare i32 @llvm.smax.i32(i32, i32) |
| 567 |
declare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) |
| 568 |
declare void @free(ptr allocptr noundef captures(none)) local_unnamed_addr |
| 569 |
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr |