blob: 457c5874e49369bc40e89f412eb83d9877566f42 [file] [log] [blame]
Dan Gohman7b634842015-08-24 18:44:37 +00001; RUN: llc < %s -asm-verbose=false \
2; RUN: -fast-isel -fast-isel-abort=1 -verify-machineinstrs \
Dan Gohman7d7409e2017-02-28 23:37:04 +00003; RUN: -disable-wasm-explicit-locals \
Dan Gohman7b634842015-08-24 18:44:37 +00004; RUN: | FileCheck %s
5
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00006target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman7d7409e2017-02-28 23:37:04 +00007target triple = "wasm32-unknown-unknown-wasm"
Dan Gohman7b634842015-08-24 18:44:37 +00008
9; This tests very minimal fast-isel functionality.
10
Dan Gohmane51c0582015-10-06 00:27:55 +000011; CHECK-LABEL: immediate_f32:
Dan Gohman700515f2015-11-23 21:55:57 +000012; CHECK: f32.const $push{{[0-9]+}}=, 0x1.4p1{{$}}
Dan Gohman7b634842015-08-24 18:44:37 +000013define float @immediate_f32() {
14 ret float 2.5
15}
16
Dan Gohmane51c0582015-10-06 00:27:55 +000017; CHECK-LABEL: immediate_f64:
Dan Gohman700515f2015-11-23 21:55:57 +000018; CHECK: f64.const $push{{[0-9]+}}=, 0x1.4p1{{$}}
Dan Gohman7b634842015-08-24 18:44:37 +000019define double @immediate_f64() {
20 ret double 2.5
21}
Dan Gohman2e644382016-05-10 17:39:48 +000022
23; CHECK-LABEL: bitcast_i32_f32:
24; CHECK: i32.reinterpret/f32 $push{{[0-9]+}}=, $0{{$}}
25define i32 @bitcast_i32_f32(float %x) {
26 %y = bitcast float %x to i32
27 ret i32 %y
28}
29
30; CHECK-LABEL: bitcast_f32_i32:
31; CHECK: f32.reinterpret/i32 $push{{[0-9]+}}=, $0{{$}}
32define float @bitcast_f32_i32(i32 %x) {
33 %y = bitcast i32 %x to float
34 ret float %y
35}
36
37; CHECK-LABEL: bitcast_i64_f64:
38; CHECK: i64.reinterpret/f64 $push{{[0-9]+}}=, $0{{$}}
39define i64 @bitcast_i64_f64(double %x) {
40 %y = bitcast double %x to i64
41 ret i64 %y
42}
43
44; CHECK-LABEL: bitcast_f64_i64:
45; CHECK: f64.reinterpret/i64 $push{{[0-9]+}}=, $0{{$}}
46define double @bitcast_f64_i64(i64 %x) {
47 %y = bitcast i64 %x to double
48 ret double %y
49}
Dan Gohman728926a2016-12-22 15:15:10 +000050
51; Do fold offsets into geps.
52; CHECK-LABEL: do_fold_offset_into_gep:
53; CHECK: i64.load $push{{[0-9]+}}=, 8($0)
54define i64 @do_fold_offset_into_gep(i64* %p) {
55bb:
56 %tmp = getelementptr inbounds i64, i64* %p, i32 1
57 %tmp2 = load i64, i64* %tmp, align 8
58 ret i64 %tmp2
59}
60
61; Don't fold negative offsets into geps.
62; CHECK-LABEL: dont_fold_negative_offset:
63; CHECK: i64.load $push{{[0-9]+}}=, 0($pop{{[0-9]+}})
64define i64 @dont_fold_negative_offset(i64* %p) {
65bb:
66 %tmp = getelementptr inbounds i64, i64* %p, i32 -1
67 %tmp2 = load i64, i64* %tmp, align 8
68 ret i64 %tmp2
69}
70
71; Don't fold non-inbounds geps.
72; CHECK-LABEL: dont_fold_non_inbounds_gep:
73; CHECK: i64.load $push{{[0-9]+}}=, 0($pop{{[0-9]+}})
74define i64 @dont_fold_non_inbounds_gep(i64* %p) {
75bb:
76 %tmp = getelementptr i64, i64* %p, i32 1
77 %tmp2 = load i64, i64* %tmp, align 8
78 ret i64 %tmp2
79}