Skip to content
  1. Oct 18, 2004
  2. Oct 17, 2004
  3. Oct 16, 2004
  4. Oct 13, 2004
  5. Oct 12, 2004
  6. Oct 11, 2004
  7. Oct 09, 2004
  8. Oct 08, 2004
  9. Oct 06, 2004
  10. Sep 29, 2004
  11. Sep 28, 2004
    • Chris Lattner's avatar
      Fold (and (setcc X, C1), (setcc X, C2)) · 623826c8
      Chris Lattner authored
      This is important for several reasons:
      
      1. Benchmarks have lots of code that looks like this (perlbmk in particular):
      
        %tmp.2.i = setne int %tmp.0.i, 128              ; <bool> [#uses=1]
        %tmp.6343 = seteq int %tmp.0.i, 1               ; <bool> [#uses=1]
        %tmp.63 = and bool %tmp.2.i, %tmp.6343          ; <bool> [#uses=1]
      
         we now fold away the setne, a clear improvement.
      
      2. In the more important cases, such as (X >= 10) & (X < 20), we now produce
         smaller code: (X-10) < 10.
      
      3. Perhaps the nicest effect of this patch is that it really helps out the
         code generators.  In particular, for a 'range test' like the above,
         instead of generating this on X86 (the difference on PPC is even more
         pronounced):
      
              cmp %EAX, 50
              setge %CL
              cmp %EAX, 100
              setl %AL
              and %CL, %AL
              cmp %CL, 0
      
         we now generate this:
      
              add %EAX, -50
              cmp %EAX, 50
      
         Furthermore, this causes setcc's to be folded into branches more often.
      
      These combinations trigger dozens of times in the spec benchmarks, particularly
      in 176.gcc, 186.crafty, 253.perlbmk, 254.gap, & 099.go.
      
      llvm-svn: 16559
      623826c8
    • Chris Lattner's avatar
      Implement X / C1 / C2 folding · 272d5ca9
      Chris Lattner authored
      Implement (setcc (shl X, C1), C2) folding.
      
      The second one occurs several dozen times in spec.  The first was added
      just in case.  :)
      
      These are tested by shift.ll:test2[12], and div.ll:test5
      
      llvm-svn: 16549
      272d5ca9
    • Chris Lattner's avatar
      shl is always zero extending, so always use a zero extending shift right. · 6afc02f8
      Chris Lattner authored
      This latent bug was exposed by recent changes, and is tested as:
      llvm/test/Regression/Transforms/InstCombine/2004-09-28-BadShiftAndSetCC.llx
      
      llvm-svn: 16546
      6afc02f8
    • Alkis Evlogimenos's avatar
      Pull assignment out of for loop conditional in order for this to · 3ce42ec7
      Alkis Evlogimenos authored
      compile under windows. Patch contributed by Paolo Invernizzi!
      
      llvm-svn: 16534
      3ce42ec7
  12. Sep 27, 2004
  13. Sep 24, 2004
  14. Sep 23, 2004
  15. Sep 21, 2004
    • Chris Lattner's avatar
      Do not fold (X + C1 != C2) if there are other users of the add. Doing · b121ae1c
      Chris Lattner authored
      this transformation used to take a loop like this:
      
      int Array[1000];
      void test(int X) {
        int i;
        for (i = 0; i < 1000; ++i)
          Array[i] += X;
      }
      
      Compiled to LLVM is:
      
      no_exit:                ; preds = %entry, %no_exit
              %indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ]            ; <uint> [#uses=2]
              %tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar                ; <int*> [#uses=2]
              %tmp.7 = load int* %tmp.4               ; <int> [#uses=1]
              %tmp.9 = add int %tmp.7, %X             ; <int> [#uses=1]
              store int %tmp.9, int* %tmp.4
      ***     %indvar.next = add uint %indvar, 1              ; <uint> [#uses=2]
      ***     %exitcond = seteq uint %indvar.next, 1000               ; <bool> [#uses=1]
              br bool %exitcond, label %return, label %no_exit
      
      and turn it into a loop like this:
      
      no_exit:                ; preds = %entry, %no_exit
              %indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ]            ; <uint> [#uses=3]
              %tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar                ; <int*> [#uses=2]
              %tmp.7 = load int* %tmp.4               ; <int> [#uses=1]
              %tmp.9 = add int %tmp.7, %X             ; <int> [#uses=1]
              store int %tmp.9, int* %tmp.4
      ***     %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
      ***     %exitcond = seteq uint %indvar, 999             ; <bool> [#uses=1]
              br bool %exitcond, label %return, label %no_exit
      
      Note that indvar.next and indvar can no longer be coallesced.  In machine
      code terms, this patch changes this code:
      
      .LBBtest_1:     # no_exit
              mov %EDX, OFFSET Array
              mov %ESI, %EAX
              add %ESI, DWORD PTR [%EDX + 4*%ECX]
              mov %EDX, OFFSET Array
              mov DWORD PTR [%EDX + 4*%ECX], %ESI
              mov %EDX, %ECX
              inc %EDX
              cmp %ECX, 999
              mov %ECX, %EDX
              jne .LBBtest_1  # no_exit
      
      into this:
      
      .LBBtest_1:     # no_exit
              mov %EDX, OFFSET Array
              mov %ESI, %EAX
              add %ESI, DWORD PTR [%EDX + 4*%ECX]
              mov %EDX, OFFSET Array
              mov DWORD PTR [%EDX + 4*%ECX], %ESI
              inc %ECX
              cmp %ECX, 1000
              jne .LBBtest_1  # no_exit
      
      We need better instruction selection to get this:
      
      .LBBtest_1:     # no_exit
              add DWORD PTR [Array + 4*%ECX], EAX
              inc %ECX
              cmp %ECX, 1000
              jne .LBBtest_1  # no_exit
      
      ... but at least there is less register juggling
      
      llvm-svn: 16473
      b121ae1c
  16. Sep 20, 2004
Loading