Skip to content
  1. Apr 22, 2004
    • Chris Lattner's avatar
      Implement a fixme. The helps loops that have induction variables of different · dc7cc350
      Chris Lattner authored
      types in them.  Instead of creating an induction variable for all types, it
      creates a single induction variable and casts to the other sizes.  This generates
      this code:
      
      no_exit:                ; preds = %entry, %no_exit
              %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=4]
      ***     %j.0.0 = cast uint %indvar to short             ; <short> [#uses=1]
              %indvar = cast uint %indvar to int              ; <int> [#uses=1]
              %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
              store short %j.0.0, short* %tmp.7
              %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
              %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
              %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
              br bool %tmp.2, label %no_exit, label %loopexit
      
      instead of:
      
      no_exit:                ; preds = %entry, %no_exit
              %indvar = phi ushort [ %indvar.next, %no_exit ], [ 0, %entry ]          ; <ushort> [#uses=2]
      ***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
              %indvar = cast uint %indvar to int              ; <int> [#uses=1]
              %indvar = cast ushort %indvar to short          ; <short> [#uses=1]
              %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
              store short %indvar, short* %tmp.7
              %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
              %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
              %indvar.next = add uint %indvar, 1
      ***     %indvar.next = add ushort %indvar, 1
              br bool %tmp.2, label %no_exit, label %loopexit
      
      This is an improvement in register pressure, but probably doesn't happen that
      often.
      
      The more important fix will be to get rid of the redundant add.
      
      llvm-svn: 13101
      dc7cc350
  2. Apr 21, 2004
  3. Apr 20, 2004
  4. Apr 19, 2004
  5. Apr 18, 2004
  6. Apr 17, 2004
    • Chris Lattner's avatar
      If the loop executes a constant number of times, try a bit harder to replace · a8140800
      Chris Lattner authored
      exit values.
      
      llvm-svn: 13018
      a8140800
    • Chris Lattner's avatar
      Add the ability to compute trip counts that are only controlled by constants · 4021d1af
      Chris Lattner authored
      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
      4021d1af
Loading