[llvm] [SLP] Make getSameOpcode support interchangeable instructions. (PR #127450)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 5 11:10:01 PST 2025
================
@@ -1085,6 +1358,25 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
return InstructionsState::invalid();
}
+ if (IsBinOp) {
+ auto FindOp =
+ [&](const InterchangeableBinOp &Converter) {
+ unsigned InterchangeableInstructionOpcode = Converter.getOpcode();
+ for (Value *V : VL) {
+ if (isa<PoisonValue>(V))
+ continue;
+ auto *Inst = cast<Instruction>(V);
+ if (Inst->getOpcode() == InterchangeableInstructionOpcode)
+ return Inst;
+ }
+ llvm_unreachable(
+ "Cannot find the candidate instruction for InstructionsState.");
+ };
+ MainOp = FindOp(InterchangeableConverter);
+ AltOp = AlternateInterchangeableConverter
+ ? FindOp(*AlternateInterchangeableConverter)
+ : MainOp;
+ }
----------------
alexey-bataev wrote:
Maybe create a new function for it , separate from getSameOpcode?
https://github.com/llvm/llvm-project/pull/127450
More information about the llvm-commits
mailing list