Commit Graph

37 Commits

Author SHA1 Message Date
Chris Lattner 747eee2707 Don't make this require loopsimplify. It works BETTER with loop simplify
but should not require it.

llvm-svn: 21123
2005-04-06 21:45:00 +00:00
Chris Lattner adb043c2d8 Export two methods for getting -X and A-B.
llvm-svn: 20527
2005-03-09 05:34:41 +00:00
Chris Lattner 0b0f3520cb DCE a dead function
llvm-svn: 20339
2005-02-26 23:36:45 +00:00
Chris Lattner f05d2b3178 1 + 100 + 51 == 152, not 52.
If we fold three constants together (c1+c2+c3), make sure to keep
LHSC updated, instead of reusing (in this case), the 1 instead of the
partial sum.

llvm-svn: 20337
2005-02-26 18:50:19 +00:00
Chris Lattner 47555decfb Scary typo that fixes Regression/Transforms/IndVarsSimplify/2005-02-17-TruncateExprCrash.ll
and PR515.

llvm-svn: 20224
2005-02-17 16:54:16 +00:00
Chris Lattner 7b0fbe7ccf Correct the recursive PHI node handling routines in a way that CANNOT induce
infinite loops (using the new replaceSymbolicValuesWithConcrete method).

This patch reverts this patch:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050131/023830.html

... which was an attempted fix for this problem.  Unfortunately, that patch
caused test/Regression/Transforms/IndVarsSimplify/exit_value_tests.llx to fail
and slightly castrated the entire analysis.  This patch fixes it right.

This patch is dedicated to jeffc, for making me deal with this.  :)

llvm-svn: 20146
2005-02-13 04:37:18 +00:00
Chris Lattner 1230cf25ba Fix a problem where we could infinitely recurse on phi nodes.
llvm-svn: 19955
2005-02-01 00:18:30 +00:00
Reid Spencer 9083936835 For PR387:\
Make only one print method to avoid overloaded virtual warnings when \
compiled with -Woverloaded-virtual

llvm-svn: 18589
2004-12-07 04:03:45 +00:00
Chris Lattner a27dd47e7a This patch prevents an infinite recursion while compiling 103.su2cor.
All SPEC CFP 95 programs now work, though the JIT isn't loading -lf2c right
so they aren't testing correctly.

llvm-svn: 18499
2004-12-04 20:54:32 +00:00
Chris Lattner 43df507fef Patch to support MSVC, contributed by Morten Ofstad
llvm-svn: 17214
2004-10-25 18:40:08 +00:00
Chris Lattner ec901cc6cd This nutty patch has been in my tree since before 1.3 went out, and it needs
to go in.  This patch allows us to compute the trip count of loops controlled
by values loaded from constant arrays.  The cannonnical example of this is
strlen when passed a constant argument:

for (int i = 0; "constantstring"[i]; ++i) ;
return i;

In this case, it will compute that the loop executes 14 times, which means
that the exit value of i is 14.  Because of this, the loop gets DCE'd and
we are happy.  This also applies to anything that does similar things, e.g.
loops like this:

  const float Array[] = { 0.1, 2.1, 3.2, 23.21 };
  for (int i = 0; Array[i] < 20; ++i)

and is actually fairly general.

The problem with this is that it almost never triggers.  The reason is that
we run indvars and the loop optimizer only at compile time, which is before
things like strlen and strcpy have been inlined into the program from libc.
Because of this, it almost never is used (it triggers twice in specint2k).

I'm committing it because it DOES work, may be useful in the future, and
doesn't slow us down at all.  If/when we start running the loop optimizer
at link-time (-O4?) this will be very nice indeed :)

llvm-svn: 16926
2004-10-12 01:49:27 +00:00
Chris Lattner 6faf3949f6 Fix SingleSource/Benchmarks/McGill/chomp
llvm-svn: 16912
2004-10-11 04:07:27 +00:00
Alkis Evlogimenos a5c04ee50f Fixes to make LLVM compile with vc7.1.
Patch contributed by Paolo Invernizzi!

llvm-svn: 16152
2004-09-03 18:19:51 +00:00
Reid Spencer 7c16caa336 Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.

llvm-svn: 16137
2004-09-01 22:55:40 +00:00
Reid Spencer 30d69a5af9 bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass

llvm-svn: 14942
2004-07-18 00:18:30 +00:00
Chris Lattner 5e08b93a34 Remove distasteful method which is really part of the indvars pass
llvm-svn: 14359
2004-06-24 06:52:20 +00:00
Chris Lattner baaed7ee90 REALLY fix PR378: crash in scalar evolution analysis
llvm-svn: 14275
2004-06-20 20:32:16 +00:00
Chris Lattner 6bfca8f5f1 Fix a bug in my change last night that caused a few test failures.
llvm-svn: 14270
2004-06-20 17:01:44 +00:00
Chris Lattner eb3e84078d Do not sort SCEV objects by address: instead sort by complexity and group
by address.  This prevents the resultant SCEV objects from depending on
where in memory other scev objects happen to live.

