Skip to content

Commit 1663665

Browse files
committed
Fix ICE on SIMD overflow checking
Disable overflow checking on SIMD operations, fix #23037
1 parent 123a754 commit 1663665

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: src/librustc_trans/trans/expr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,8 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17791779
ast::BiAdd => {
17801780
if is_float {
17811781
FAdd(bcx, lhs, rhs, binop_debug_loc)
1782+
} else if is_simd {
1783+
Add(bcx, lhs, rhs, binop_debug_loc)
17821784
} else {
17831785
let (newbcx, res) = with_overflow_check(
17841786
bcx, OverflowOp::Add, info, lhs_t, lhs, rhs, binop_debug_loc);
@@ -1789,6 +1791,8 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17891791
ast::BiSub => {
17901792
if is_float {
17911793
FSub(bcx, lhs, rhs, binop_debug_loc)
1794+
} else if is_simd {
1795+
Sub(bcx, lhs, rhs, binop_debug_loc)
17921796
} else {
17931797
let (newbcx, res) = with_overflow_check(
17941798
bcx, OverflowOp::Sub, info, lhs_t, lhs, rhs, binop_debug_loc);
@@ -1799,6 +1803,8 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17991803
ast::BiMul => {
18001804
if is_float {
18011805
FMul(bcx, lhs, rhs, binop_debug_loc)
1806+
} else if is_simd {
1807+
Mul(bcx, lhs, rhs, binop_debug_loc)
18021808
} else {
18031809
let (newbcx, res) = with_overflow_check(
18041810
bcx, OverflowOp::Mul, info, lhs_t, lhs, rhs, binop_debug_loc);

Diff for: src/test/run-pass/issue-23037.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(core)]
12+
13+
use std::simd::i32x4;
14+
fn main() {
15+
let foo = i32x4(1,2,3,4);
16+
let bar = i32x4(40,30,20,10);
17+
let baz = foo + bar;
18+
assert!(baz.0 == 41 && baz.1 == 32 && baz.2 == 23 && baz.3 == 14);
19+
}

0 commit comments

Comments
 (0)