@@ -619,22 +619,34 @@ fn codegen_stmt<'tcx>(
619619 Rvalue :: UnaryOp ( un_op, ref operand) => {
620620 let operand = codegen_operand ( fx, operand) ;
621621 let layout = operand. layout ( ) ;
622- let val = operand. load_scalar ( fx) ;
623622 let res = match un_op {
624- UnOp :: Not => match layout. ty . kind ( ) {
625- ty:: Bool => {
626- let res = fx. bcx . ins ( ) . icmp_imm ( IntCC :: Equal , val, 0 ) ;
627- CValue :: by_val ( res, layout)
623+ UnOp :: Not => {
624+ let val = operand. load_scalar ( fx) ;
625+ match layout. ty . kind ( ) {
626+ ty:: Bool => {
627+ let res = fx. bcx . ins ( ) . icmp_imm ( IntCC :: Equal , val, 0 ) ;
628+ CValue :: by_val ( res, layout)
629+ }
630+ ty:: Uint ( _) | ty:: Int ( _) => {
631+ CValue :: by_val ( fx. bcx . ins ( ) . bnot ( val) , layout)
632+ }
633+ _ => unreachable ! ( "un op Not for {:?}" , layout. ty) ,
628634 }
629- ty:: Uint ( _) | ty:: Int ( _) => {
630- CValue :: by_val ( fx. bcx . ins ( ) . bnot ( val) , layout)
635+ }
636+ UnOp :: Neg => {
637+ let val = operand. load_scalar ( fx) ;
638+ match layout. ty . kind ( ) {
639+ ty:: Int ( _) => CValue :: by_val ( fx. bcx . ins ( ) . ineg ( val) , layout) ,
640+ ty:: Float ( _) => CValue :: by_val ( fx. bcx . ins ( ) . fneg ( val) , layout) ,
641+ _ => unreachable ! ( "un op Neg for {:?}" , layout. ty) ,
631642 }
632- _ => unreachable ! ( "un op Not for {:?}" , layout. ty) ,
633- } ,
634- UnOp :: Neg => match layout. ty . kind ( ) {
635- ty:: Int ( _) => CValue :: by_val ( fx. bcx . ins ( ) . ineg ( val) , layout) ,
636- ty:: Float ( _) => CValue :: by_val ( fx. bcx . ins ( ) . fneg ( val) , layout) ,
637- _ => unreachable ! ( "un op Neg for {:?}" , layout. ty) ,
643+ }
644+ UnOp :: PtrMetadata => match layout. abi {
645+ Abi :: Scalar ( _) => CValue :: zst ( dest_layout) ,
646+ Abi :: ScalarPair ( _, _) => {
647+ CValue :: by_val ( operand. load_scalar_pair ( fx) . 1 , dest_layout)
648+ }
649+ _ => bug ! ( "Unexpected `PtrToMetadata` operand: {operand:?}" ) ,
638650 } ,
639651 } ;
640652 lval. write_cvalue ( fx, res) ;
0 commit comments