[PATCH] D150316: [AArch64][InstCombine] Don't scalarize for bitselet instructions
Pranav Kant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 15:22:44 PDT 2023
pranavk updated this revision to Diff 521121.
pranavk edited the summary of this revision.
pranavk added a comment.
clang-format and remove print statement
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150316/new/
https://reviews.llvm.org/D150316
Files:
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -56,6 +56,29 @@
///
/// FIXME: It's possible to create more instructions than previously existed.
static bool cheapToScalarize(Value *V, Value *EI) {
+ // Pattern: or(and(a, mask), and(b, ~mask)) can be efficiently folded to
+ // bitselect instructions where ~mask = xor mask, -1
+ if (isa<Instruction>(V)) {
+ Instruction *TI = cast<Instruction>(V);
+ if (TI->getOpcode() == Instruction::Or) {
+ Value *LHS = TI->getOperand(0);
+ Value *RHS = TI->getOperand(1);
+ Value *MaskValue = nullptr;
+ Value *MaskConst = nullptr;
+
+ if (match(LHS, m_And(m_Value(), m_Value(MaskValue))) &&
+ match(RHS, m_And(m_Value(),
+ m_Xor(m_Specific(MaskValue), m_Value(MaskConst))))) {
+ if (auto *CI = dyn_cast<ConstantDataVector>(MaskConst)) {
+ Constant *C = CI->getSplatValue();
+ if (C->isAllOnesValue()) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+
ConstantInt *CEI = dyn_cast<ConstantInt>(EI);
// If we can pick a scalar constant value out of a vector, that is free.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150316.521121.patch
Type: text/x-patch
Size: 1350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230510/024f745e/attachment.bin>
More information about the llvm-commits
mailing list