[llvm] [GlobalISel] Support fixed vectors in constant-fold combines. (PR #220876)
Yaxun Liu via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 06:50:32 PDT 2026
================
@@ -4760,13 +4686,25 @@ bool CombinerHelper::matchICmpToTrueFalseKnownBits(MachineInstr &MI,
if (!KnownVal)
return false;
- MatchInfo =
- *KnownVal
- ? getICmpTrueVal(getTargetLowering(),
- /*IsVector = */
- MRI.getType(MI.getOperand(0).getReg()).isVector(),
- /* IsFP = */ false)
- : 0;
+
+ Register Dst = MI.getOperand(0).getReg();
+ LLT DstTy = MRI.getType(Dst);
+ int64_t Val = *KnownVal ? getICmpTrueVal(getTargetLowering(),
+ /*IsVector = */ DstTy.isVector(),
+ /* IsFP = */ false)
+ : 0;
+
+ if (DstTy.isVector()) {
+ SmallVector<APInt> Csts(DstTy.getNumElements(),
----------------
yxsamliu wrote:
Since this is generic GlobalISel code, could we avoid calling `getNumElements()` after only checking `isVector()`? This also includes scalable vectors, where `getNumElements()` is not valid. Using `isFixedVector()` or building a splat would avoid that case.
https://github.com/llvm/llvm-project/pull/220876
More information about the llvm-commits
mailing list