@@ -128,10 +128,11 @@ pub(crate) fn codegen_int_binop<'tcx>(
128128 let rhs = in_rhs. load_scalar ( fx) ;
129129
130130 let b = fx. bcx . ins ( ) ;
131+ // FIXME trap on overflow for the Unchecked versions
131132 let val = match bin_op {
132- BinOp :: Add => b. iadd ( lhs, rhs) ,
133- BinOp :: Sub => b. isub ( lhs, rhs) ,
134- BinOp :: Mul => b. imul ( lhs, rhs) ,
133+ BinOp :: Add | BinOp :: AddUnchecked => b. iadd ( lhs, rhs) ,
134+ BinOp :: Sub | BinOp :: SubUnchecked => b. isub ( lhs, rhs) ,
135+ BinOp :: Mul | BinOp :: MulUnchecked => b. imul ( lhs, rhs) ,
135136 BinOp :: Div => {
136137 if signed {
137138 b. sdiv ( lhs, rhs)
@@ -149,16 +150,19 @@ pub(crate) fn codegen_int_binop<'tcx>(
149150 BinOp :: BitXor => b. bxor ( lhs, rhs) ,
150151 BinOp :: BitAnd => b. band ( lhs, rhs) ,
151152 BinOp :: BitOr => b. bor ( lhs, rhs) ,
152- BinOp :: Shl => b. ishl ( lhs, rhs) ,
153- BinOp :: Shr => {
153+ BinOp :: Shl | BinOp :: ShlUnchecked => b. ishl ( lhs, rhs) ,
154+ BinOp :: Shr | BinOp :: ShrUnchecked => {
154155 if signed {
155156 b. sshr ( lhs, rhs)
156157 } else {
157158 b. ushr ( lhs, rhs)
158159 }
159160 }
161+ BinOp :: Offset => unreachable ! ( "Offset is not an integer operation" ) ,
160162 // Compare binops handles by `codegen_binop`.
161- _ => unreachable ! ( "{:?}({:?}, {:?})" , bin_op, in_lhs. layout( ) . ty, in_rhs. layout( ) . ty) ,
163+ BinOp :: Eq | BinOp :: Ne | BinOp :: Lt | BinOp :: Le | BinOp :: Gt | BinOp :: Ge => {
164+ unreachable ! ( "{:?}({:?}, {:?})" , bin_op, in_lhs. layout( ) . ty, in_rhs. layout( ) . ty) ;
165+ }
162166 } ;
163167
164168 CValue :: by_val ( val, in_lhs. layout ( ) )
0 commit comments