blob: 953bd610b1bc64b922a515cfdbacc721d9af4240 [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 \
3; RUN: | FileCheck %s
4
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00005target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman7b634842015-08-24 18:44:37 +00006target triple = "wasm32-unknown-unknown"
7
8; This tests very minimal fast-isel functionality.
9
Dan Gohmane51c0582015-10-06 00:27:55 +000010; CHECK-LABEL: immediate_f32:
Dan Gohman700515f2015-11-23 21:55:57 +000011; CHECK: f32.const $push{{[0-9]+}}=, 0x1.4p1{{$}}
Dan Gohman7b634842015-08-24 18:44:37 +000012define float @immediate_f32() {
13 ret float 2.5
14}
15
Dan Gohmane51c0582015-10-06 00:27:55 +000016; CHECK-LABEL: immediate_f64:
Dan Gohman700515f2015-11-23 21:55:57 +000017; CHECK: f64.const $push{{[0-9]+}}=, 0x1.4p1{{$}}
Dan Gohman7b634842015-08-24 18:44:37 +000018define double @immediate_f64() {
19 ret double 2.5
20}
Dan Gohman2e644382016-05-10 17:39:48 +000021
22; CHECK-LABEL: bitcast_i32_f32:
23; CHECK: i32.reinterpret/f32 $push{{[0-9]+}}=, $0{{$}}
24define i32 @bitcast_i32_f32(float %x) {
25 %y = bitcast float %x to i32
26 ret i32 %y
27}
28
29; CHECK-LABEL: bitcast_f32_i32:
30; CHECK: f32.reinterpret/i32 $push{{[0-9]+}}=, $0{{$}}
31define float @bitcast_f32_i32(i32 %x) {
32 %y = bitcast i32 %x to float
33 ret float %y
34}
35
36; CHECK-LABEL: bitcast_i64_f64:
37; CHECK: i64.reinterpret/f64 $push{{[0-9]+}}=, $0{{$}}
38define i64 @bitcast_i64_f64(double %x) {
39 %y = bitcast double %x to i64
40 ret i64 %y
41}
42
43; CHECK-LABEL: bitcast_f64_i64:
44; CHECK: f64.reinterpret/i64 $push{{[0-9]+}}=, $0{{$}}
45define double @bitcast_f64_i64(i64 %x) {
46 %y = bitcast i64 %x to double
47 ret double %y
48}
Dan Gohman728926a2016-12-22 15:15:10 +000049
50; Do fold offsets into geps.
51; CHECK-LABEL: do_fold_offset_into_gep:
52; CHECK: i64.load $push{{[0-9]+}}=, 8($0)
53define i64 @do_fold_offset_into_gep(i64* %p) {
54bb:
55 %tmp = getelementptr inbounds i64, i64* %p, i32 1
56 %tmp2 = load i64, i64* %tmp, align 8
57 ret i64 %tmp2
58}
59
60; Don't fold negative offsets into geps.
61; CHECK-LABEL: dont_fold_negative_offset:
62; CHECK: i64.load $push{{[0-9]+}}=, 0($pop{{[0-9]+}})
63define i64 @dont_fold_negative_offset(i64* %p) {
64bb:
65 %tmp = getelementptr inbounds i64, i64* %p, i32 -1
66 %tmp2 = load i64, i64* %tmp, align 8
67 ret i64 %tmp2
68}
69
70; Don't fold non-inbounds geps.
71; CHECK-LABEL: dont_fold_non_inbounds_gep:
72; CHECK: i64.load $push{{[0-9]+}}=, 0($pop{{[0-9]+}})
73define i64 @dont_fold_non_inbounds_gep(i64* %p) {
74bb:
75 %tmp = getelementptr i64, i64* %p, i32 1
76 %tmp2 = load i64, i64* %tmp, align 8
77 ret i64 %tmp2
78}