[WebAssembly] Also legalize sign_extend_inreg of i32->i64.
[oota-llvm.git] / test / CodeGen / WebAssembly / legalize.ll
1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3 ; Test various types and operators that need to be legalized.
4
5 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
7
8 ; CHECK-LABEL: shl_i3:
9 ; CHECK: i32.const   $push0=, 7
10 ; CHECK: i32.and     $push1=, $1, $pop0
11 ; CHECK: i32.shl     $push2=, $0, $pop1
12 define i3 @shl_i3(i3 %a, i3 %b, i3* %p) {
13   %t = shl i3 %a, %b
14   ret i3 %t
15 }
16
17 ; CHECK-LABEL: shl_i53:
18 ; CHECK: i64.const   $push0=, 9007199254740991
19 ; CHECK: i64.and     $push1=, $1, $pop0
20 ; CHECK: i64.shl     $push2=, $0, $pop1
21 define i53 @shl_i53(i53 %a, i53 %b, i53* %p) {
22   %t = shl i53 %a, %b
23   ret i53 %t
24 }
25
26 ; CHECK-LABEL: sext_in_reg_i32_i64:
27 ; CHECK: i64.shl
28 ; CHECK: i64.shr_s
29 define i64 @sext_in_reg_i32_i64(i64 %a) {
30   %b = shl i64 %a, 32
31   %c = ashr i64 %b, 32
32   ret i64 %c
33 }