@@ -116,9 +116,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
116
116
None ,
117
117
)
118
118
}
119
- sym:: likely => {
120
- self . call_intrinsic ( "llvm.expect.i1" , & [ args[ 0 ] . immediate ( ) , self . const_bool ( true ) ] )
121
- }
119
+ sym:: likely => self . expect ( args[ 0 ] . immediate ( ) , true ) ,
122
120
sym:: is_val_statically_known => {
123
121
let intrinsic_type = args[ 0 ] . layout . immediate_llvm_type ( self . cx ) ;
124
122
match self . type_kind ( intrinsic_type) {
@@ -131,8 +129,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
131
129
_ => self . const_bool ( false ) ,
132
130
}
133
131
}
134
- sym:: unlikely => self
135
- . call_intrinsic ( "llvm.expect.i1" , & [ args[ 0 ] . immediate ( ) , self . const_bool ( false ) ] ) ,
132
+ sym:: unlikely => self . expect ( args[ 0 ] . immediate ( ) , false ) ,
136
133
kw:: Try => {
137
134
try_intrinsic (
138
135
self ,
@@ -423,11 +420,17 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
423
420
}
424
421
425
422
fn assume ( & mut self , val : Self :: Value ) {
426
- self . call_intrinsic ( "llvm.assume" , & [ val] ) ;
423
+ if self . cx . sess ( ) . opts . optimize != rustc_session:: config:: OptLevel :: No {
424
+ self . call_intrinsic ( "llvm.assume" , & [ val] ) ;
425
+ }
427
426
}
428
427
429
428
fn expect ( & mut self , cond : Self :: Value , expected : bool ) -> Self :: Value {
430
- self . call_intrinsic ( "llvm.expect.i1" , & [ cond, self . const_bool ( expected) ] )
429
+ if self . cx . sess ( ) . opts . optimize != rustc_session:: config:: OptLevel :: No {
430
+ self . call_intrinsic ( "llvm.expect.i1" , & [ cond, self . const_bool ( expected) ] )
431
+ } else {
432
+ cond
433
+ }
431
434
}
432
435
433
436
fn type_test ( & mut self , pointer : Self :: Value , typeid : Self :: Value ) -> Self :: Value {
0 commit comments