[llvm] Revert "[InstCombine/RISCV] Constant-fold bitcast(vmv.v.x) (#182630)" (PR #194292)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 00:15:16 PDT 2026
================
@@ -3654,54 +3653,3 @@ bool RISCVTTIImpl::shouldCopyAttributeWhenOutliningFrom(
return BaseT::shouldCopyAttributeWhenOutliningFrom(Caller, Attr);
}
-
-std::optional<Instruction *>
-RISCVTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
- // If all operands of a vmv.v.x are constant, fold a bitcast(vmv.v.x) to scale
- // the vmv.v.x, enabling removal of the bitcast. The transform helps avoid
- // creating redundant masks.
- const DataLayout &DL = IC.getDataLayout();
- if (II.user_empty())
- return {};
- auto *TargetVecTy = dyn_cast<ScalableVectorType>(II.user_back()->getType());
- if (!TargetVecTy)
- return {};
- const APInt *Scalar;
- uint64_t VL;
- if (!match(&II, m_Intrinsic<Intrinsic::riscv_vmv_v_x>(
- m_Poison(), m_APInt(Scalar), m_ConstantInt(VL))) ||
- !all_of(II.users(), [TargetVecTy](User *U) {
- return U->getType() == TargetVecTy && match(U, m_BitCast(m_Value()));
- }))
- return {};
- auto *SourceVecTy = cast<ScalableVectorType>(II.getType());
- unsigned TargetEltBW = DL.getTypeSizeInBits(TargetVecTy->getElementType());
- unsigned SourceEltBW = DL.getTypeSizeInBits(SourceVecTy->getElementType());
----------------
artagnon wrote:
If I understand correctly, the infinite loop can be fixed by simply checking that TargetEltBW == SourceEltBW, as sizeof(float) == sizeof(i32), which causes the issue? Identity casts are always stripped anyway?
https://github.com/llvm/llvm-project/pull/194292
More information about the llvm-commits
mailing list