brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 9a3bc06 Raw
57 lines · plain
1; RUN: opt -S < %s -passes=gvn-sink | FileCheck %s2 3declare void @llvm.sideeffect()4 5; GVN sinking across a @llvm.sideeffect.6 7; CHECK-LABEL: scalarsSinking8; CHECK-NOT: fmul9; CHECK: = phi10; CHECK: = fmul11define float @scalarsSinking(float %d, float %m, float %a, i1 %cmp) {12entry:13  br i1 %cmp, label %if.then, label %if.else14 15if.then:16  call void @llvm.sideeffect()17  %sub = fsub float %m, %a18  %mul0 = fmul float %sub, %d19  br label %if.end20 21if.else:22  %add = fadd float %m, %a23  %mul1 = fmul float %add, %d24  br label %if.end25 26if.end:27  %phi = phi float [ %mul0, %if.then ], [ %mul1, %if.else ]28  ret float %phi29}30 31; CHECK-LABEL: scalarsSinkingReverse32; CHECK-NOT: fmul33; CHECK: = phi34; CHECK: = fmul35define float @scalarsSinkingReverse(float %d, float %m, float %a, i1 %cmp) {36; This test is just a reverse(graph mirror) of the test37; above to ensure GVNSink doesn't depend on the order of branches.38entry:39  br i1 %cmp, label %if.then, label %if.else40 41if.then:42  %add = fadd float %m, %a43  %mul1 = fmul float %add, %d44  br label %if.end45 46if.else:47  call void @llvm.sideeffect()48  %sub = fsub float %m, %a49  %mul0 = fmul float %sub, %d50  br label %if.end51 52if.end:53  %phi = phi float [ %mul1, %if.then ], [ %mul0, %if.else ]54  ret float %phi55}56 57