16#ifndef LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPCOMPATIBILITYANALYSIS_H
17#define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPCOMPATIBILITYANALYSIS_H
47 using MaskType = std::uint_fast32_t;
49 constexpr static unsigned SupportedOp[] = {
50 Instruction::Add, Instruction::FAdd, Instruction::Sub, Instruction::FSub,
51 Instruction::Mul, Instruction::Shl, Instruction::AShr, Instruction::And,
52 Instruction::Or, Instruction::Xor};
54 "SupportedOp is not sorted.");
75 static std::pair<Constant *, unsigned>
77 struct InterchangeableInfo {
80 MaskType Mask = MainOpBIT | XorBIT | OrBIT | AndBIT | SubBIT | AddBIT |
81 MulBIT | AShrBIT | ShlBIT | FSubBIT | FAddBIT;
86 MaskType SeenBefore = 0;
91 bool trySet(MaskType OpcodeInMaskForm, MaskType InterchangeableMask);
92 bool equal(
unsigned Opcode) {
93 return Opcode ==
I->getOpcode() && trySet(MainOpBIT, MainOpBIT);
95 unsigned getOpcode()
const;
96 bool hasDefinedOpcode()
const {
return (Mask & SeenBefore) > 0; }
101 InterchangeableInfo MainOp;
102 InterchangeableInfo AltOp;
109 : MainOp(MainOp), AltOp(AltOp) {}
115 return MainOp.hasCandidateOpcode(Opcode);
122 return !
hasAltOp() || AltOp.hasDefinedOpcode();
125 return MainOp.getOperand(
I);
This file defines the SmallVector class.
This is an important base class in LLVM.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
SmallVector< Value * > getOperand(const Instruction *I) const
bool hasDefinedMainOpcode() const
unsigned getAltOpcode() const
bool hasDefinedAltOpcode() const
bool add(const Instruction *I)
bool hasCandidateOpcode(unsigned Opcode) const
Checks if the list of potential opcodes includes Opcode.
BinOpSameOpcodeHelper(const Instruction *MainOp, const Instruction *AltOp=nullptr)
unsigned getMainOpcode() const
A private "module" namespace for types and utilities used by this pass.
bool isValidForAlternation(unsigned Opcode)
This is an optimization pass for GlobalISel generic memory operations.
@ LLVM_MARK_AS_BITMASK_ENUM
constexpr bool is_sorted_constexpr(R &&Range, Cmp C=Cmp{})
Check if elements in a range R are sorted with respect to a comparator C.
bool equal(L &&LRange, R &&RRange)
Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.