[llvm] [InstCombine] Lower flag check pattern to use a bitmask-shift (PR #169557)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 13 12:46:30 PST 2026
================
@@ -2410,6 +2410,64 @@ Value *InstCombinerImpl::reassociateBooleanAndOr(Value *LHS, Value *X, Value *Y,
return nullptr;
}
+static Value *combineAndOrOfImmCmpToBitExtract(Instruction &Or,
+ InstCombiner::BuilderTy &Builder,
+ const DataLayout &DL) {
+ // Currently only support scalars
+ if (Or.getType()->isVectorTy())
+ return nullptr;
+
+ ConstantComparesGatherer ConstantCompare(&Or, DL, /*OneUse=*/true);
+ // Unpack the result
+ SmallVectorImpl<ConstantInt *> &Values = ConstantCompare.Vals;
+ Value *Index = ConstantCompare.CompValue;
+
+ // TODO: Handle ConstantCompare.Extra case
+ // If expanding an existing case, only adding one extra case is still good
+ if (!Index || !isGuaranteedNotToBeUndefOrPoison(Index) ||
----------------
bababuck wrote:
I think that's correct, but I think it just needs to be softened to `isGuarateedNotToBeUndefOrPoison()`, since if `Index` is `undef`, it can cause `poison` in the shift operation. See https://alive2.llvm.org/ce/z/7qXpr5
https://github.com/llvm/llvm-project/pull/169557
More information about the llvm-commits
mailing list