Skip to content

Commit

Permalink
Use if let instead of match with one meaningful arm
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino authored and oli-obk committed Jan 10, 2020
1 parent b63597d commit fb2f0ec
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/librustc_codegen_ssa/mir/block.rs
Expand Up @@ -609,25 +609,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// checked by const-qualification, which also
// promotes any complex rvalues to constants.
if i == 2 && intrinsic.unwrap().starts_with("simd_shuffle") {
match arg {
// The shuffle array argument is usually not an explicit constant,
// but specified directly in the code. This means it gets promoted
// and we can then extract the value by evaluating the promoted.
mir::Operand::Copy(_place) | mir::Operand::Move(_place) => {}

mir::Operand::Constant(constant) => {
let c = self.eval_mir_constant(constant);
let (llval, ty) = self.simd_shuffle_indices(
&bx,
constant.span,
constant.literal.ty,
c,
);
return OperandRef {
val: Immediate(llval),
layout: bx.layout_of(ty),
};
}
if let mir::Operand::Constant(constant) = arg {
let c = self.eval_mir_constant(constant);
let (llval, ty) = self.simd_shuffle_indices(
&bx,
constant.span,
constant.literal.ty,
c,
);
return OperandRef { val: Immediate(llval), layout: bx.layout_of(ty) };
}
}

Expand Down

0 comments on commit fb2f0ec

Please sign in to comment.