@@ -593,17 +593,23 @@ llvm::Value *InstructionLifter::LiftRegisterOperand(Instruction &inst,
593593 auto arg_size = data_layout.getTypeAllocSizeInBits (arg_type);
594594
595595 if (val_size < arg_size) {
596- // Because of using the latest version of Intex XED we support (which is currently v2025.06.08),
597- // it reports XMM/YMM registers as vectors instead of integers. When remills tries to extend/truncate
598- // these values we'll bitcast those vectors into integers
596+ // NOTE(xed2025): XED 2025 reports XMM/YMM/ZMM registers as LLVM vector types
597+ // (e.g., <4 x float>) instead of integers. When remill needs to zero-extend
598+ // these values to a larger integer type, we must first bitcast the vector
599+ // to an integer of the same bit width, then perform the extension.
599600 if (arg_type->isIntegerTy ()) {
600601 if (val_type->isVectorTy ()) {
602+ // Vector types can be directly bitcast to integers of the same size.
601603 auto int_type = llvm::Type::getIntNTy (module ->getContext (), val_size);
602604 val = new llvm::BitCastInst (val, int_type, llvm::Twine::createNull (), block);
603605
604606 val_type = int_type;
605607 } else if (val_type->isArrayTy ()) {
606- // Arrays cannot be bitcast directly. Store to memory, bitcast pointer, then load.
608+ // NOTE(xed2025): Some register types in remill's State structure are
609+ // represented as arrays (e.g., X87 FPU stack entries as [10 x i8]).
610+ // LLVM does not allow direct bitcast of array types to integers.
611+ // Workaround: store array to stack, bitcast the pointer to int*, then load.
612+ // This gets optimized away by LLVM but satisfies the type system.
607613 auto int_type = llvm::Type::getIntNTy (module ->getContext (), val_size);
608614 auto temp_alloca = new llvm::AllocaInst (val_type, 0 , llvm::Twine::createNull (), block);
609615 new llvm::StoreInst (val, temp_alloca, block);
@@ -633,14 +639,18 @@ llvm::Value *InstructionLifter::LiftRegisterOperand(Instruction &inst,
633639 }
634640
635641 } else if (val_size > arg_size) {
642+ // NOTE(xed2025): Same type conversion issue as above, but for truncation.
643+ // XED 2025 may report registers as vectors/arrays that need conversion
644+ // to integers before we can truncate them to the smaller argument size.
636645 if (arg_type->isIntegerTy ()) {
637646 if (val_type->isVectorTy ()) {
647+ // Vector types can be directly bitcast to integers of the same size.
638648 auto int_type = llvm::Type::getIntNTy (module ->getContext (), val_size);
639649 val = new llvm::BitCastInst (val, int_type, llvm::Twine::createNull (), block);
640650
641651 val_type = int_type;
642652 } else if (val_type->isArrayTy ()) {
643- // Arrays cannot be bitcast directly. Store to memory, bitcast pointer, then load .
653+ // Array types require store- bitcast-load pattern (see comment above) .
644654 auto int_type = llvm::Type::getIntNTy (module ->getContext (), val_size);
645655 auto temp_alloca = new llvm::AllocaInst (val_type, 0 , llvm::Twine::createNull (), block);
646656 new llvm::StoreInst (val, temp_alloca, block);
0 commit comments