[llvm] [AArch64][GlobalISel] Add lowering for constant BIT/BIF/BSP (PR #65897)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 10 07:55:51 PDT 2023
================
@@ -338,6 +338,50 @@ void applySplitStoreZero128(MachineInstr &MI, MachineRegisterInfo &MRI,
Store.eraseFromParent();
}
+bool matchOrToBSP(MachineInstr &MI, MachineRegisterInfo &MRI,
+ std::tuple<Register, Register, Register> &MatchInfo) {
+ const LLT DstTy = MRI.getType(MI.getOperand(0).getReg());
+ if (!DstTy.isVector())
+ return false;
+
+ MachineInstr *LHS =
+ getOpcodeDef(TargetOpcode::G_AND, MI.getOperand(1).getReg(), MRI);
+ MachineInstr *RHS =
+ getOpcodeDef(TargetOpcode::G_AND, MI.getOperand(2).getReg(), MRI);
+ if (!LHS || !RHS)
+ return false;
+
+ auto *BV1 = getOpcodeDef<GBuildVector>(LHS->getOperand(2).getReg(), MRI);
+ auto *BV2 = getOpcodeDef<GBuildVector>(RHS->getOperand(2).getReg(), MRI);
+ if (!BV1 || !BV2)
+ return false;
+
+ for (int k = 0; k < DstTy.getNumElements(); k++) {
+ auto ValAndVReg1 = getIConstantVRegValWithLookThrough(
+ BV1->getOperand(k + 1).getReg(), MRI);
----------------
aemerson wrote:
You can use `GBuildVector::getSourceReg(k)`.
https://github.com/llvm/llvm-project/pull/65897
More information about the llvm-commits
mailing list