Skip to content

Commit

Permalink
Avoid mir_operand_get_const_val for simd_shuffle and cmpps and cmppd
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Sep 14, 2023
1 parent aab17cc commit d8c1393
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/intrinsics/llvm_x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
};
let x = codegen_operand(fx, x);
let y = codegen_operand(fx, y);
let kind = crate::constant::mir_operand_get_const_val(fx, kind)
.expect("llvm.x86.sse2.cmp.* kind not const");
let kind = match kind {
Operand::Constant(const_) => {
crate::constant::eval_mir_constant(fx, const_).unwrap().0
}
Operand::Copy(_) | Operand::Move(_) => unreachable!("{kind:?}"),
};

let flt_cc = match kind
.try_to_bits(Size::from_bytes(1))
Expand Down
8 changes: 6 additions & 2 deletions src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(

let indexes = {
use rustc_middle::mir::interpret::*;
let idx_const = crate::constant::mir_operand_get_const_val(fx, idx)
.expect("simd_shuffle idx not const");
let idx_const = match idx {
Operand::Constant(const_) => {
crate::constant::eval_mir_constant(fx, const_).unwrap().0
}
Operand::Copy(_) | Operand::Move(_) => unreachable!("{idx:?}"),
};

let idx_bytes = match idx_const {
ConstValue::ByRef { alloc, offset } => {
Expand Down

0 comments on commit d8c1393

Please sign in to comment.