[llvm] [GlobalISel] Fold instructions with fully-known bits to a constant. (PR #224254)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 03:32:51 PDT 2026
================
@@ -3363,6 +3363,35 @@ bool CombinerHelper::matchRedundantAnd(MachineInstr &MI,
return false;
}
+bool CombinerHelper::matchKnownBitsToConstant(MachineInstr &MI,
+ APInt &MatchInfo) const {
+ if (!VT)
+ return false;
+
+ Register Dst = MI.getOperand(0).getReg();
+ LLT Ty = MRI.getType(Dst);
+
+ // Scalars and fixed vectors. getKnownBits intersects all lanes, so a constant
+ // vector result is necessarily a splat-constant.
+ if (!Ty.isScalar() && !Ty.isFixedVector())
+ return false;
+
+ // Don't materialize a def that already has a class/bank constraint into a
+ // constant.
+ if (!MRI.getRegClassOrRegBank(Dst).isNull())
+ return false;
----------------
arsenm wrote:
This would be fine?
https://github.com/llvm/llvm-project/pull/224254
More information about the llvm-commits
mailing list