Skip to content
  1. May 14, 2014
  2. May 09, 2014
    • Louis Gerbarg's avatar
      Add ExtractValue instruction to SimplifyCFG's ComputeSpeculationCost · 1f54b821
      Louis Gerbarg authored
      Since ExtractValue is not included in ComputeSpeculationCost CFGs containing
      ExtractValueInsts cannot be simplified. In particular this interacts with
      InstCombineCompare's tendency to insert add.with.overflow intrinsics for
      certain idiomatic math operations, preventing optimization.
      
      This patch adds ExtractValue to the ComputeSpeculationCost. Test case included
      
      rdar://14853450
      
      llvm-svn: 208434
      1f54b821
  3. Apr 25, 2014
  4. Apr 22, 2014
    • Chandler Carruth's avatar
      [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE · 964daaaf
      Chandler Carruth authored
      definition below all of the header #include lines, lib/Transforms/...
      edition.
      
      This one is tricky for two reasons. We again have a couple of passes
      that define something else before the includes as well. I've sunk their
      name macros with the DEBUG_TYPE.
      
      Also, InstCombine contains headers that need DEBUG_TYPE, so now those
      headers #define and #undef DEBUG_TYPE around their code, leaving them
      well formed modular headers. Fixing these headers was a large motivation
      for all of these changes, as "leaky" macros of this form are hard on the
      modules implementation.
      
      llvm-svn: 206844
      964daaaf
  5. Mar 12, 2014
    • Hans Wennborg's avatar
      Allow switch-to-lookup table for tables with holes by adding bitmask check · b73c0b04
      Hans Wennborg authored
      This allows us to generate table lookups for code such as:
      
        unsigned test(unsigned x) {
          switch (x) {
            case 100: return 0;
            case 101: return 1;
            case 103: return 2;
            case 105: return 3;
            case 107: return 4;
            case 109: return 5;
            case 110: return 6;
            default: return f(x);
          }
        }
      
      Since cases 102, 104, etc. are not constants, the lookup table has holes
      in those positions. We therefore guard the table lookup with a bitmask check.
      
      Patch by Jasper Neumann!
      
      llvm-svn: 203694
      b73c0b04
  6. Mar 09, 2014
    • Benjamin Kramer's avatar
      SimplifyCFG: Simplify the weight scaling algorithm. · 79da941f
      Benjamin Kramer authored
      No change in functionality.
      
      llvm-svn: 203413
      79da941f
    • Chandler Carruth's avatar
      [C++11] Add range based accessors for the Use-Def chain of a Value. · cdf47884
      Chandler Carruth authored
      This requires a number of steps.
      1) Move value_use_iterator into the Value class as an implementation
         detail
      2) Change it to actually be a *Use* iterator rather than a *User*
         iterator.
      3) Add an adaptor which is a User iterator that always looks through the
         Use to the User.
      4) Wrap these in Value::use_iterator and Value::user_iterator typedefs.
      5) Add the range adaptors as Value::uses() and Value::users().
      6) Update *all* of the callers to correctly distinguish between whether
         they wanted a use_iterator (and to explicitly dig out the User when
         needed), or a user_iterator which makes the Use itself totally
         opaque.
      
      Because #6 requires churning essentially everything that walked the
      Use-Def chains, I went ahead and added all of the range adaptors and
      switched them to range-based loops where appropriate. Also because the
      renaming requires at least churning every line of code, it didn't make
      any sense to split these up into multiple commits -- all of which would
      touch all of the same lies of code.
      
      The result is still not quite optimal. The Value::use_iterator is a nice
      regular iterator, but Value::user_iterator is an iterator over User*s
      rather than over the User objects themselves. As a consequence, it fits
      a bit awkwardly into the range-based world and it has the weird
      extra-dereferencing 'operator->' that so many of our iterators have.
      I think this could be fixed by providing something which transforms
      a range of T&s into a range of T*s, but that *can* be separated into
      another patch, and it isn't yet 100% clear whether this is the right
      move.
      
      However, this change gets us most of the benefit and cleans up
      a substantial amount of code around Use and User. =]
      
      llvm-svn: 203364
      cdf47884
  7. Mar 04, 2014
  8. Mar 02, 2014
  9. Feb 21, 2014
    • Rafael Espindola's avatar
      Rename many DataLayout variables from TD to DL. · 37dc9e19
      Rafael Espindola authored
      I am really sorry for the noise, but the current state where some parts of the
      code use TD (from the old name: TargetData) and other parts use DL makes it
      hard to write a patch that changes where those variables come from and how
      they are passed along.
      
      llvm-svn: 201827
      37dc9e19
  10. Jan 28, 2014
    • Rafael Espindola's avatar
      Fix pr14893. · ab73c493
      Rafael Espindola authored
      When simplifycfg moves an instruction, it must drop metadata it doesn't know
      is still valid with the preconditions changes. In particular, it must drop
      the range and tbaa metadata.
      
      The patch implements this with an utility function to drop all metadata not
      in a white list.
      
      llvm-svn: 200322
      ab73c493
    • Manman Ren's avatar
      PGO branch weight: keep halving the weights until they can fit into · f1cb16e4
      Manman Ren authored
      uint32.
      
      When folding branches to common destination, the updated branch weights
      can exceed uint32 by more than factor of 2. We should keep halving the
      weights until they can fit into uint32.
      
      llvm-svn: 200262
      f1cb16e4
  11. Jan 24, 2014
    • Alp Toker's avatar
      Fix known typos · cb402911
      Alp Toker authored
      Sweep the codebase for common typos. Includes some changes to visible function
      names that were misspelt.
      
      llvm-svn: 200018
      cb402911
  12. Jan 15, 2014
    • Hans Wennborg's avatar
      Switch-to-lookup tables: set threshold to 3 cases · 4744ac17
      Hans Wennborg authored
      There has been an old FIXME to find the right cut-off for when it's worth
      analyzing and potentially transforming a switch to a lookup table.
      
      The switches always have two or more cases. I could not measure any speed-up
      by transforming a switch with two cases. A switch with three cases gets a nice
      speed-up, and I couldn't measure any compile-time regression, so I think this
      is the right threshold.
      
      In a Clang self-host, this causes 480 new switches to be transformed,
      and reduces the final binary size with 8 KB.
      
      llvm-svn: 199294
      4744ac17
  13. Jan 12, 2014
    • Hans Wennborg's avatar
      Switch-to-lookup tables: Don't require a result for the default · ac114a3c
      Hans Wennborg authored
      case when the lookup table doesn't have any holes.
      
      This means we can build a lookup table for switches like this:
      
        switch (x) {
          case 0: return 1;
          case 1: return 2;
          case 2: return 3;
          case 3: return 4;
          default: exit(1);
        }
      
      The default case doesn't yield a constant result here, but that doesn't matter,
      since a default result is only necessary for filling holes in the lookup table,
      and this table doesn't have any holes.
      
      This makes us transform 505 more switches in a clang bootstrap, and shaves 164 KB
      off the resulting clang binary.
      
      llvm-svn: 199025
      ac114a3c
  14. Dec 20, 2013
  15. Nov 12, 2013
    • Nadav Rotem's avatar
      FoldBranchToCommonDest merges branches into a single branch with or/and of the... · 53d32211
      Nadav Rotem authored
      FoldBranchToCommonDest merges branches into a single branch with or/and of the condition. It has a heuristics for estimating when some of the dependencies are processed by out-of-order processors. This patch adds another rule to the heuristics that says that if the "BonusInstruction" that we speculatively execute is used by the condition of the second branch then it is okay to hoist it. This change exposes more opportunities for other passes to transform the code. It does not matter that much that we if-convert the code because the selectiondag builder splits or/and branches into multiple branches when profitable.
      
      llvm-svn: 194524
      53d32211
    • Benjamin Kramer's avatar
      SimplifyCFG: Use existing constant folding logic when forming switch tables. · 7c30260a
      Benjamin Kramer authored
      Both simpler and more powerful than the hand-rolled folding logic.
      
      llvm-svn: 194475
      7c30260a
  16. Nov 10, 2013
    • Nadav Rotem's avatar
      SimplifyCFG has a heuristics for out-of-order processors that decides when it... · 5ba1c6ce
      Nadav Rotem authored
      SimplifyCFG has a heuristics for out-of-order processors that decides when it is worthwhile to merge branches. It tries to estimate if the operands of the instruction that we want to hoist are ready. This commit marks function arguments as 'ready' because they require no calculation. This boosts libquantum and a few other workloads from the testsuite.
        
      
      llvm-svn: 194346
      5ba1c6ce
  17. Oct 21, 2013
  18. Oct 20, 2013
    • Michael Gottesman's avatar
      Teach simplify-cfg how to correctly create covered lookup tables for switches on iN with N >= 3. · c024f325
      Michael Gottesman authored
      One optimization simplify-cfg performs is the converting of switches to
      lookup tables if the switch has > 4 cases. This is done by:
      
      1. Finding the max/min case value and calculating the switch case range.
      2. Create a lookup table basic block.
      3. Perform a check in the switch's BB to see if the input value is in
      the switch's case range. If the input value satisfies said predicate
      branch to the lookup table BB, otherwise branch to the switch's default
      destination BB using the default value as the result.
      
      The conditional check consists of subtracting the min case value of the
      table from any input iN value and then ensuring that said value is
      unsigned less than the size of the lookup table represented as an iN
      value.
      
      If the lookup table is a covered lookup table, the size of the table will be N
      which is 0 as an iN value. Thus the comparison will be an `icmp ult` of an iN
      value against 0 which is always false yielding the incorrect result.
      
      This patch fixes this problem by recognizing if we have a covered lookup table
      and if we do, unconditionally jumps to the lookup table BB since the covering
      property of the lookup table implies no input values could not be handled by
      said BB.
      
      rdar://15268442
      
      llvm-svn: 193045
      c024f325
  19. Sep 22, 2013
  20. Sep 06, 2013
  21. Aug 06, 2013
  22. Aug 02, 2013
  23. Jul 29, 2013
  24. Jul 27, 2013
  25. Jul 14, 2013
  26. Jul 04, 2013
  27. Jun 04, 2013
    • Rafael Espindola's avatar
      Second part of pr16069 · a5e536ab
      Rafael Espindola authored
      The problem this time seems to be a thinko. We were assuming that in the CFG
      
      A
      | \
      |  B
      | /
      C
      
      speculating the basic block B would cause only the phi value for the B->C edge
      to be speculated. That is not true, the phi's are semantically in the edges, so
      if the A->B->C path is taken, any code needed for A->C is not executed and we
      have to consider it too when deciding to speculate B.
      
      llvm-svn: 183226
      a5e536ab
    • Hans Wennborg's avatar
      Typo: s/caes/cases/ in SimplifyCFG · 5cf30be6
      Hans Wennborg authored
      llvm-svn: 183219
      5cf30be6
  28. Jun 03, 2013
  29. Jun 01, 2013
  30. May 23, 2013
Loading