20#include "llvm/IR/IntrinsicsHexagon.h"
44char HexagonOptimizeSZextends::ID = 0;
47 "Remove Sign and Zero Extends for Args",
false,
false)
49bool HexagonOptimizeSZextends::intrinsicAlreadySextended(Intrinsic::
ID IntID) {
51 case llvm::Intrinsic::hexagon_A2_addh_l16_sat_ll:
59bool HexagonOptimizeSZextends::runOnFunction(
Function &
F) {
67 for (
auto &Arg :
F.args()) {
68 if (
F.getAttributes().hasParamAttr(
Idx, Attribute::SExt)) {
69 if (!isa<PointerType>(Arg.getType())) {
71 if (isa<SExtInst>(U)) {
79 Use->eraseFromParent();
97 if (!(Ashr && Ashr->
getOpcode() == Instruction::AShr))
102 if (!(
C &&
C->getSExtValue() == 16))
107 if (!(Shl && Shl->
getOpcode() == Instruction::Shl))
111 C = dyn_cast<ConstantInt>(ShlOp1);
113 if (!(
C &&
C->getSExtValue() == 16))
118 if (!intrinsicAlreadySextended(
I->getIntrinsicID()))
123 const Use &TheUse = UI.getUse();
125 J->replaceUsesOfWith(Ashr,
I);
137 return new HexagonOptimizeSZextends();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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)
Represent the analysis usage information of a pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
InstListType::iterator iterator
Instruction iterators...
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.
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()
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
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.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.