@@ -581,40 +581,22 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
581
581
Some ( self . operand_from_scalar ( scalar, value. layout . ty ) )
582
582
}
583
583
Immediate :: ScalarPair ( ..) => {
584
- // Found a value represented as a pair. For now only do const-prop if the type
585
- // of `rvalue` is also a tuple with two scalars.
586
- // FIXME: enable the general case stated above ^.
587
- let ty = value. layout . ty ;
588
- // Only do it for tuples
589
- let ty:: Tuple ( types) = ty. kind ( ) else { return None } ;
590
- // Only do it if tuple is also a pair with two scalars
591
- if let [ ty1, ty2] = types[ ..] {
592
- let ty_is_scalar = |ty| {
593
- self . ecx . layout_of ( ty) . ok ( ) . map ( |layout| layout. abi . is_scalar ( ) )
594
- == Some ( true )
595
- } ;
596
- let alloc = if ty_is_scalar ( ty1) && ty_is_scalar ( ty2) {
597
- self . ecx
598
- . intern_with_temp_alloc ( value. layout , |ecx, dest| {
599
- ecx. write_immediate ( * imm, dest)
600
- } )
601
- . unwrap ( )
602
- } else {
603
- return None ;
604
- } ;
605
-
606
- // Assign entire constant in a single statement.
607
- // We can't use aggregates, as we run after the aggregate-lowering `MirPhase`.
608
- let const_val = ConstValue :: ByRef { alloc, offset : Size :: ZERO } ;
609
- let literal = ConstantKind :: Val ( const_val, ty) ;
610
- Some ( Operand :: Constant ( Box :: new ( Constant {
611
- span : DUMMY_SP ,
612
- user_ty : None ,
613
- literal,
614
- } ) ) )
615
- } else {
616
- None
617
- }
584
+ let alloc = self
585
+ . ecx
586
+ . intern_with_temp_alloc ( value. layout , |ecx, dest| {
587
+ ecx. write_immediate ( * imm, dest)
588
+ } )
589
+ . ok ( ) ?;
590
+
591
+ let literal = ConstantKind :: Val (
592
+ ConstValue :: ByRef { alloc, offset : Size :: ZERO } ,
593
+ value. layout . ty ,
594
+ ) ;
595
+ Some ( Operand :: Constant ( Box :: new ( Constant {
596
+ span : DUMMY_SP ,
597
+ user_ty : None ,
598
+ literal,
599
+ } ) ) )
618
600
}
619
601
// Scalars or scalar pairs that contain undef values are assumed to not have
620
602
// successfully evaluated and are thus not propagated.
0 commit comments