File tree Expand file tree Collapse file tree 4 files changed +9
-2
lines changed
librustc_codegen_ssa/traits Expand file tree Collapse file tree 4 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,10 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
249
249
self . const_uint ( self . type_i8 ( ) , i as u64 )
250
250
}
251
251
252
+ fn const_real ( & self , t : & ' ll Type , val : f64 ) -> & ' ll Value {
253
+ unsafe { llvm:: LLVMConstReal ( t, val) }
254
+ }
255
+
252
256
fn const_struct (
253
257
& self ,
254
258
elts : & [ & ' ll Value ] ,
Original file line number Diff line number Diff line change @@ -1663,9 +1663,10 @@ fn generic_simd_intrinsic(
1663
1663
acc
1664
1664
} else {
1665
1665
// unordered arithmetic reductions do not:
1666
+ let identity_acc = if $name. contains( "mul" ) { 1.0 } else { 0.0 } ;
1666
1667
match f. bit_width( ) {
1667
- 32 => bx. const_undef ( bx. type_f32( ) ) ,
1668
- 64 => bx. const_undef ( bx. type_f64( ) ) ,
1668
+ 32 => bx. const_real ( bx. type_f32( ) , identity_acc ) ,
1669
+ 64 => bx. const_real ( bx. type_f64( ) , identity_acc ) ,
1669
1670
v => {
1670
1671
return_error!( r#"
1671
1672
unsupported {} from `{}` with element `{}` of size `{}` to `{}`"# ,
Original file line number Diff line number Diff line change @@ -715,6 +715,7 @@ extern "C" {
715
715
// Operations on scalar constants
716
716
pub fn LLVMConstInt ( IntTy : & Type , N : c_ulonglong , SignExtend : Bool ) -> & Value ;
717
717
pub fn LLVMConstIntOfArbitraryPrecision ( IntTy : & Type , Wn : c_uint , Ws : * const u64 ) -> & Value ;
718
+ pub fn LLVMConstReal ( RealTy : & Type , N : f64 ) -> & Value ;
718
719
pub fn LLVMConstIntGetZExtValue ( ConstantVal : & Value ) -> c_ulonglong ;
719
720
pub fn LLVMRustConstInt128Get ( ConstantVal : & Value , SExt : bool ,
720
721
high : & mut u64 , low : & mut u64 ) -> bool ;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
17
17
fn const_u64 ( & self , i : u64 ) -> Self :: Value ;
18
18
fn const_usize ( & self , i : u64 ) -> Self :: Value ;
19
19
fn const_u8 ( & self , i : u8 ) -> Self :: Value ;
20
+ fn const_real ( & self , t : Self :: Type , val : f64 ) -> Self :: Value ;
20
21
21
22
fn const_struct ( & self , elts : & [ Self :: Value ] , packed : bool ) -> Self :: Value ;
22
23
You can’t perform that action at this time.
0 commit comments