20#include "llvm/IR/IntrinsicsHexagon.h"
51char HexagonOptimizeSZextends::ID = 0;
54 "Remove Sign and Zero Extends for Args",
false,
false)
56bool HexagonOptimizeSZextends::intrinsicAlreadySextended(Intrinsic::
ID IntID) {
58 case llvm::Intrinsic::hexagon_A2_addh_l16_sat_ll:
66bool HexagonOptimizeSZextends::runOnFunction(
Function &
F) {
74 for (
auto &Arg :
F.args()) {
75 if (
F.getAttributes().hasParamAttr(
Idx, Attribute::SExt)) {
76 if (!isa<PointerType>(Arg.getType())) {
78 if (isa<SExtInst>(U)) {
86 Use->eraseFromParent();
104 if (!(Ashr && Ashr->
getOpcode() == Instruction::AShr))
109 if (!(
C &&
C->getSExtValue() == 16))
114 if (!(Shl && Shl->
getOpcode() == Instruction::Shl))
118 C = dyn_cast<ConstantInt>(ShlOp1);
120 if (!(
C &&
C->getSExtValue() == 16))
125 if (!intrinsicAlreadySextended(
I->getIntrinsicID()))
130 const Use &TheUse = UI.getUse();
132 J->replaceUsesOfWith(Ashr,
I);
144 return new HexagonOptimizeSZextends();
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
BinaryOps getOpcode() const
This is the shared class of boolean and integer constants.
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
A wrapper class for inspecting calls to intrinsic functions.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
This class represents a sign extension of integer types.
StringRef - Represent a constant reference to a string, i.e.
A Use represents the edge between a Value definition and its users.
User * getUser() const
Returns the User that contains this Use.
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator user_begin()
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
FunctionPass * createHexagonOptimizeSZextends()
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
void initializeHexagonOptimizeSZextendsPass(PassRegistry &)
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.