@@ -820,10 +820,8 @@ namespace {
820
820
/// The class maintains a reference to the main instruction (MainOp) and
821
821
/// provides methods to:
822
822
/// - Check if another instruction is interchangeable (isSame)
823
- /// - Get the opcode for the interchangeable form
824
- /// (getInterchangeableInstructionOpcode)
825
- /// - Get the operands for the interchangeable form
826
- /// (getInterchangeableInstructionOps)
823
+ /// - Get the opcode for the interchangeable form (getOpcode)
824
+ /// - Get the operands for the interchangeable form (getOperand)
827
825
class InterchangeableInstruction {
828
826
protected:
829
827
Instruction *const MainOp;
@@ -833,11 +831,8 @@ class InterchangeableInstruction {
833
831
virtual bool isSame(Instruction *I) {
834
832
return MainOp->getOpcode() == I->getOpcode();
835
833
}
836
- virtual unsigned getInterchangeableInstructionOpcode() {
837
- return MainOp->getOpcode();
838
- }
839
- virtual SmallVector<Value *>
840
- getInterchangeableInstructionOps(Instruction *I) {
834
+ virtual unsigned getOpcode() { return MainOp->getOpcode(); }
835
+ virtual SmallVector<Value *> getOperand(Instruction *I) {
841
836
assert(MainOp->getOpcode() == I->getOpcode());
842
837
return SmallVector<Value *>(MainOp->operands());
843
838
}
@@ -939,7 +934,7 @@ class InterchangeableBinOp final : public InterchangeableInstruction {
939
934
}
940
935
return tryAnd(opcodeToMask(Opcode));
941
936
}
942
- unsigned getInterchangeableInstructionOpcode () override {
937
+ unsigned getOpcode () override {
943
938
MaskType Candidate = Mask & SeenBefore;
944
939
if (Candidate & 0b1)
945
940
return Instruction::Shl;
@@ -959,8 +954,7 @@ class InterchangeableBinOp final : public InterchangeableInstruction {
959
954
return Instruction::Xor;
960
955
llvm_unreachable("Cannot find interchangeable instruction.");
961
956
}
962
- SmallVector<Value *>
963
- getInterchangeableInstructionOps(Instruction *I) override {
957
+ SmallVector<Value *> getOperand(Instruction *I) override {
964
958
unsigned ToOpcode = I->getOpcode();
965
959
assert(binary_search(SupportedOp, ToOpcode) && "Unsupported opcode.");
966
960
unsigned FromOpcode = MainOp->getOpcode();
@@ -1069,12 +1063,11 @@ convertTo(Instruction *I, Instruction *MainOp, Instruction *AltOp) {
1069
1063
getInterchangeableInstruction(I));
1070
1064
for (std::unique_ptr<InterchangeableInstruction> &C : Candidate)
1071
1065
if (C->isSame(I) && C->isSame(MainOp))
1072
- return std::make_pair(MainOp,
1073
- C->getInterchangeableInstructionOps(MainOp));
1066
+ return std::make_pair(MainOp, C->getOperand(MainOp));
1074
1067
Candidate = getInterchangeableInstruction(I);
1075
1068
for (std::unique_ptr<InterchangeableInstruction> &C : Candidate)
1076
1069
if (C->isSame(I) && C->isSame(AltOp))
1077
- return std::make_pair(AltOp, C->getInterchangeableInstructionOps (AltOp));
1070
+ return std::make_pair(AltOp, C->getOperand (AltOp));
1078
1071
llvm_unreachable("Cannot convert the instruction.");
1079
1072
}
1080
1073
@@ -1366,8 +1359,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
1366
1359
[&](ArrayRef<std::unique_ptr<InterchangeableInstruction>> Candidate) {
1367
1360
for (const std::unique_ptr<InterchangeableInstruction> &I :
1368
1361
Candidate) {
1369
- unsigned InterchangeableInstructionOpcode =
1370
- I->getInterchangeableInstructionOpcode();
1362
+ unsigned InterchangeableInstructionOpcode = I->getOpcode();
1371
1363
for (Value *V : VL) {
1372
1364
if (isa<PoisonValue>(V))
1373
1365
continue;
0 commit comments