immediate number test in llvm

In LLVM, I'd like to test whether the trip count obtained by LoopInfo pass is an immediate number. For example, the following loop

for(i=0; i<10; i++) { ... }

has a trip count of 10, and it's an immediate number. The member function getTripCount() of Loop can be called to get a Value representing the trip count. How can I decide this value is an immediate number or not?

--------------Solutions-------------

Use the following getter provided by the Scalar Evolution analysis:

unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock)

/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
/// normal unsigned value. Returns 0 if the trip count is unknown or not
/// constant. Will also return 0 if the maximum trip count is very large (>=
/// 2^32).
///
/// This "trip count" assumes that control exits via ExitingBlock. More
/// precisely, it is the number of times that control may reach ExitingBlock
/// before taking the branch. For loops with multiple exits, it may not be the
/// number times that the loop header executes because the loop may exit
/// prematurely via another branch.

Category:optimization Time:2011-04-27 Views:1

Related post

  • Creating a call instruction using the IRBuilder to have variable number of arguments - llvm 2.8 2011-12-03

    I am trying to create a Call Instruction using the llvm IRBuilder as below llvm::Value* FunctionCall::genLLVM(GenLLVM* g){ std::vector<llvm::Value*> paramArrayRef; std::list<Value*> paramList = getParamList(); std::list<Value*>::ite

  • Strengths and weaknesses of JIT compilers for Python 2010-05-29

    I'm currently aware of the following Python JIT compilers: Psyco, PyPy and Unladen Swallow. Basically, I'd like to ask for your personal experiences on the strengths and weaknesses of these compilers - and if there are any others worth looking into.

  • Adding a function in LLVM (haskell bindings) when the number of parameters is not known at compile time 2011-06-23

    Background: I have written a toy Lisp interpreter that I am trying to add LLVM JIT functionality to. For the moment, have imposed the following limitations: Only integer values are allowed in functions Variables may only reference formal parameters G

  • -[NSDate timeIntervalSinceDate:] returns very small number on GCC 4.2, but works as expected on LLVM-GCC 4.2 on iOS4.3 Simulator 2011-08-02

    On iOS 4.3 Simulator, the following code returns a very small number: 1e-700 on GCC 4.2, but works as expected on LLVM-GCC 4.2. Any ideas? NSDate *selectedDate = self.datepicker.date; // guaranteed to be before now NSTimeInterval interval = [nowDate

  • LLVM type cast fails for the types having in total differnt number of bits 2012-05-02

    I try to perform casting in LLVm using BitCastInst and iType = dyn_cast<Type>(VectorType::get(iType, eleCount)); My question : is it possible to cast from vector type with 3 elemnts of Int16Ty to vector type having 1 lement of 64 bit(Int64Ty) (

  • What are the differences between LLVM and java bytecode? 2009-01-18

    I dont understand the difference between LLVM and the java (bytecode), what are they? -edit- by 'what are they' i mean the differences between LLVM and java (bytecode) not what are LLVM and java. --------------Solutions------------- Assuming you mean

  • Questions for compiling to LLVM 2009-04-09

    I've been playing around with LLVM hoping to learn how to use it. However, my mind is boggled by the level of complexity of the interface. Take for example their Fibonacci function int fib(int x) { if(x<=2) return 1; return fib(x-1) + fib(x-2); }

  • Retain a random number across different functions in Cocoa? 2009-06-29

    I know how to do a global variable, but whenever I try to define a global variable with a random number function, xcode says "initializer element is not constant." The compiler doesn't want to make a variable from a random number because the random n

  • How can I implement a string data type in LLVM? 2009-06-30

    I have been looking at LLVM lately, and I find it to be quite an interesting architecture. However, looking through the tutorial and the reference material, I can't see any examples of how I might implement a string data type. There is a lot of docum

  • -forwardInvocation works with Clang - LLVM but not with GCC 2009-09-20

    The following code implements an NSProxy subclass which forwards methods to an NSNumber instance. However when calling [nsproxy floatValue] I get 0.0 under GCC 4.2. Under LLVM-Clang I get the correct answer 42.0. Any idea what is going on? (by the wa

  • How to detect LLVM and its version through #define directives? 2009-10-24

    The question is quite clear I think. I'm trying to write a compiler detection header to be able to include in the application information on which compiler was used and which version. This is part of the code I'm using: /* GNU C Compiler Detection */

  • Why isn't there a good scheme/lisp on llvm? 2010-01-26

    There is Gambit Scheme, MIT Scheme, PLT Scheme, Chicken Scheme, Bigloo, Larceny, ...; then there are all the lisps. Yet, there's not (to my knowledge) a single popular scheme/lisp on LLVM, even though LLVM provides lots of nice things like: easier to

  • What exactly is LLVM? 2010-03-01

    I keep hearing about LLVM all the time. It's in Perl, then it's in Haskell, then someone uses it in some other language? What is it? --------------Solutions------------- LLVM is a library that is used to construct, optimize and produce intermediate a

  • c++ g++ llvm-clang compiler profiling 2010-03-30

    Note, my question is not: how do I tell my compiler to compile with profiling on. I want to profile my compiles process. For each file, I'd like to know how much time is spent on each line of the program. I'm working on a project, some files have hug

  • Curious: Could LLVM be used for Infocom z-machine code, and if so how? (in general) 2010-04-17

    Forgive me if this is a silly question, but I'm wondering if/how LLVM could be used to obtain a higher performance Z-Machine VM for interactive fiction. (If it could be used, I'm just looking for some high-level ideas or suggestions, not a detailed s

  • Linking LLVM JIT Code to Static LLVM Libraries? 2010-05-10

    I'm in the process of implementing a cross-platform (Mac OS X, Windows, and Linux) application which will do lots of CPU intensive analysis of financial data. The bulk of the analysis engine will be written in C++ for speed reasons, with a user-acces

  • Error trying to link c++ code using llvm 4.2.1 2010-09-09

    I am trying to convert some gpl code(not mine!) from C++ to C so I can use it in a c-only project. I read about llvm and got excited but I am running into a linker error that I have no idea how to fix: the error is: Intrinsic prototype has incorrect

  • LLVM Compiler 2.0: Warning with "using namespace std;" 2010-10-17

    In Xcode using LLVM 2.0, when I put the line using namespace std; in my C++ code, I get this warning: Semantic Issue Using directive refers to implicitly-defined namespace 'std' Is there a way to fix this? Why is it giving that warning? -------------

  • LLVM - Can I access variables in my instruction format from e.g. the delay slot filler? 2010-11-29

    I'm working on an llvm back-end and I'm currently trying to get delay slots working correctly. The number of slots varies for 0-3, and the easiest - and for me most logical - way to specify this is adding a variable numDelaySlots to the instruction f

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.745 (s). 13 q(s)