Skip to content

Commit c573e92

Browse files
committed
add const to isSame
1 parent 3cedcd4 commit c573e92

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ class InterchangeableInstruction {
828828

829829
public:
830830
InterchangeableInstruction(Instruction *MainOp) : MainOp(MainOp) {}
831-
virtual bool isSame(Instruction *I) {
831+
virtual bool isSame(Instruction *I) const {
832832
return MainOp->getOpcode() == I->getOpcode();
833833
}
834834
virtual unsigned getOpcode() const { return MainOp->getOpcode(); }
@@ -857,13 +857,13 @@ class InterchangeableBinOp final : public InterchangeableInstruction {
857857
Xor_BIT = 0b10000000,
858858
};
859859
// The bit it sets represents whether MainOp can be converted to.
860-
MaskType Mask = Xor_BIT | Or_BIT | And_BIT | Sub_BIT | Add_BIT | Mul_BIT |
861-
AShr_BIT | SHL_BIT;
860+
mutable MaskType Mask = Xor_BIT | Or_BIT | And_BIT | Sub_BIT | Add_BIT |
861+
Mul_BIT | AShr_BIT | SHL_BIT;
862862
// We cannot create an interchangeable instruction that does not exist in VL.
863863
// For example, VL [x + 0, y * 1] can be converted to [x << 0, y << 0], but
864864
// 'shl' does not exist in VL. In the end, we convert VL to [x * 1, y * 1].
865865
// SeenBefore is used to know what operations have been seen before.
866-
MaskType SeenBefore = 0;
866+
mutable MaskType SeenBefore = 0;
867867

868868
/// Return a non-nullptr if either operand of I is a ConstantInt.
869869
static std::pair<ConstantInt *, unsigned>
@@ -910,7 +910,7 @@ class InterchangeableBinOp final : public InterchangeableInstruction {
910910
llvm_unreachable("Unsupported opcode.");
911911
}
912912

913-
bool tryAnd(MaskType X) {
913+
bool tryAnd(MaskType X) const {
914914
if (Mask & X) {
915915
Mask &= X;
916916
return true;
@@ -920,7 +920,7 @@ class InterchangeableBinOp final : public InterchangeableInstruction {
920920

921921
public:
922922
using InterchangeableInstruction::InterchangeableInstruction;
923-
bool isSame(Instruction *I) override {
923+
bool isSame(Instruction *I) const override {
924924
unsigned Opcode = I->getOpcode();
925925
if (!binary_search(SupportedOp, Opcode))
926926
return false;

0 commit comments

Comments
 (0)