Taints the non-acquire RMW's store address with the load part
[oota-llvm.git] / test / CodeGen / WebAssembly / loop-idiom.ll
1 ; RUN: opt -loop-idiom -S < %s -march=wasm32 | FileCheck %s
2
3 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4 target triple = "wasm32-unknown-unknown"
5
6
7 ; Make sure loop-idiom doesn't create memcpy or memset. These aren't well
8 ; supported in WebAssembly for now.
9 ;
10 ; TODO Check the patterns are recognized once memcpy / memset are supported.
11
12 ; CHECK-LABEL: @cpy(
13 ; CHECK-NOT: llvm.memcpy
14 ; CHECK: load
15 ; CHECK: store
16 define void @cpy(i64 %Size) {
17 bb.nph:
18   %Base = alloca i8, i32 10000
19   %Dest = alloca i8, i32 10000
20   br label %for.body
21
22 for.body:
23   %indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
24   %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
25   %DestI = getelementptr i8, i8* %Dest, i64 %indvar
26   %V = load i8, i8* %I.0.014, align 1
27   store i8 %V, i8* %DestI, align 1
28   %indvar.next = add i64 %indvar, 1
29   %exitcond = icmp eq i64 %indvar.next, %Size
30   br i1 %exitcond, label %for.end, label %for.body
31
32 for.end:
33   ret void
34 }
35
36 ; CHECK-LABEL: @set(
37 ; CHECK-NOT: llvm.memset
38 ; CHECK: store
39 define void @set(i8* %Base, i64 %Size) {
40 bb.nph:
41   br label %for.body
42
43 for.body:
44   %indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ]
45   %I.0.014 = getelementptr i8, i8* %Base, i64 %indvar
46   store i8 0, i8* %I.0.014, align 1
47   %indvar.next = add i64 %indvar, 1
48   %exitcond = icmp eq i64 %indvar.next, %Size
49   br i1 %exitcond, label %for.end, label %for.body
50
51 for.end:
52   ret void
53 }