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> {
249249 self . const_uint ( self . type_i8 ( ) , i as u64 )
250250 }
251251
252+ fn const_real ( & self , t : & ' ll Type , val : f64 ) -> & ' ll Value {
253+ unsafe { llvm:: LLVMConstReal ( t, val) }
254+ }
255+
252256 fn const_struct (
253257 & self ,
254258 elts : & [ & ' ll Value ] ,
Original file line number Diff line number Diff line change @@ -1663,9 +1663,10 @@ fn generic_simd_intrinsic(
16631663 acc
16641664 } else {
16651665 // unordered arithmetic reductions do not:
1666+ let identity_acc = if $name. contains( "mul" ) { 1.0 } else { 0.0 } ;
16661667 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 ) ,
16691670 v => {
16701671 return_error!( r#"
16711672unsupported {} from `{}` with element `{}` of size `{}` to `{}`"# ,
Original file line number Diff line number Diff line change @@ -715,6 +715,7 @@ extern "C" {
715715 // Operations on scalar constants
716716 pub fn LLVMConstInt ( IntTy : & Type , N : c_ulonglong , SignExtend : Bool ) -> & Value ;
717717 pub fn LLVMConstIntOfArbitraryPrecision ( IntTy : & Type , Wn : c_uint , Ws : * const u64 ) -> & Value ;
718+ pub fn LLVMConstReal ( RealTy : & Type , N : f64 ) -> & Value ;
718719 pub fn LLVMConstIntGetZExtValue ( ConstantVal : & Value ) -> c_ulonglong ;
719720 pub fn LLVMRustConstInt128Get ( ConstantVal : & Value , SExt : bool ,
720721 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 {
1717 fn const_u64 ( & self , i : u64 ) -> Self :: Value ;
1818 fn const_usize ( & self , i : u64 ) -> Self :: Value ;
1919 fn const_u8 ( & self , i : u8 ) -> Self :: Value ;
20+ fn const_real ( & self , t : Self :: Type , val : f64 ) -> Self :: Value ;
2021
2122 fn const_struct ( & self , elts : & [ Self :: Value ] , packed : bool ) -> Self :: Value ;
2223
You can’t perform that action at this time.
0 commit comments