@@ -11,7 +11,7 @@ use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh}
11
11
use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
12
12
use rustc_codegen_ssa:: errors:: { ExpectedPointerMutability , InvalidMonomorphization } ;
13
13
use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
14
- use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
14
+ use rustc_codegen_ssa:: mir:: place:: { PlaceRef , PlaceValue } ;
15
15
use rustc_codegen_ssa:: traits:: * ;
16
16
use rustc_hir as hir;
17
17
use rustc_middle:: mir:: BinOp ;
@@ -203,6 +203,35 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
203
203
}
204
204
sym:: unlikely => self
205
205
. call_intrinsic ( "llvm.expect.i1" , & [ args[ 0 ] . immediate ( ) , self . const_bool ( false ) ] ) ,
206
+ sym:: select_unpredictable => {
207
+ let cond = args[ 0 ] . immediate ( ) ;
208
+ assert_eq ! ( args[ 1 ] . layout, args[ 2 ] . layout) ;
209
+ let select = |bx : & mut Self , true_val, false_val| {
210
+ let result = bx. select ( cond, true_val, false_val) ;
211
+ bx. set_unpredictable ( & result) ;
212
+ result
213
+ } ;
214
+ match ( args[ 1 ] . val , args[ 2 ] . val ) {
215
+ ( OperandValue :: Ref ( true_val) , OperandValue :: Ref ( false_val) ) => {
216
+ assert ! ( true_val. llextra. is_none( ) ) ;
217
+ assert ! ( false_val. llextra. is_none( ) ) ;
218
+ assert_eq ! ( true_val. align, false_val. align) ;
219
+ let ptr = select ( self , true_val. llval , false_val. llval ) ;
220
+ let selected =
221
+ OperandValue :: Ref ( PlaceValue :: new_sized ( ptr, true_val. align ) ) ;
222
+ selected. store ( self , result) ;
223
+ return Ok ( ( ) ) ;
224
+ }
225
+ ( OperandValue :: Immediate ( _) , OperandValue :: Immediate ( _) )
226
+ | ( OperandValue :: Pair ( _, _) , OperandValue :: Pair ( _, _) ) => {
227
+ let true_val = args[ 1 ] . immediate_or_packed_pair ( self ) ;
228
+ let false_val = args[ 2 ] . immediate_or_packed_pair ( self ) ;
229
+ select ( self , true_val, false_val)
230
+ }
231
+ ( OperandValue :: ZeroSized , OperandValue :: ZeroSized ) => return Ok ( ( ) ) ,
232
+ _ => span_bug ! ( span, "Incompatible OperandValue for select_unpredictable" ) ,
233
+ }
234
+ }
206
235
sym:: catch_unwind => {
207
236
catch_unwind_intrinsic (
208
237
self ,
0 commit comments