1 ; RUN: opt -S < %s -passes=gvn-sink | FileCheck %s
3 declare void @llvm.sideeffect()
5 ; GVN sinking across a @llvm.sideeffect.
7 ; CHECK-LABEL: scalarsSinking
11 define float @scalarsSinking(float %d, float %m, float %a, i1 %cmp) {
13 br i1 %cmp, label %if.then, label %if.else
16 call void @llvm.sideeffect()
17 %sub = fsub float %m, %a
18 %mul0 = fmul float %sub, %d
22 %add = fadd float %m, %a
23 %mul1 = fmul float %add, %d
27 %phi = phi float [ %mul0, %if.then ], [ %mul1, %if.else ]
31 ; CHECK-LABEL: scalarsSinkingReverse
35 define float @scalarsSinkingReverse(float %d, float %m, float %a, i1 %cmp) {
36 ; This test is just a reverse(graph mirror) of the test
37 ; above to ensure GVNSink doesn't depend on the order of branches.
39 br i1 %cmp, label %if.then, label %if.else
42 %add = fadd float %m, %a
43 %mul1 = fmul float %add, %d
47 call void @llvm.sideeffect()
48 %sub = fsub float %m, %a
49 %mul0 = fmul float %sub, %d
53 %phi = phi float [ %mul1, %if.then ], [ %mul0, %if.else ]