1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes
//@ only-64bit (so I don't need to worry about usize)
//@ revisions: aarch64 x86_64
//@ [aarch64] only-aarch64
//@ [aarch64] compile-flags: -C target-feature=+neon
//@ [x86_64] only-x86_64
//@ [x86_64] compile-flags: -C target-feature=+sse2
#![crate_type = "lib"]
#![feature(core_intrinsics)]
#![feature(portable_simd)]
use std::intrinsics::transmute;
use std::simd::{Simd, f32x4, f64x2, i32x4, i64x2};
type PtrX2 = Simd<*const (), 2>;
// These tests use the "C" ABI so that the vectors in question aren't passed and
// returned though memory (as they are in the "Rust" ABI), which greatly
// simplifies seeing the difference between the in-operand cases vs the ones
// that fallback to just using the `LocalKind::Memory` path.
// CHECK-LABEL: <2 x i64> @mixed_int(<4 x i32> %v)
#[no_mangle]
pub extern "C" fn mixed_int(v: i32x4) -> i64x2 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <4 x i32> %v to <2 x i64>
// CHECK: ret <2 x i64> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x double> @mixed_float(<4 x float> %v)
#[no_mangle]
pub extern "C" fn mixed_float(v: f32x4) -> f64x2 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <4 x float> %v to <2 x double>
// CHECK: ret <2 x double> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <4 x i32> @float_int_same_lanes(<4 x float> %v)
#[no_mangle]
pub extern "C" fn float_int_same_lanes(v: f32x4) -> i32x4 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <4 x float> %v to <4 x i32>
// CHECK: ret <4 x i32> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x double> @int_float_same_lanes(<2 x i64> %v)
#[no_mangle]
pub extern "C" fn int_float_same_lanes(v: i64x2) -> f64x2 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <2 x i64> %v to <2 x double>
// CHECK: ret <2 x double> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x i64> @float_int_widen(<4 x float> %v)
#[no_mangle]
pub extern "C" fn float_int_widen(v: f32x4) -> i64x2 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <4 x float> %v to <2 x i64>
// CHECK: ret <2 x i64> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x double> @int_float_widen(<4 x i32> %v)
#[no_mangle]
pub extern "C" fn int_float_widen(v: i32x4) -> f64x2 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <4 x i32> %v to <2 x double>
// CHECK: ret <2 x double> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <4 x i32> @float_int_narrow(<2 x double> %v)
#[no_mangle]
pub extern "C" fn float_int_narrow(v: f64x2) -> i32x4 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <2 x double> %v to <4 x i32>
// CHECK: ret <4 x i32> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <4 x float> @int_float_narrow(<2 x i64> %v)
#[no_mangle]
pub extern "C" fn int_float_narrow(v: i64x2) -> f32x4 {
// CHECK-NOT: alloca
// CHECK: %[[RET:.+]] = bitcast <2 x i64> %v to <4 x float>
// CHECK: ret <4 x float> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x ptr> @float_ptr_same_lanes(<2 x double> %v)
#[no_mangle]
pub extern "C" fn float_ptr_same_lanes(v: f64x2) -> PtrX2 {
// CHECK-NOT: alloca
// CHECK: %[[TEMP:.+]] = alloca [16 x i8]
// CHECK-NOT: alloca
// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]])
// CHECK: store <2 x double> %v, ptr %[[TEMP]]
// CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]]
// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]])
// CHECK: ret <2 x ptr> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x double> @ptr_float_same_lanes(<2 x ptr> %v)
#[no_mangle]
pub extern "C" fn ptr_float_same_lanes(v: PtrX2) -> f64x2 {
// CHECK-NOT: alloca
// CHECK: %[[TEMP:.+]] = alloca [16 x i8]
// CHECK-NOT: alloca
// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]])
// CHECK: store <2 x ptr> %v, ptr %[[TEMP]]
// CHECK: %[[RET:.+]] = load <2 x double>, ptr %[[TEMP]]
// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]])
// CHECK: ret <2 x double> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x ptr> @int_ptr_same_lanes(<2 x i64> %v)
#[no_mangle]
pub extern "C" fn int_ptr_same_lanes(v: i64x2) -> PtrX2 {
// CHECK-NOT: alloca
// CHECK: %[[TEMP:.+]] = alloca [16 x i8]
// CHECK-NOT: alloca
// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]])
// CHECK: store <2 x i64> %v, ptr %[[TEMP]]
// CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]]
// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]])
// CHECK: ret <2 x ptr> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x i64> @ptr_int_same_lanes(<2 x ptr> %v)
#[no_mangle]
pub extern "C" fn ptr_int_same_lanes(v: PtrX2) -> i64x2 {
// CHECK-NOT: alloca
// CHECK: %[[TEMP:.+]] = alloca [16 x i8]
// CHECK-NOT: alloca
// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]])
// CHECK: store <2 x ptr> %v, ptr %[[TEMP]]
// CHECK: %[[RET:.+]] = load <2 x i64>, ptr %[[TEMP]]
// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]])
// CHECK: ret <2 x i64> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x ptr> @float_ptr_widen(<4 x float> %v)
#[no_mangle]
pub extern "C" fn float_ptr_widen(v: f32x4) -> PtrX2 {
// CHECK-NOT: alloca
// CHECK: %[[TEMP:.+]] = alloca [16 x i8]
// CHECK-NOT: alloca
// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]])
// CHECK: store <4 x float> %v, ptr %[[TEMP]]
// CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]]
// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]])
// CHECK: ret <2 x ptr> %[[RET]]
unsafe { transmute(v) }
}
// CHECK-LABEL: <2 x ptr> @int_ptr_widen(<4 x i32> %v)
#[no_mangle]
pub extern "C" fn int_ptr_widen(v: i32x4) -> PtrX2 {
// CHECK-NOT: alloca
// CHECK: %[[TEMP:.+]] = alloca [16 x i8]
// CHECK-NOT: alloca
// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]])
// CHECK: store <4 x i32> %v, ptr %[[TEMP]]
// CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]]
// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]])
// CHECK: ret <2 x ptr> %[[RET]]
unsafe { transmute(v) }
}
|