@@ -383,7 +383,9 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
383383 | sym:: rotate_left
384384 | sym:: rotate_right
385385 | sym:: saturating_add
386- | sym:: saturating_sub => {
386+ | sym:: saturating_sub
387+ | sym:: unchecked_funnel_shl
388+ | sym:: unchecked_funnel_shr => {
387389 let ty = args[ 0 ] . layout . ty ;
388390 if !ty. is_integral ( ) {
389391 tcx. dcx ( ) . emit_err ( InvalidMonomorphization :: BasicIntegerType {
@@ -424,18 +426,26 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
424426 sym:: bitreverse => {
425427 self . call_intrinsic ( "llvm.bitreverse" , & [ llty] , & [ args[ 0 ] . immediate ( ) ] )
426428 }
427- sym:: rotate_left | sym:: rotate_right => {
428- let is_left = name == sym:: rotate_left;
429- let val = args[ 0 ] . immediate ( ) ;
430- let raw_shift = args[ 1 ] . immediate ( ) ;
431- // rotate = funnel shift with first two args the same
429+ sym:: rotate_left
430+ | sym:: rotate_right
431+ | sym:: unchecked_funnel_shl
432+ | sym:: unchecked_funnel_shr => {
433+ let is_left = name == sym:: rotate_left || name == sym:: unchecked_funnel_shl;
434+ let lhs = args[ 0 ] . immediate ( ) ;
435+ let ( rhs, raw_shift) =
436+ if name == sym:: rotate_left || name == sym:: rotate_right {
437+ // rotate = funnel shift with first two args the same
438+ ( lhs, args[ 1 ] . immediate ( ) )
439+ } else {
440+ ( args[ 1 ] . immediate ( ) , args[ 2 ] . immediate ( ) )
441+ } ;
432442 let llvm_name = format ! ( "llvm.fsh{}" , if is_left { 'l' } else { 'r' } ) ;
433443
434444 // llvm expects shift to be the same type as the values, but rust
435445 // always uses `u32`.
436- let raw_shift = self . intcast ( raw_shift, self . val_ty ( val ) , false ) ;
446+ let raw_shift = self . intcast ( raw_shift, self . val_ty ( lhs ) , false ) ;
437447
438- self . call_intrinsic ( llvm_name, & [ llty] , & [ val , val , raw_shift] )
448+ self . call_intrinsic ( llvm_name, & [ llty] , & [ lhs , rhs , raw_shift] )
439449 }
440450 sym:: saturating_add | sym:: saturating_sub => {
441451 let is_add = name == sym:: saturating_add;
0 commit comments