@@ -186,9 +186,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
186
186
Some ( instance) ,
187
187
)
188
188
}
189
- sym:: likely => {
190
- self . call_intrinsic ( "llvm.expect.i1" , & [ args[ 0 ] . immediate ( ) , self . const_bool ( true ) ] )
191
- }
189
+ sym:: likely => self . expect ( args[ 0 ] . immediate ( ) , true ) ,
192
190
sym:: is_val_statically_known => {
193
191
let intrinsic_type = args[ 0 ] . layout . immediate_llvm_type ( self . cx ) ;
194
192
match self . type_kind ( intrinsic_type) {
@@ -201,8 +199,8 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
201
199
_ => self . const_bool ( false ) ,
202
200
}
203
201
}
204
- sym :: unlikely => self
205
- . call_intrinsic ( "llvm. expect.i1" , & [ args[ 0 ] . immediate ( ) , self . const_bool ( false ) ] ) ,
202
+
203
+ sym :: unlikely => self . expect ( args[ 0 ] . immediate ( ) , false ) ,
206
204
sym:: catch_unwind => {
207
205
catch_unwind_intrinsic (
208
206
self ,
@@ -566,11 +564,17 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
566
564
}
567
565
568
566
fn assume ( & mut self , val : Self :: Value ) {
569
- self . call_intrinsic ( "llvm.assume" , & [ val] ) ;
567
+ if self . cx . sess ( ) . opts . optimize != rustc_session:: config:: OptLevel :: No {
568
+ self . call_intrinsic ( "llvm.assume" , & [ val] ) ;
569
+ }
570
570
}
571
571
572
572
fn expect ( & mut self , cond : Self :: Value , expected : bool ) -> Self :: Value {
573
- self . call_intrinsic ( "llvm.expect.i1" , & [ cond, self . const_bool ( expected) ] )
573
+ if self . cx . sess ( ) . opts . optimize != rustc_session:: config:: OptLevel :: No {
574
+ self . call_intrinsic ( "llvm.expect.i1" , & [ cond, self . const_bool ( expected) ] )
575
+ } else {
576
+ cond
577
+ }
574
578
}
575
579
576
580
fn type_test ( & mut self , pointer : Self :: Value , typeid : Self :: Value ) -> Self :: Value {
0 commit comments