1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-idiom < %s -S | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
5 ;; memcpy.atomic formation (atomic load & store) -- element size 2
6 ;; Will not create call due to a max element size of 0
7 define void @test1(i64 %Size) nounwind ssp {
10 ; CHECK-NEXT: [[BASE:%.*]] = alloca i16, i32 10000, align 2
11 ; CHECK-NEXT: [[DEST:%.*]] = alloca i16, i32 10000, align 2
12 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
14 ; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ 0, [[BB_NPH:%.*]] ], [ [[INDVAR_NEXT:%.*]], [[FOR_BODY]] ]
15 ; CHECK-NEXT: [[I_0_014:%.*]] = getelementptr i16, ptr [[BASE]], i64 [[INDVAR]]
16 ; CHECK-NEXT: [[DESTI:%.*]] = getelementptr i16, ptr [[DEST]], i64 [[INDVAR]]
17 ; CHECK-NEXT: [[V:%.*]] = load atomic i16, ptr [[I_0_014]] unordered, align 2
18 ; CHECK-NEXT: store atomic i16 [[V]], ptr [[DESTI]] unordered, align 2
19 ; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
20 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], [[SIZE:%.*]]
21 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
23 ; CHECK-NEXT: ret void
26 %Base = alloca i16, i32 10000
27 %Dest = alloca i16, i32 10000
30 for.body: ; preds = %bb.nph, %for.body
31 %indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
32 %I.0.014 = getelementptr i16, ptr %Base, i64 %indvar
33 %DestI = getelementptr i16, ptr %Dest, i64 %indvar
34 %V = load atomic i16, ptr %I.0.014 unordered, align 2
35 store atomic i16 %V, ptr %DestI unordered, align 2
36 %indvar.next = add i64 %indvar, 1
37 %exitcond = icmp eq i64 %indvar.next, %Size
38 br i1 %exitcond, label %for.end, label %for.body
40 for.end: ; preds = %for.body, %entry