[llvm] [GlobalISel] Fold instructions with fully-known bits to a constant. (PR #224254)
Vikash Gupta via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 03:44:20 PDT 2026
vg0204 wrote:
You’re right — #198808 does not fold a fully known result to a constant, and this shouldn’t stay a separate combine.
In SelectionDAG that fold is the last step of SimplifyDemandedBits: once the demanded bits are a subset of Known.Zero | Known.One, the node is replaced with that constant (TargetLowering.cpp). InstCombine does the same. Known bits are already a result of the walk, and the check is stronger than Known.isConstant() because only the demanded bits have to be known.
#198808 has the walk (and / or / constant shl / shr) but not that step. I’ll add it there and drop known_bits_to_constant. The and / or cases in this PR are already roots of that walk. zext / sext / trunc aren’t in the first opcode set, so I’ll enter the same walk on those opcodes and keep these tests on that path.
What are your thoughts on it @lialan , @yxsamliu , @arsenm ?
https://github.com/llvm/llvm-project/pull/224254
More information about the llvm-commits
mailing list