Skip to content
  1. May 03, 2012
  2. May 01, 2012
  3. Apr 27, 2012
  4. Apr 25, 2012
  5. Apr 24, 2012
  6. Apr 23, 2012
    • Jakob Stoklund Olesen's avatar
      Reapply r155136 after fixing PR12599. · 43bcb970
      Jakob Stoklund Olesen authored
      Original commit message:
      
      Defer some shl transforms to DAGCombine.
      
      The shl instruction is used to represent multiplication by a constant
      power of two as well as bitwise left shifts. Some InstCombine
      transformations would turn an shl instruction into a bit mask operation,
      making it difficult for later analysis passes to recognize the
      constsnt multiplication.
      
      Disable those shl transformations, deferring them to DAGCombine time.
      An 'shl X, C' instruction is now treated mostly the same was as 'mul X, C'.
      
      These transformations are deferred:
      
        (X >>? C) << C   --> X & (-1 << C)  (When X >> C has multiple uses)
        (X >>? C1) << C2 --> X << (C2-C1) & (-1 << C2)   (When C2 > C1)
        (X >>? C1) << C2 --> X >>? (C1-C2) & (-1 << C2)  (When C1 > C2)
      
      The corresponding exact transformations are preserved, just like
      div-exact + mul:
      
        (X >>?,exact C) << C   --> X
        (X >>?,exact C1) << C2 --> X << (C2-C1)
        (X >>?,exact C1) << C2 --> X >>?,exact (C1-C2)
      
      The disabled transformations could also prevent the instruction selector
      from recognizing rotate patterns in hash functions and cryptographic
      primitives. I have a test case for that, but it is too fragile.
      
      llvm-svn: 155362
      43bcb970
  7. Apr 20, 2012
  8. Apr 19, 2012
    • Jakob Stoklund Olesen's avatar
      Defer some shl transforms to DAGCombine. · 6b6c81e6
      Jakob Stoklund Olesen authored
      The shl instruction is used to represent multiplication by a constant
      power of two as well as bitwise left shifts. Some InstCombine
      transformations would turn an shl instruction into a bit mask operation,
      making it difficult for later analysis passes to recognize the
      constsnt multiplication.
      
      Disable those shl transformations, deferring them to DAGCombine time.
      An 'shl X, C' instruction is now treated mostly the same was as 'mul X, C'.
      
      These transformations are deferred:
      
        (X >>? C) << C   --> X & (-1 << C)  (When X >> C has multiple uses)
        (X >>? C1) << C2 --> X << (C2-C1) & (-1 << C2)   (When C2 > C1)
        (X >>? C1) << C2 --> X >>? (C1-C2) & (-1 << C2)  (When C1 > C2)
      
      The corresponding exact transformations are preserved, just like
      div-exact + mul:
      
        (X >>?,exact C) << C   --> X
        (X >>?,exact C1) << C2 --> X << (C2-C1)
        (X >>?,exact C1) << C2 --> X >>?,exact (C1-C2)
      
      The disabled transformations could also prevent the instruction selector
      from recognizing rotate patterns in hash functions and cryptographic
      primitives. I have a test case for that, but it is too fragile.
      
      llvm-svn: 155136
      6b6c81e6
  9. Apr 08, 2012
    • Chandler Carruth's avatar
      Teach InstCombine to nuke a common alloca pattern -- an alloca which has · f82b0e2d
      Chandler Carruth authored
      GEPs, bit casts, and stores reaching it but no other instructions. These
      often show up during the iterative processing of the inliner, SROA, and
      DCE. Once we hit this point, we can completely remove the alloca. These
      were actually showing up in the final, fully optimized code in a bunch
      of inliner tests I've been working on, and notably they show up after
      LLVM finishes optimizing away all function calls involved in
      hash_combine(a, b).
      
      llvm-svn: 154285
      f82b0e2d
  10. Apr 04, 2012
    • Rafael Espindola's avatar
      Always compute all the bits in ComputeMaskedBits. · ba0a6cab
      Rafael Espindola authored
      This allows us to keep passing reduced masks to SimplifyDemandedBits, but
      know about all the bits if SimplifyDemandedBits fails. This allows instcombine
      to simplify cases like the one in the included testcase.
      
      llvm-svn: 154011
      ba0a6cab
  11. Mar 26, 2012
  12. Mar 16, 2012
  13. Mar 15, 2012
  14. Mar 11, 2012
    • Stepan Dyatkovskiy's avatar
      llvm::SwitchInst · 97b02fc1
      Stepan Dyatkovskiy authored
      Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default.
      Added some notes relative to case iterators.
      
      llvm-svn: 152532
      97b02fc1
  15. Mar 08, 2012
    • Stepan Dyatkovskiy's avatar
      Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012: · 5b648afb
      Stepan Dyatkovskiy authored
      http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html
      
      Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*".
      
      ConstCaseIt is just a read-only iterator.
      CaseIt is read-write iterator; it allows to change case successor and case value.
      
      Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters.
      
      Main way of iterator usage looks like this:
      SwitchInst *SI = ... // intialize it somehow
      
      for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) {
        BasicBlock *BB = i.getCaseSuccessor();
        ConstantInt *V = i.getCaseValue();
        // Do something.
      }
      
      If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method.
      If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method.
      
      There are also related changes in llvm-clients: klee and clang.
      
      llvm-svn: 152297
      5b648afb
  16. Feb 29, 2012
    • Bill Wendling's avatar
      Restrict this transformation to equality conditions. · f2c78f34
      Bill Wendling authored
      This transformation is not correct for not-equal conditions:
      
      (trunc x) != C1 & (and x, CA) != C2 -> (and x, CA|CMAX) != C1|C2
      
      Let
        C1 == 0
        C2 == 0
        CA == 0xFF0000
        CMAX == 0xFF
      and truncating to i8.
      
      The original truth table:
      
          x   | A: trunc x != 0 | B: x & 0xFF0000 != 0 | A & B != 0
      --------------------------------------------------------------
      0x00000 |        0        |          0           |     0
      0x00001 |        1        |          0           |     0
      0x10000 |        0        |          1           |     0
      0x10001 |        1        |          1           |     1
      
      The truth table of the replacement:
      
          x   | x & 0xFF00FF != 0
      ----------------------------
      0x00000 |        0
      0x00001 |        1
      0x10000 |        1
      0x10001 |        1
      
      So they are different.
      
      llvm-svn: 151691
      f2c78f34
  17. Feb 21, 2012
  18. Feb 20, 2012
  19. Feb 14, 2012
  20. Feb 07, 2012
  21. Feb 06, 2012
  22. Feb 03, 2012
  23. Feb 01, 2012
    • Stepan Dyatkovskiy's avatar
      SwitchInst refactoring. · 513aaa56
      Stepan Dyatkovskiy authored
      The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want.
      
      What was done:
      
      1. Changed semantics of index inside the getCaseValue method:
      getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous.
      2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned.
      3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment.
      4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst.
      4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor.
      4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor.
      
      Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang.
      llvm-svn: 149481
      513aaa56
    • Jim Grosbach's avatar
      Disable InstCombine unsafe folding bitcasts of calls w/ varargs. · 9fa04815
      Jim Grosbach authored
      Changing arguments from being passed as fixed to varargs is unsafe, as
      the ABI may require they be handled differently (stack vs. register, for
      example).
      
      Remove two tests which rely on the bitcast being folded into the direct
      call, which is exactly the transformation that's unsafe.
      
      llvm-svn: 149457
      9fa04815
  24. Jan 31, 2012
  25. Jan 27, 2012
  26. Jan 26, 2012
Loading