1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s 2; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -fast-isel -fast-isel-abort=1 | FileCheck %s 3 4; Test that wasm select instruction is selected from LLVM select instruction. 5 6target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 7target triple = "wasm32-unknown-unknown" 8 9; CHECK-LABEL: select_i32_bool: 10; CHECK-NEXT: .param i32, i32, i32{{$}} 11; CHECK-NEXT: .result i32{{$}} 12; CHECK-NEXT: i32.select $push0=, $1, $2, $0{{$}} 13; CHECK-NEXT: return $pop0{{$}} 14define i32 @select_i32_bool(i1 zeroext %a, i32 %b, i32 %c) { 15 %cond = select i1 %a, i32 %b, i32 %c 16 ret i32 %cond 17} 18 19; CHECK-LABEL: select_i32_eq: 20; CHECK-NEXT: .param i32, i32, i32{{$}} 21; CHECK-NEXT: .result i32{{$}} 22; CHECK-NEXT: i32.select $push0=, $2, $1, $0{{$}} 23; CHECK-NEXT: return $pop0{{$}} 24define i32 @select_i32_eq(i32 %a, i32 %b, i32 %c) { 25 %cmp = icmp eq i32 %a, 0 26 %cond = select i1 %cmp, i32 %b, i32 %c 27 ret i32 %cond 28} 29 30; CHECK-LABEL: select_i32_ne: 31; CHECK-NEXT: .param i32, i32, i32{{$}} 32; CHECK-NEXT: .result i32{{$}} 33; CHECK-NEXT: i32.select $push0=, $1, $2, $0{{$}} 34; CHECK-NEXT: return $pop0{{$}} 35define i32 @select_i32_ne(i32 %a, i32 %b, i32 %c) { 36 %cmp = icmp ne i32 %a, 0 37 %cond = select i1 %cmp, i32 %b, i32 %c 38 ret i32 %cond 39} 40 41; CHECK-LABEL: select_i64_bool: 42; CHECK-NEXT: .param i32, i64, i64{{$}} 43; CHECK-NEXT: .result i64{{$}} 44; CHECK-NEXT: i64.select $push0=, $1, $2, $0{{$}} 45; CHECK-NEXT: return $pop0{{$}} 46define i64 @select_i64_bool(i1 zeroext %a, i64 %b, i64 %c) { 47 %cond = select i1 %a, i64 %b, i64 %c 48 ret i64 %cond 49} 50 51; CHECK-LABEL: select_i64_eq: 52; CHECK-NEXT: .param i32, i64, i64{{$}} 53; CHECK-NEXT: .result i64{{$}} 54; CHECK-NEXT: i64.select $push0=, $2, $1, $0{{$}} 55; CHECK-NEXT: return $pop0{{$}} 56define i64 @select_i64_eq(i32 %a, i64 %b, i64 %c) { 57 %cmp = icmp eq i32 %a, 0 58 %cond = select i1 %cmp, i64 %b, i64 %c 59 ret i64 %cond 60} 61 62; CHECK-LABEL: select_i64_ne: 63; CHECK-NEXT: .param i32, i64, i64{{$}} 64; CHECK-NEXT: .result i64{{$}} 65; CHECK-NEXT: i64.select $push0=, $1, $2, $0{{$}} 66; CHECK-NEXT: return $pop0{{$}} 67define i64 @select_i64_ne(i32 %a, i64 %b, i64 %c) { 68 %cmp = icmp ne i32 %a, 0 69 %cond = select i1 %cmp, i64 %b, i64 %c 70 ret i64 %cond 71} 72 73; CHECK-LABEL: select_f32_bool: 74; CHECK-NEXT: .param i32, f32, f32{{$}} 75; CHECK-NEXT: .result f32{{$}} 76; CHECK-NEXT: f32.select $push0=, $1, $2, $0{{$}} 77; CHECK-NEXT: return $pop0{{$}} 78define float @select_f32_bool(i1 zeroext %a, float %b, float %c) { 79 %cond = select i1 %a, float %b, float %c 80 ret float %cond 81} 82 83; CHECK-LABEL: select_f32_eq: 84; CHECK-NEXT: .param i32, f32, f32{{$}} 85; CHECK-NEXT: .result f32{{$}} 86; CHECK-NEXT: f32.select $push0=, $2, $1, $0{{$}} 87; CHECK-NEXT: return $pop0{{$}} 88define float @select_f32_eq(i32 %a, float %b, float %c) { 89 %cmp = icmp eq i32 %a, 0 90 %cond = select i1 %cmp, float %b, float %c 91 ret float %cond 92} 93 94; CHECK-LABEL: select_f32_ne: 95; CHECK-NEXT: .param i32, f32, f32{{$}} 96; CHECK-NEXT: .result f32{{$}} 97; CHECK-NEXT: f32.select $push0=, $1, $2, $0{{$}} 98; CHECK-NEXT: return $pop0{{$}} 99define float @select_f32_ne(i32 %a, float %b, float %c) { 100 %cmp = icmp ne i32 %a, 0 101 %cond = select i1 %cmp, float %b, float %c 102 ret float %cond 103} 104 105; CHECK-LABEL: select_f64_bool: 106; CHECK-NEXT: .param i32, f64, f64{{$}} 107; CHECK-NEXT: .result f64{{$}} 108; CHECK-NEXT: f64.select $push0=, $1, $2, $0{{$}} 109; CHECK-NEXT: return $pop0{{$}} 110define double @select_f64_bool(i1 zeroext %a, double %b, double %c) { 111 %cond = select i1 %a, double %b, double %c 112 ret double %cond 113} 114 115; CHECK-LABEL: select_f64_eq: 116; CHECK-NEXT: .param i32, f64, f64{{$}} 117; CHECK-NEXT: .result f64{{$}} 118; CHECK-NEXT: f64.select $push0=, $2, $1, $0{{$}} 119; CHECK-NEXT: return $pop0{{$}} 120define double @select_f64_eq(i32 %a, double %b, double %c) { 121 %cmp = icmp eq i32 %a, 0 122 %cond = select i1 %cmp, double %b, double %c 123 ret double %cond 124} 125 126; CHECK-LABEL: select_f64_ne: 127; CHECK-NEXT: .param i32, f64, f64{{$}} 128; CHECK-NEXT: .result f64{{$}} 129; CHECK-NEXT: f64.select $push0=, $1, $2, $0{{$}} 130; CHECK-NEXT: return $pop0{{$}} 131define double @select_f64_ne(i32 %a, double %b, double %c) { 132 %cmp = icmp ne i32 %a, 0 133 %cond = select i1 %cmp, double %b, double %c 134 ret double %cond 135} 136