20 #include "llvm/IR/IntrinsicsHexagon.h" 40 StringRef getPassName()
const override {
return "Remove sign extends"; }
54 "Remove Sign and Zero Extends for Args",
false,
false)
56 bool HexagonOptimizeSZextends::intrinsicAlreadySextended(Intrinsic::
ID IntID) {
58 case llvm::Intrinsic::hexagon_A2_addh_l16_sat_ll:
74 for (
auto &
Arg :
F.args()) {
75 if (
F.getAttributes().hasAttribute(Idx, Attribute::SExt)) {
76 if (!isa<PointerType>(
Arg.getType())) {
77 for (
auto UI =
Arg.use_begin(); UI !=
Arg.use_end();) {
78 if (isa<SExtInst>(*UI)) {
86 SI->insertBefore(First);
87 Use->eraseFromParent();
107 if (!(Ashr && Ashr->
getOpcode() == Instruction::AShr))
112 if (!(
C &&
C->getSExtValue() == 16))
117 if (!(Shl && Shl->
getOpcode() == Instruction::Shl))
121 C = dyn_cast<ConstantInt>(ShlOp1);
123 if (!(
C &&
C->getSExtValue() == 16))
128 if (!intrinsicAlreadySextended(
I->getIntrinsicID()))
133 const Use &TheUse = UI.getUse();
135 J->replaceUsesOfWith(Ashr,
I);
147 return new HexagonOptimizeSZextends();
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
INITIALIZE_PASS(HexagonOptimizeSZextends, "reargs", "Remove Sign and Zero Extends for Args", false, false) bool HexagonOptimizeSZextends
This class represents lattice values for constants.
BinaryOps getOpcode() const
This class represents a sign extension of integer types.
FunctionPass * createHexagonOptimizeSZextends()
A Use represents the edge between a Value definition and its users.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Type * getType() const
All values are typed, get the type of this value.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Value * getOperand(unsigned i) const
static bool runOnFunction(Function &F, bool PostInlining)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void initializeHexagonOptimizeSZextendsPass(PassRegistry &)
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
User * getUser() const
Returns the User that contains this Use.
This is the shared class of boolean and integer constants.
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
A wrapper class for inspecting calls to intrinsic functions.