Skip to content

Commit f7cfb9d

Browse files
committed
Remove shl/shr special handling for 128bit ints
Cranelift now natively supports 128bit int shifting
1 parent 17eaf43 commit f7cfb9d

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

src/codegen_i128.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ pub(crate) fn maybe_codegen<'tcx>(
1919
return None;
2020
}
2121

22-
let lhs_val = lhs.load_scalar(fx);
23-
let rhs_val = rhs.load_scalar(fx);
24-
2522
let is_signed = type_sign(lhs.layout().ty);
2623

2724
match bin_op {
@@ -128,40 +125,6 @@ pub(crate) fn maybe_codegen<'tcx>(
128125
assert!(!checked);
129126
None
130127
}
131-
BinOp::Shl | BinOp::Shr => {
132-
let is_overflow = if checked {
133-
// rhs >= 128
134-
135-
// FIXME support non 128bit rhs
136-
/*let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs_val);
137-
let rhs_msb_gt_0 = fx.bcx.ins().icmp_imm(IntCC::NotEqual, rhs_msb, 0);
138-
let rhs_lsb_ge_128 = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, rhs_lsb, 127);
139-
let is_overflow = fx.bcx.ins().bor(rhs_msb_gt_0, rhs_lsb_ge_128);*/
140-
let is_overflow = fx.bcx.ins().bconst(types::B1, false);
141-
142-
Some(fx.bcx.ins().bint(types::I8, is_overflow))
143-
} else {
144-
None
145-
};
146-
147-
let truncated_rhs = clif_intcast(fx, rhs_val, types::I32, false);
148-
let val = match bin_op {
149-
BinOp::Shl => fx.bcx.ins().ishl(lhs_val, truncated_rhs),
150-
BinOp::Shr => {
151-
if is_signed {
152-
fx.bcx.ins().sshr(lhs_val, truncated_rhs)
153-
} else {
154-
fx.bcx.ins().ushr(lhs_val, truncated_rhs)
155-
}
156-
}
157-
_ => unreachable!(),
158-
};
159-
if let Some(is_overflow) = is_overflow {
160-
let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter());
161-
Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty)))
162-
} else {
163-
Some(CValue::by_val(val, lhs.layout()))
164-
}
165-
}
128+
BinOp::Shl | BinOp::Shr => None,
166129
}
167130
}

0 commit comments

Comments
 (0)