blob: 5feb2e8c8c75e2e540fca7a002801ef4fbd76795 [file] [log] [blame]
Dan Gohmana8483752015-12-10 00:26:26 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test various types and operators that need to be legalized.
4
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00005target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohmana8483752015-12-10 00:26:26 +00006target triple = "wasm32-unknown-unknown"
7
8; CHECK-LABEL: shl_i3:
Dan Gohman28818d72015-12-10 14:52:34 +00009; CHECK: i32.const $push0=, 7{{$}}
10; CHECK: i32.and $push1=, $1, $pop0{{$}}
11; CHECK: i32.shl $push2=, $0, $pop1{{$}}
Dan Gohmana8483752015-12-10 00:26:26 +000012define 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:
Dan Gohman28818d72015-12-10 14:52:34 +000018; CHECK: i64.const $push0=, 9007199254740991{{$}}
19; CHECK: i64.and $push1=, $1, $pop0{{$}}
20; CHECK: i64.shl $push2=, $0, $pop1{{$}}
Dan Gohmana8483752015-12-10 00:26:26 +000021define i53 @shl_i53(i53 %a, i53 %b, i53* %p) {
22 %t = shl i53 %a, %b
23 ret i53 %t
24}
Dan Gohmana5603b82015-12-10 01:00:19 +000025
26; CHECK-LABEL: sext_in_reg_i32_i64:
27; CHECK: i64.shl
28; CHECK: i64.shr_s
29define 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}
Dan Gohman60bddf12015-12-10 02:07:53 +000034
35; CHECK-LABEL: fpext_f32_f64:
36; CHECK: f32.load $push0=, 0($0){{$}}
Dan Gohman28818d72015-12-10 14:52:34 +000037; CHECK: f64.promote/f32 $push1=, $pop0{{$}}
Dan Gohman60bddf12015-12-10 02:07:53 +000038; CHECK: return $pop1{{$}}
39define double @fpext_f32_f64(float *%p) {
40 %v = load float, float* %p
41 %e = fpext float %v to double
42 ret double %e
43}
44
45; CHECK-LABEL: fpconv_f64_f32:
46; CHECK: f64.load $push0=, 0($0){{$}}
Dan Gohman28818d72015-12-10 14:52:34 +000047; CHECK: f32.demote/f64 $push1=, $pop0{{$}}
Dan Gohman60bddf12015-12-10 02:07:53 +000048; CHECK: return $pop1{{$}}
49define float @fpconv_f64_f32(double *%p) {
50 %v = load double, double* %p
51 %e = fptrunc double %v to float
52 ret float %e
53}
Dan Gohman41729532015-12-16 23:25:51 +000054
55; Check that big shifts work. This generates a big pile of code from the
56; legalizer; the main thing here is that we don't abort.
57
58; CHECK-LABEL: bigshift:
59define i1024 @bigshift(i1024 %a, i1024 %b) {
60 %c = shl i1024 %a, %b
61 ret i1024 %c
62}