1; RUN: llc < %s -asm-verbose=false | FileCheck %s 2 3; Test that the wasm-store-results pass makes users of stored values use the 4; result of store expressions to reduce get_local/set_local traffic. 5 6target datalayout = "e-p:32:32-i64:64-n32:64-S128" 7target triple = "wasm32-unknown-unknown" 8 9; CHECK-LABEL: single_block: 10; CHECK-NOT: .local 11; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} 12; CHECK: i32.store $push[[STORE:[0-9]+]]=, 0($0), $pop{{[0-9]+}}{{$}} 13; CHECK: return $pop[[STORE]]{{$}} 14define i32 @single_block(i32* %p) { 15entry: 16 store i32 0, i32* %p 17 ret i32 0 18} 19 20; Test interesting corner cases for wasm-store-results, in which the operand of 21; a store ends up getting used by a phi, which needs special handling in the 22; dominance test, since phis use their operands on their incoming edges. 23 24%class.Vec3 = type { float, float, float } 25 26@pos = global %class.Vec3 zeroinitializer, align 4 27 28; CHECK-LABEL: foo: 29; CHECK: i32.store $discard=, pos($0), $0{{$}} 30define void @foo() { 31for.body.i: 32 br label %for.body5.i 33 34for.body5.i: 35 %i.0168.i = phi i32 [ 0, %for.body.i ], [ %inc.i, %for.body5.i ] 36 %conv6.i = sitofp i32 %i.0168.i to float 37 store volatile float 0.0, float* getelementptr inbounds (%class.Vec3, %class.Vec3* @pos, i32 0, i32 0) 38 %inc.i = add nuw nsw i32 %i.0168.i, 1 39 %exitcond.i = icmp eq i32 %inc.i, 256 40 br i1 %exitcond.i, label %for.cond.cleanup4.i, label %for.body5.i 41 42for.cond.cleanup4.i: 43 ret void 44} 45 46; CHECK-LABEL: bar: 47; CHECK: i32.store $discard=, pos($0), $0{{$}} 48define void @bar() { 49for.body.i: 50 br label %for.body5.i 51 52for.body5.i: 53 %i.0168.i = phi float [ 0.0, %for.body.i ], [ %inc.i, %for.body5.i ] 54 store volatile float 0.0, float* getelementptr inbounds (%class.Vec3, %class.Vec3* @pos, i32 0, i32 0) 55 %inc.i = fadd float %i.0168.i, 1.0 56 %exitcond.i = fcmp oeq float %inc.i, 256.0 57 br i1 %exitcond.i, label %for.cond.cleanup4.i, label %for.body5.i 58 59for.cond.cleanup4.i: 60 ret void 61} 62