]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #23692 - yjh0502:fix/simd-overflow, r=pnkfelix
authorManish Goregaokar <manishsmail@gmail.com>
Wed, 25 Mar 2015 11:42:14 +0000 (17:12 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Wed, 25 Mar 2015 14:14:08 +0000 (19:44 +0530)
Disable overflow checking on SIMD operations, fix #23037

1  2 
src/librustc_trans/trans/expr.rs

index 4d7431a20b707e098f3ef6ea54f03b7853ea2763,989ad0d55347d4063e0294251ce3da83399a3283..ba8de6da42f72210abebe59610ea99cec0d99617
@@@ -1227,9 -1227,22 +1227,9 @@@ fn trans_rvalue_dps_unadjusted<'blk, 't
              trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), base,
                                  vec![(idx_datum, idx.id)], Some(dest), true).bcx
          }
 -        ast::ExprCast(ref val, _) => {
 -            // DPS output mode means this is a trait cast:
 -            if ty::type_is_trait(node_id_type(bcx, expr.id)) {
 -                let trait_ref =
 -                    bcx.tcx().object_cast_map.borrow()
 -                                             .get(&expr.id)
 -                                             .cloned()
 -                                             .unwrap();
 -                let trait_ref = bcx.monomorphize(&trait_ref);
 -                let datum = unpack_datum!(bcx, trans(bcx, &**val));
 -                meth::trans_trait_cast(bcx, datum, expr.id,
 -                                       trait_ref, dest)
 -            } else {
 -                bcx.tcx().sess.span_bug(expr.span,
 -                                        "expr_cast of non-trait");
 -            }
 +        ast::ExprCast(..) => {
 +            // Trait casts used to come this way, now they should be coercions.
 +            bcx.tcx().sess.span_bug(expr.span, "DPS expr_cast (residual trait cast?)")
          }
          ast::ExprAssignOp(op, ref dst, ref src) => {
              trans_assign_op(bcx, expr, op, &**dst, &**src)
@@@ -1766,6 -1779,8 +1766,8 @@@ fn trans_eager_binop<'blk, 'tcx>(bcx: B
        ast::BiAdd => {
          if is_float {
              FAdd(bcx, lhs, rhs, binop_debug_loc)
+         } else if is_simd {
+             Add(bcx, lhs, rhs, binop_debug_loc)
          } else {
              let (newbcx, res) = with_overflow_check(
                  bcx, OverflowOp::Add, info, lhs_t, lhs, rhs, binop_debug_loc);
        ast::BiSub => {
          if is_float {
              FSub(bcx, lhs, rhs, binop_debug_loc)
+         } else if is_simd {
+             Sub(bcx, lhs, rhs, binop_debug_loc)
          } else {
              let (newbcx, res) = with_overflow_check(
                  bcx, OverflowOp::Sub, info, lhs_t, lhs, rhs, binop_debug_loc);
        ast::BiMul => {
          if is_float {
              FMul(bcx, lhs, rhs, binop_debug_loc)
+         } else if is_simd {
+             Mul(bcx, lhs, rhs, binop_debug_loc)
          } else {
              let (newbcx, res) = with_overflow_check(
                  bcx, OverflowOp::Mul, info, lhs_t, lhs, rhs, binop_debug_loc);
@@@ -2078,7 -2097,7 +2084,7 @@@ fn trans_imm_cast<'blk, 'tcx>(bcx: Bloc
      let mut bcx = bcx;
      let ccx = bcx.ccx();
  
 -    let t_in = expr_ty(bcx, expr);
 +    let t_in = expr_ty_adjusted(bcx, expr);
      let t_out = node_id_type(bcx, id);
      let k_in = cast_type_kind(bcx.tcx(), t_in);
      let k_out = cast_type_kind(bcx.tcx(), t_out);
      // by-value as appropriate given its type:
      let mut datum = unpack_datum!(bcx, trans(bcx, expr));
  
 -    if cast_is_noop(datum.ty, t_out) {
 +    let datum_ty = monomorphize_type(bcx, datum.ty);
 +    if cast_is_noop(datum_ty, t_out) {
          datum.ty = t_out;
          return DatumBlock::new(bcx, datum);
      }