@@ -2,7 +2,7 @@ use rustc_index::vec::Idx;
22use rustc:: middle:: lang_items;
33use rustc:: ty:: { self , Ty , TypeFoldable , Instance } ;
44use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt , FnTypeExt } ;
5- use rustc:: mir:: { self , Place , PlaceBase , Static , StaticKind } ;
5+ use rustc:: mir:: { self , PlaceBase , Static , StaticKind } ;
66use rustc:: mir:: interpret:: PanicInfo ;
77use rustc_target:: abi:: call:: { ArgType , FnType , PassMode } ;
88use rustc_target:: spec:: abi:: Abi ;
@@ -630,53 +630,43 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
630630 // checked by const-qualification, which also
631631 // promotes any complex rvalues to constants.
632632 if i == 2 && intrinsic. unwrap ( ) . starts_with ( "simd_shuffle" ) {
633- match * arg {
633+ match arg {
634634 // The shuffle array argument is usually not an explicit constant,
635635 // but specified directly in the code. This means it gets promoted
636636 // and we can then extract the value by evaluating the promoted.
637- mir:: Operand :: Copy (
638- Place {
639- base : PlaceBase :: Static ( box Static {
640- kind : StaticKind :: Promoted ( promoted, _) ,
637+ mir:: Operand :: Copy ( place) | mir:: Operand :: Move ( place) => {
638+ if let mir:: PlaceRef {
639+ base :
640+ & PlaceBase :: Static ( box Static {
641+ kind : StaticKind :: Promoted ( promoted, _) ,
642+ ty,
643+ def_id : _,
644+ } ) ,
645+ projection : & [ ] ,
646+ } = place. as_ref ( )
647+ {
648+ let param_env = ty:: ParamEnv :: reveal_all ( ) ;
649+ let cid = mir:: interpret:: GlobalId {
650+ instance : self . instance ,
651+ promoted : Some ( promoted) ,
652+ } ;
653+ let c = bx. tcx ( ) . const_eval ( param_env. and ( cid) ) ;
654+ let ( llval, ty) = self . simd_shuffle_indices (
655+ & bx,
656+ terminator. source_info . span ,
641657 ty,
642- def_id : _,
643- } ) ,
644- projection : box [ ] ,
658+ c,
659+ ) ;
660+ return OperandRef {
661+ val : Immediate ( llval) ,
662+ layout : bx. layout_of ( ty) ,
663+ } ;
664+ } else {
665+ span_bug ! ( span, "shuffle indices must be constant" ) ;
645666 }
646- ) |
647- mir:: Operand :: Move (
648- Place {
649- base : PlaceBase :: Static ( box Static {
650- kind : StaticKind :: Promoted ( promoted, _) ,
651- ty,
652- def_id : _,
653- } ) ,
654- projection : box [ ] ,
655- }
656- ) => {
657- let param_env = ty:: ParamEnv :: reveal_all ( ) ;
658- let cid = mir:: interpret:: GlobalId {
659- instance : self . instance ,
660- promoted : Some ( promoted) ,
661- } ;
662- let c = bx. tcx ( ) . const_eval ( param_env. and ( cid) ) ;
663- let ( llval, ty) = self . simd_shuffle_indices (
664- & bx,
665- terminator. source_info . span ,
666- ty,
667- c,
668- ) ;
669- return OperandRef {
670- val : Immediate ( llval) ,
671- layout : bx. layout_of ( ty) ,
672- } ;
673-
674- }
675- mir:: Operand :: Copy ( _) |
676- mir:: Operand :: Move ( _) => {
677- span_bug ! ( span, "shuffle indices must be constant" ) ;
678667 }
679- mir:: Operand :: Constant ( ref constant) => {
668+
669+ mir:: Operand :: Constant ( constant) => {
680670 let c = self . eval_mir_constant ( constant) ;
681671 let ( llval, ty) = self . simd_shuffle_indices (
682672 & bx,
@@ -1117,10 +1107,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11171107 if fn_ret. is_ignore ( ) {
11181108 return ReturnDest :: Nothing ;
11191109 }
1120- let dest = if let mir:: Place {
1121- base : mir:: PlaceBase :: Local ( index) ,
1122- projection : box [ ] ,
1123- } = * dest {
1110+ let dest = if let Some ( index) = dest. as_local ( ) {
11241111 match self . locals [ index] {
11251112 LocalRef :: Place ( dest) => dest,
11261113 LocalRef :: UnsizedPlace ( _) => bug ! ( "return type must be sized" ) ,
@@ -1178,10 +1165,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11781165 src : & mir:: Operand < ' tcx > ,
11791166 dst : & mir:: Place < ' tcx >
11801167 ) {
1181- if let mir:: Place {
1182- base : mir:: PlaceBase :: Local ( index) ,
1183- projection : box [ ] ,
1184- } = * dst {
1168+ if let Some ( index) = dst. as_local ( ) {
11851169 match self . locals [ index] {
11861170 LocalRef :: Place ( place) => self . codegen_transmute_into ( bx, src, place) ,
11871171 LocalRef :: UnsizedPlace ( _) => bug ! ( "transmute must not involve unsized locals" ) ,
0 commit comments