1 ; Test that multiple select statements using the same condition are expanded
2 ; into a single conditional branch when possible.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -disable-block-placement | FileCheck %s
6 define void @test0(i32 signext %positive, double %base, double %offset, ptr %rmin, ptr %rmax) {
14 %tobool = icmp eq i32 %positive, 0
15 %add = fadd double %base, %offset
16 %min = select i1 %tobool, double %add, double %base
17 %max = select i1 %tobool, double %base, double %add
18 store double %min, ptr %rmin, align 8
19 store double %max, ptr %rmax, align 8
23 ; Two selects with an intervening instruction that doesn't clobber CC can
25 define double @test1(i32 signext %positive, double %A, double %B, double %C) {
28 ; CHECK: cijhe {{.*}}LBB1_2
32 %tobool = icmp slt i32 %positive, 0
33 %s1 = select i1 %tobool, double %A, double %B
34 %mul = fmul double %A, %B
35 %s2 = select i1 %tobool, double %B, double %C
36 %add = fadd double %s1, %s2
37 %add2 = fadd double %add, %mul
41 ; Two selects with an intervening user of the first select can't be merged.
42 define double @test2(i32 signext %positive, double %A, double %B) {
45 ; CHECK: cije {{.*}}LBB2_2
46 ; CHECK: cibe {{.*}}%r14
49 %tobool = icmp eq i32 %positive, 0
50 %s1 = select i1 %tobool, double %A, double %B
51 %add = fadd double %A, %s1
52 %s2 = select i1 %tobool, double %A, double %add
56 ; Two selects with different conditions can't be merged
57 define double @test3(i32 signext %positive, double %A, double %B, double %C) {
60 ; CHECK: cijl {{.*}}LBB3_2
61 ; CHECK: cijl {{.*}}LBB3_4
64 %tobool = icmp slt i32 %positive, 0
65 %s1 = select i1 %tobool, double %A, double %B
66 %tobool2 = icmp slt i32 %positive, 2
67 %s2 = select i1 %tobool2, double %B, double %C
68 %add = fadd double %s1, %s2