Skip to content

Commit dabf77f

Browse files
committed
remove is_packed() method and use the layout to determine if a type should be evaluated as a const vector
1 parent a554f3f commit dabf77f

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,21 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
639639
let constant_ty = constant.ty();
640640
// Make sure that constant SIMD vectors are passed as immediates.
641641
// This is needed for some intrinsics.
642-
if constant_ty.is_simd() && !constant_ty.is_packed() {
643-
let (llval, ty) = self.immediate_const_vector(bx, constant);
644-
OperandRef { val: OperandValue::Immediate(llval), layout: bx.layout_of(ty) }
642+
return if constant_ty.is_simd() {
643+
let layout = bx.layout_of(constant_ty);
644+
match layout.abi {
645+
Abi::Vector { .. } => {
646+
let (llval, ty) = self.immediate_const_vector(bx, constant);
647+
OperandRef {
648+
val: OperandValue::Immediate(llval),
649+
layout: bx.layout_of(ty),
650+
}
651+
}
652+
_ => self.eval_mir_constant_to_operand(bx, constant),
653+
}
645654
} else {
646655
self.eval_mir_constant_to_operand(bx, constant)
647-
}
656+
};
648657
}
649658
}
650659
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,14 +1077,6 @@ impl<'tcx> Ty<'tcx> {
10771077
}
10781078
}
10791079

1080-
#[inline]
1081-
pub fn is_packed(self) -> bool {
1082-
match self.kind() {
1083-
Adt(def, _) => def.repr().packed(),
1084-
_ => false,
1085-
}
1086-
}
1087-
10881080
pub fn sequence_element_type(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
10891081
match self.kind() {
10901082
Array(ty, _) | Slice(ty) => *ty,

0 commit comments

Comments
 (0)