2018-08-27 23:45:51 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+nontrapping-fptoint | FileCheck %s
|
2015-09-15 08:55:19 +08:00
|
|
|
|
|
|
|
; Test that basic conversion operations assemble as expected.
|
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2018-05-11 01:49:11 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
2015-09-15 08:55:19 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i32_wrap_i64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_wrap_i64 (i64) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.wrap_i64 $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i32 @i32_wrap_i64(i64 %x) {
|
2015-09-15 08:55:19 +08:00
|
|
|
%a = trunc i64 %x to i32
|
|
|
|
ret i32 %a
|
|
|
|
}
|
2015-10-03 10:10:28 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i64_extend_s_i32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_extend_s_i32 (i32) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.extend_i32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i64 @i64_extend_s_i32(i32 %x) {
|
|
|
|
%a = sext i32 %x to i64
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i64_extend_u_i32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_extend_u_i32 (i32) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.extend_i32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i64 @i64_extend_u_i32(i32 %x) {
|
|
|
|
%a = zext i32 %x to i64
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_s_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_s_f32 (f32) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i32 @i32_trunc_s_f32(float %x) {
|
|
|
|
%a = fptosi float %x to i32
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_sat_s_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_sat_s_f32 (f32) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i32 @llvm.wasm.trunc.saturate.signed.i32.f32(float)
|
|
|
|
define i32 @i32_trunc_sat_s_f32(float %x) {
|
|
|
|
%a = call i32 @llvm.wasm.trunc.saturate.signed.i32.f32(float %x)
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_u_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_u_f32 (f32) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i32 @i32_trunc_u_f32(float %x) {
|
|
|
|
%a = fptoui float %x to i32
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_sat_u_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_sat_u_f32 (f32) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i32 @llvm.wasm.trunc.saturate.unsigned.i32.f32(float)
|
|
|
|
define i32 @i32_trunc_sat_u_f32(float %x) {
|
|
|
|
%a = call i32 @llvm.wasm.trunc.saturate.unsigned.i32.f32(float %x)
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_s_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_s_f64 (f64) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i32 @i32_trunc_s_f64(double %x) {
|
|
|
|
%a = fptosi double %x to i32
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_sat_s_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_sat_s_f64 (f64) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i32 @llvm.wasm.trunc.saturate.signed.i32.f64(double)
|
|
|
|
define i32 @i32_trunc_sat_s_f64(double %x) {
|
|
|
|
%a = call i32 @llvm.wasm.trunc.saturate.signed.i32.f64(double %x)
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_u_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_u_f64 (f64) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i32 @i32_trunc_u_f64(double %x) {
|
|
|
|
%a = fptoui double %x to i32
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i32_trunc_sat_u_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i32_trunc_sat_u_f64 (f64) -> (i32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i32.trunc_sat_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i32 @llvm.wasm.trunc.saturate.unsigned.i32.f64(double)
|
|
|
|
define i32 @i32_trunc_sat_u_f64(double %x) {
|
|
|
|
%a = call i32 @llvm.wasm.trunc.saturate.unsigned.i32.f64(double %x)
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_s_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_s_f32 (f32) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i64 @i64_trunc_s_f32(float %x) {
|
|
|
|
%a = fptosi float %x to i64
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_sat_s_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_sat_s_f32 (f32) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i64 @llvm.wasm.trunc.saturate.signed.i64.f32(float)
|
|
|
|
define i64 @i64_trunc_sat_s_f32(float %x) {
|
|
|
|
%a = call i64 @llvm.wasm.trunc.saturate.signed.i64.f32(float %x)
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_u_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_u_f32 (f32) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i64 @i64_trunc_u_f32(float %x) {
|
|
|
|
%a = fptoui float %x to i64
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_sat_u_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_sat_u_f32 (f32) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i64 @llvm.wasm.trunc.saturate.unsigned.i64.f32(float)
|
|
|
|
define i64 @i64_trunc_sat_u_f32(float %x) {
|
|
|
|
%a = call i64 @llvm.wasm.trunc.saturate.unsigned.i64.f32(float %x)
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_s_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_s_f64 (f64) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i64 @i64_trunc_s_f64(double %x) {
|
|
|
|
%a = fptosi double %x to i64
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_sat_s_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_sat_s_f64 (f64) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i64 @llvm.wasm.trunc.saturate.signed.i64.f64(double)
|
|
|
|
define i64 @i64_trunc_sat_s_f64(double %x) {
|
|
|
|
%a = call i64 @llvm.wasm.trunc.saturate.signed.i64.f64(double %x)
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_u_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_u_f64 (f64) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define i64 @i64_trunc_u_f64(double %x) {
|
|
|
|
%a = fptoui double %x to i64
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-LABEL: i64_trunc_sat_u_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype i64_trunc_sat_u_f64 (f64) -> (i64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: i64.trunc_sat_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2018-10-11 08:01:25 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
|
|
|
declare i64 @llvm.wasm.trunc.saturate.unsigned.i64.f64(double)
|
|
|
|
define i64 @i64_trunc_sat_u_f64(double %x) {
|
|
|
|
%a = call i64 @llvm.wasm.trunc.saturate.unsigned.i64.f64(double %x)
|
|
|
|
ret i64 %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f32_convert_s_i32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f32_convert_s_i32 (i32) -> (f32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f32.convert_i32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define float @f32_convert_s_i32(i32 %x) {
|
|
|
|
%a = sitofp i32 %x to float
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f32_convert_u_i32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f32_convert_u_i32 (i32) -> (f32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f32.convert_i32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define float @f32_convert_u_i32(i32 %x) {
|
|
|
|
%a = uitofp i32 %x to float
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f64_convert_s_i32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f64_convert_s_i32 (i32) -> (f64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f64.convert_i32_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define double @f64_convert_s_i32(i32 %x) {
|
|
|
|
%a = sitofp i32 %x to double
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f64_convert_u_i32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f64_convert_u_i32 (i32) -> (f64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f64.convert_i32_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define double @f64_convert_u_i32(i32 %x) {
|
|
|
|
%a = uitofp i32 %x to double
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f32_convert_s_i64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f32_convert_s_i64 (i64) -> (f32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f32.convert_i64_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define float @f32_convert_s_i64(i64 %x) {
|
|
|
|
%a = sitofp i64 %x to float
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f32_convert_u_i64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f32_convert_u_i64 (i64) -> (f32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f32.convert_i64_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define float @f32_convert_u_i64(i64 %x) {
|
|
|
|
%a = uitofp i64 %x to float
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f64_convert_s_i64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f64_convert_s_i64 (i64) -> (f64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f64.convert_i64_s $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define double @f64_convert_s_i64(i64 %x) {
|
|
|
|
%a = sitofp i64 %x to double
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f64_convert_u_i64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f64_convert_u_i64 (i64) -> (f64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f64.convert_i64_u $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define double @f64_convert_u_i64(i64 %x) {
|
|
|
|
%a = uitofp i64 %x to double
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f64_promote_f32:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f64_promote_f32 (f32) -> (f64){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f64.promote_f32 $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define double @f64_promote_f32(float %x) {
|
|
|
|
%a = fpext float %x to double
|
|
|
|
ret double %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: f32_demote_f64:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype f32_demote_f64 (f64) -> (f32){{$}}
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: f32.demote_f64 $push[[NUM:[0-9]+]]=, $0{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM]]{{$}}
|
2015-10-03 10:10:28 +08:00
|
|
|
define float @f32_demote_f64(double %x) {
|
|
|
|
%a = fptrunc double %x to float
|
|
|
|
ret float %a
|
|
|
|
}
|
2015-12-10 08:17:35 +08:00
|
|
|
|
|
|
|
; If the high its are unused, LLVM will optimize sext/zext into anyext, which
|
|
|
|
; we need to patterm-match back to a specific instruction.
|
|
|
|
|
|
|
|
; CHECK-LABEL: anyext:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK: i64.extend_i32_u $push0=, $0{{$}}
|
2015-12-10 08:17:35 +08:00
|
|
|
define i64 @anyext(i32 %x) {
|
|
|
|
%y = sext i32 %x to i64
|
|
|
|
%w = shl i64 %y, 32
|
|
|
|
ret i64 %w
|
|
|
|
}
|
2015-12-10 08:37:51 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: bitcast_i32_to_float:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK: f32.reinterpret_i32 $push0=, $0{{$}}
|
2015-12-10 08:37:51 +08:00
|
|
|
define float @bitcast_i32_to_float(i32 %a) {
|
|
|
|
%t = bitcast i32 %a to float
|
|
|
|
ret float %t
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: bitcast_float_to_i32:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK: i32.reinterpret_f32 $push0=, $0{{$}}
|
2015-12-10 08:37:51 +08:00
|
|
|
define i32 @bitcast_float_to_i32(float %a) {
|
|
|
|
%t = bitcast float %a to i32
|
|
|
|
ret i32 %t
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: bitcast_i64_to_double:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK: f64.reinterpret_i64 $push0=, $0{{$}}
|
2015-12-10 08:37:51 +08:00
|
|
|
define double @bitcast_i64_to_double(i64 %a) {
|
|
|
|
%t = bitcast i64 %a to double
|
|
|
|
ret double %t
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: bitcast_double_to_i64:
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK: i64.reinterpret_f64 $push0=, $0{{$}}
|
2015-12-10 08:37:51 +08:00
|
|
|
define i64 @bitcast_double_to_i64(double %a) {
|
|
|
|
%t = bitcast double %a to i64
|
|
|
|
ret i64 %t
|
|
|
|
}
|