1; RUN: llc -o - %s | FileCheck %s 2target triple = "arm-unknown-unknown" 3 4; select with and i1/or i1 condition should be implemented as a series of 2 5; cmovs, not by producing two conditions and using and on them. 6 7define i32 @select_and(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5) { 8; CHECK-LABEL: select_and 9; CHECK-NOT: tst 10; CHECK-NOT: movne 11; CHECK: mov{{lo|hs}} 12; CHECK: mov{{lo|hs}} 13 %cmp0 = icmp ult i32 %a0, %a1 14 %cmp1 = icmp ult i32 %a2, %a3 15 %and = and i1 %cmp0, %cmp1 16 %res = select i1 %and, i32 %a4, i32 %a5 17 ret i32 %res 18} 19 20define i32 @select_or(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5) { 21; select with and i1 condition should be implemented as a series of 2 cmovs, not 22; by producing two conditions and using and on them. 23; CHECK-LABEL: select_or 24; CHECK-NOT: orss 25; CHECK-NOT: tst 26; CHECK: mov{{lo|hs}} 27; CHECK: mov{{lo|hs}} 28 %cmp0 = icmp ult i32 %a0, %a1 29 %cmp1 = icmp ult i32 %a2, %a3 30 %and = or i1 %cmp0, %cmp1 31 %res = select i1 %and, i32 %a4, i32 %a5 32 ret i32 %res 33} 34 35; If one of the conditions is materialized as a 0/1 value anyway, then the 36; sequence of 2 cmovs should not be used. 37 38@var32 = global i32 0 39define i32 @select_noopt(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4) { 40; CHECK-LABEL: select_noopt 41; CHECK: orrs 42; CHECK: movne 43 %cmp0 = icmp ult i32 %a0, %a1 44 %cmp1 = icmp ult i32 %a1, %a2 45 %or = or i1 %cmp0, %cmp1 46 %zero_one = zext i1 %or to i32 47 store volatile i32 %zero_one, i32* @var32 48 %res = select i1 %or, i32 %a3, i32 %a4 49 ret i32 %res 50} 51