1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s 2 3 define i32 @test_select_i32(i1 %bit, i32 %a, i32 %b) { 4 ; CHECK-LABEL: test_select_i32: 5 %val = select i1 %bit, i32 %a, i32 %b 6 ; CHECK: movz [[ONE:w[0-9]+]], #1 7 ; CHECK: tst w0, [[ONE]] 8 ; CHECK-NEXT: csel w0, w1, w2, ne 9 10 ret i32 %val 11 } 12 13 define i64 @test_select_i64(i1 %bit, i64 %a, i64 %b) { 14 ; CHECK-LABEL: test_select_i64: 15 %val = select i1 %bit, i64 %a, i64 %b 16 ; CHECK: movz [[ONE:w[0-9]+]], #1 17 ; CHECK: tst w0, [[ONE]] 18 ; CHECK-NEXT: csel x0, x1, x2, ne 19 20 ret i64 %val 21 } 22 23 define float @test_select_float(i1 %bit, float %a, float %b) { 24 ; CHECK-LABEL: test_select_float: 25 %val = select i1 %bit, float %a, float %b 26 ; CHECK: movz [[ONE:w[0-9]+]], #1 27 ; CHECK: tst w0, [[ONE]] 28 ; CHECK-NEXT: fcsel s0, s0, s1, ne 29 30 ret float %val 31 } 32 33 define double @test_select_double(i1 %bit, double %a, double %b) { 34 ; CHECK-LABEL: test_select_double: 35 %val = select i1 %bit, double %a, double %b 36 ; CHECK: movz [[ONE:w[0-9]+]], #1 37 ; CHECK: tst w0, [[ONE]] 38 ; CHECK-NEXT: fcsel d0, d0, d1, ne 39 40 ret double %val 41 } 42 43 define i32 @test_brcond(i1 %bit) { 44 ; CHECK-LABEL: test_brcond: 45 br i1 %bit, label %true, label %false 46 ; CHECK: tbz {{w[0-9]+}}, #0, .LBB 47 48 true: 49 ret i32 0 50 false: 51 ret i32 42 52 } 53 54 define i1 @test_setcc_float(float %lhs, float %rhs) { 55 ; CHECK: test_setcc_float 56 %val = fcmp oeq float %lhs, %rhs 57 ; CHECK: fcmp s0, s1 58 ; CHECK: csinc w0, wzr, wzr, ne 59 ret i1 %val 60 } 61 62 define i1 @test_setcc_double(double %lhs, double %rhs) { 63 ; CHECK: test_setcc_double 64 %val = fcmp oeq double %lhs, %rhs 65 ; CHECK: fcmp d0, d1 66 ; CHECK: csinc w0, wzr, wzr, ne 67 ret i1 %val 68 } 69 70 define i1 @test_setcc_i32(i32 %lhs, i32 %rhs) { 71 ; CHECK: test_setcc_i32 72 %val = icmp ugt i32 %lhs, %rhs 73 ; CHECK: cmp w0, w1 74 ; CHECK: csinc w0, wzr, wzr, ls 75 ret i1 %val 76 } 77 78 define i1 @test_setcc_i64(i64 %lhs, i64 %rhs) { 79 ; CHECK: test_setcc_i64 80 %val = icmp ne i64 %lhs, %rhs 81 ; CHECK: cmp x0, x1 82 ; CHECK: csinc w0, wzr, wzr, eq 83 ret i1 %val 84 } 85