llvm-svn: 14263
2004-06-20 06:23:15 +00:00
Chris Lattner 2d3a7a6ff0 Changes to fix up the inst_iterator to pass to boost iterator checks. This
patch was graciously contributed by Vladimir Prus.

llvm-svn: 13185
2004-04-27 15:13:33 +00:00
Chris Lattner 05ef97f994 Eliminate all of the SCEV Expansion code which is really part of the
IndVars pass, not part of SCEV *analysis*.

llvm-svn: 13134
2004-04-23 21:29:03 +00:00
Chris Lattner 663ebc3ec6 It's not just a printer, it's actually an analysis too
llvm-svn: 13064
2004-04-19 03:42:32 +00:00
Chris Lattner d72c3eb54e Change the ExitBlocks list from being explicitly contained in the Loop
structure to being dynamically computed on demand.  This makes updating
loop information MUCH easier.

llvm-svn: 13045
2004-04-18 22:14:10 +00:00
Chris Lattner dd73047673 Add the ability to compute exit values for complex loop using unanalyzable
operations.  This allows us to compile this testcase:

int main() {
        int h = 1;
         do h = 3 * h + 1; while (h <= 256);
        printf("%d\n", h);
        return 0;
}

into this:

int %main() {
entry:
        call void %__main( )
        %tmp.6 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([4 x sbyte]*  %.str_1, long 0, long 0), int 364 )        ; <int> [#uses=0]
        ret int 0
}

This testcase was taken directly from 256.bzip2, believe it or not.

This code is not as general as I would like.  Next up is to refactor it
a bit to handle more cases.

llvm-svn: 13019
2004-04-17 22:58:41 +00:00
Chris Lattner 4021d1af5a Add the ability to compute trip counts that are only controlled by constants
even if the loop is using expressions that we can't compute as a closed-form.
This allows us to calculate that this function always returns 55:

int test() {
  double X;
  int Count = 0;
  for (X = 100; X > 1; X = sqrt(X), ++Count)
    /*empty*/;
  return Count;
}

And allows us to compute trip counts for loops like:

        int h = 1;
         do h = 3 * h + 1; while (h <= 256);

(which occurs in bzip2), and for this function, which occurs after inlining
and other optimizations:

int popcount()
{
   int x = 666;
  int result = 0;
  while (x != 0) {
    result = result + (x & 0x1);
    x = x >> 1;
  }
  return result;
}

We still cannot compute the exit values of result or h in the two loops above,
which means we cannot delete the loop, but we are getting closer.  Being able to
compute a constant trip count for these two loops will allow us to unroll them
completely though.

llvm-svn: 13017
2004-04-17 18:36:24 +00:00
Brian Gaeke 174633b078 Include <cmath> for compatibility with gcc 3.0.x (the system compiler on
Debian.)

llvm-svn: 12986
2004-04-16 15:57:32 +00:00
Chris Lattner b4f681b42b Factor a bunch of classes out into a public header
llvm-svn: 12958
2004-04-15 15:07:24 +00:00
Chris Lattner a4e4a63856 Unbreak the build
llvm-svn: 12956
2004-04-15 14:17:43 +00:00
Chris Lattner d420fe63ea Implement a FIXME: if we're going to insert a cast, we might as well only
insert it once!

llvm-svn: 12955
2004-04-14 22:01:22 +00:00
Chris Lattner 8a9fd94cfe This is a trivial tweak to the addrec insertion code: insert the increment
at the bottom of the loop instead of the top.  This reduces the number of
overlapping live ranges a lot, for example, eliminating a spill in an important
loop in 183.equake with linear scan.

I still need to make the exit comparison of the loop use the post-incremented
version of this variable, but this is an easy first step.

llvm-svn: 12952
2004-04-14 21:11:25 +00:00
Chris Lattner 74498e1066 Fix a bug Brian found.
llvm-svn: 12754
2004-04-07 16:16:11 +00:00
Chris Lattner d4f78f270b Sparc don't got not "sqrtl", bum bum bum
llvm-svn: 12670
2004-04-05 19:05:15 +00:00
Misha Brukman 5ebc25c818 Kill warnings during an optimized compile where assert() disappears.
llvm-svn: 12669
2004-04-05 19:00:46 +00:00
Chris Lattner 29153fc2e5 Fix PR312 and IndVarsSimplify/2004-04-05-InvokeCastCrash.llx
llvm-svn: 12668
2004-04-05 18:46:55 +00:00
Chris Lattner 0defaa1cbc Add a break in the default case
llvm-svn: 12639
2004-04-03 00:43:03 +00:00
Chris Lattner 0916921332 Comment out debugging printouts
llvm-svn: 12623
2004-04-02 20:26:46 +00:00
Chris Lattner d934c70cf8 Add a new analysis
llvm-svn: 12619
2004-04-02 20:23:17 +00:00