brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 66473ce Raw
71 lines · plain
1; Test that multiple select statements using the same condition are expanded2; into a single conditional branch when possible.3;4; RUN: llc < %s -mtriple=s390x-linux-gnu -disable-block-placement | FileCheck %s5 6define void @test0(i32 signext %positive, double %base, double %offset, ptr %rmin, ptr %rmax) {7entry:8; CHECK-LABEL: test09; CHECK: cijlh %r2, 0,10; CHECK-NOT: cij11; CHECK-NOT: je12; CHECK-NOT: jlh13 14  %tobool = icmp eq i32 %positive, 015  %add = fadd double %base, %offset16  %min = select i1 %tobool, double %add, double %base17  %max = select i1 %tobool, double %base, double %add18  store double %min, ptr %rmin, align 819  store double %max, ptr %rmax, align 820  ret void21}22 23; Two selects with an intervening instruction that doesn't clobber CC can24; still be merged.25define double @test1(i32 signext %positive, double %A, double %B, double %C) {26entry:27; CHECK-LABEL: test128; CHECK: cijhe {{.*}}LBB1_229; CHECK-NOT: cij30; CHECK: br %r1431 32  %tobool = icmp slt i32 %positive, 033  %s1  = select i1 %tobool, double %A, double %B34  %mul = fmul double %A, %B35  %s2  = select i1 %tobool, double %B, double %C36  %add = fadd double %s1, %s237  %add2 = fadd double %add, %mul38  ret double %add239}40 41; Two selects with an intervening user of the first select can't be merged.42define double @test2(i32 signext %positive, double %A, double %B) {43entry:44; CHECK-LABEL: test245; CHECK: cije {{.*}}LBB2_246; CHECK: cibe {{.*}}%r1447; CHECK: br %r1448 49  %tobool = icmp eq i32 %positive, 050  %s1  = select i1 %tobool, double %A, double %B51  %add = fadd double %A, %s152  %s2  = select i1 %tobool, double %A, double %add53  ret double %s254}55 56; Two selects with different conditions can't be merged57define double @test3(i32 signext %positive, double %A, double %B, double %C) {58entry:59; CHECK-LABEL: test360; CHECK: cijl {{.*}}LBB3_261; CHECK: cijl {{.*}}LBB3_462; CHECK: br %r1463 64  %tobool = icmp slt i32 %positive, 065  %s1  = select i1 %tobool, double %A, double %B66  %tobool2 = icmp slt i32 %positive, 267  %s2  = select i1 %tobool2, double %B, double %C68  %add = fadd double %s1, %s269  ret double %add70}71