1. Sep 22, 2014
  2. Sep 21, 2014
    • Sanjay Patel's avatar
      Refactor reciprocal square root estimate into target-independent function; NFC. · b67bd262
      Sanjay Patel authored
      This is purely a plumbing patch. No functional changes intended.
      
      The ultimate goal is to allow targets other than PowerPC (certainly X86 and Aarch64) to turn this:
      
      z = y / sqrt(x)
      
      into:
      
      z = y * rsqrte(x)
      
      using whatever HW magic they can use. See http://llvm.org/bugs/show_bug.cgi?id=20900 .
      
      The first step is to add a target hook for RSQRTE, take the already target-independent code selfishly hoarded by PPC, and put it into DAGCombiner.
      
      Next steps:
      
          The code in DAGCombiner::BuildRSQRTE() should be refactored further; tests that exercise that logic need to be added.
          Logic in PPCTargetLowering::BuildRSQRTE() should be hoisted into DAGCombiner.
          X86 and AArch64 overrides for TargetLowering.BuildRSQRTE() should be added.
      
      Differential Revision: http://reviews.llvm.org/D5425
      
      llvm-svn: 218219
      b67bd262
    • Sanjay Patel's avatar
    • Chandler Carruth's avatar
      [x86] With the stronger canonicalization of shuffles added in r218216, · 215037e3
      Chandler Carruth authored
      the new vector shuffle lowering no longer needs to check both symmetric
      forms of UNPCK patterns for v4f64.
      
      llvm-svn: 218217
      215037e3
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering to re-use the SHUFPS · b3125c75
      Chandler Carruth authored
      lowering when it can use a symmetric SHUFPS across both 128-bit lanes.
      
      This required making the SHUFPS lowering tolerant of other vector types,
      and adjusting our canonicalization to canonicalize harder.
      
      This is the last of the clever uses of symmetry I've thought of for
      v8f32. The rest of the tricks I'm aware of here are to work around
      assymetry in the mask.
      
      llvm-svn: 218216
      b3125c75
    • Chandler Carruth's avatar
      [x86] Refactor the logic to form SHUFPS instruction patterns to lower · 02f35549
      Chandler Carruth authored
      a generic vector shuffle mask into a helper that isn't specific to the
      other things that influence which choice is made or the specific types
      used with the instruction.
      
      No functionality changed.
      
      llvm-svn: 218215
      02f35549
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering the basics about insertion · 33eda728
      Chandler Carruth authored
      of a single element into a zero vector for v4f64 and v4i64 in AVX.
      Ironically, there is less to see here because xor+blend is so crazy fast
      that we can't really beat that to zero the high 128-bit lane.
      
      llvm-svn: 218214
      33eda728
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering how to lower to UNPCKLPS and · 43f5974e
      Chandler Carruth authored
      UNPCKHPS with AVX vectors by recognizing those patterns when they are
      repeated for both 128-bit lanes.
      
      With this, we now generate the exact same (really nice) code for
      Quentin's avx_test_case.ll which was the most significant regression
      reported for the new shuffle lowering. In fact, I'm out of specific test
      cases for AVX lowering, the rest were AVX2 I think. However, there are
      a bunch of pretty obvious remaining things to improve with AVX...
      
      llvm-svn: 218213
      43f5974e
    • Chandler Carruth's avatar
      [x86] Add test cases for UNPCK instructions with v8f32 AVX vectors in · 78f47989
      Chandler Carruth authored
      preparation for enhancing their support in the new vector shuffle
      lowering.
      
      llvm-svn: 218212
      78f47989
    • Chandler Carruth's avatar
      [x86] Begin teaching the new vector shuffle lowering among the most · 88404c4f
      Chandler Carruth authored
      important bits of cleverness: to detect and lower repeated shuffle
      patterns between the two 128-bit lanes with a single instruction.
      
      This patch just teaches it how to lower single-input shuffles that fit
      this model using VPERMILPS. =] There is more that needs to happen here.
      
      llvm-svn: 218211
      88404c4f
    • Chandler Carruth's avatar
      [x86] Regenerate this test case now that I've improved my script for · 83252ac8
      Chandler Carruth authored
      generating the test cases to format things more consistently and
      actually catch all the operand sequences that should be elided in favor
      of the asm comments. No actual changes here.
      
      llvm-svn: 218210
      83252ac8
    • Chandler Carruth's avatar
      [x86] Explicitly lower to a blend early if it is trivial to do so for · 3dccabaf
      Chandler Carruth authored
      v8f32 shuffles in the new vector shuffle lowering code.
      
      This is very cheap to do and makes it much more clear that anything more
      expensive but overlapping with this lowering should be selected
      afterward (for example using AVX2's VPERMPS). However, no functionality
      changed here as without this code we would fall through to create no-op
      shuffles of each input and a blend. =]
      
      llvm-svn: 218209
      3dccabaf
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering of v4f64 to prefer a direct · e81bfbad
      Chandler Carruth authored
      VBLENDPD over using VSHUFPD. While the 256-bit variant of VBLENDPD slows
      down to the same speed as VSHUFPD on Sandy Bridge CPUs, it has twice the
      reciprocal throughput on Ivy Bridge CPUs much like it does everywhere
      for 128-bits. There isn't a downside, so just eagerly use this
      instruction when it suffices.
      
      llvm-svn: 218208
      e81bfbad
    • Chandler Carruth's avatar
      [x86] Add some more comprehensive tests for v4f64 blending. · 6aea21df
      Chandler Carruth authored
      llvm-svn: 218207
      6aea21df
    • Chandler Carruth's avatar
      [x86] Re-generate a bunch of the v4f64 test cases with my new script. · 908afb56
      Chandler Carruth authored
      This expands the integer cases to cover the fact that AVX2 moves their
      lane-crossing shuffles into the integer domain. It also adds proper
      support for AVX2 run lines and the "ALL" group when it doesn't matter.
      
      llvm-svn: 218206
      908afb56
    • Chandler Carruth's avatar
      [x86] Switch the blend implementation to use a MVT switch rather than · 8d0a1b20
      Chandler Carruth authored
      awkward conditions. The readability improvement of this will be even
      more important as I generalize it to handle more types.
      
      No functionality changed.
      
      llvm-svn: 218205
      8d0a1b20
    • Chandler Carruth's avatar
      [x86] Remove some essentially lying comments from the v4f64 path of the · f098cee2
      Chandler Carruth authored
      new vector shuffle lowering.
      
      llvm-svn: 218204
      f098cee2
    • Chandler Carruth's avatar
      [x86] Fix a helper to reflect that what we actually care about is · a746d776
      Chandler Carruth authored
      128-bit lane crossings, not 'half' crossings. This came up in code
      review ages ago, but I hadn't really addresesd it. Also added some
      documentation for the helper.
      
      No functionality changed.
      
      llvm-svn: 218203
      a746d776
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering the first step toward more · 293327dd
      Chandler Carruth authored
      actual support for complex AVX shuffling tricks. We can do independent
      blends of the low and high 128-bit lanes of an avx vector, so shuffle
      the inputs into place and then do the blend at 256 bits. This will in
      many cases remove one blend instruction.
      
      The next step is to permute the low and high halves in-place rather than
      extracting them and re-inserting them.
      
      llvm-svn: 218202
      293327dd
    • David Majnemer's avatar
      MC: Support aligned COMMON symbols for COFF · 48227a37
      David Majnemer authored
      link.exe:
      Fuzz testing has shown that COMMON symbols with size > 32 will always
      have an alignment of at least 32 and all symbols with size < 32 will
      have an alignment of at least the largest power of 2 less than the size
      of the symbol.
      
      binutils:
      The BFD linker essentially work like the link.exe behavior but with
      alignment 4 instead of 32.  The BFD linker also supports an extension to
      COFF which adds an -aligncomm argument to the .drectve section which
      permits specifying a precise alignment for a variable but MC currently
      doesn't support editing .drectve in this way.
      
      With all of this in mind, we decide to play a little trick: we can
      ensure that the alignment will be respected by bumping the size of the
      global to it's alignment.
      
      llvm-svn: 218201
      48227a37
    • Chandler Carruth's avatar
      [x86] Add some more test cases covering specific blend patterns. · 8ff73c01
      Chandler Carruth authored
      llvm-svn: 218200
      8ff73c01
    • Chandler Carruth's avatar
      [x86] Add the beginnings of some tests for our v8f32 shuffle lowering · 7a6108d6
      Chandler Carruth authored
      under AVX.
      
      This really just documents the current state of the world. I'm going to
      try to flesh it out to cover any test cases I plan to improve prior to
      improving them so that the delta made by changes is actually visible to
      code reviewers.
      
      This is made easier by the fact that I now have a script to automate the
      process of producing test cases including the check lines. =]
      
      llvm-svn: 218199
      7a6108d6
    • Yaron Keren's avatar
      Modified per David Blakie suggestion. · 9682c855
      Yaron Keren authored
      llvm-svn: 218198
      9682c855
    • Yaron Keren's avatar
      Silence these C4715 warnings from Visual C++ (NFC) · 84f3816f
      Yaron Keren authored
      llvm\tools\lld\lib\readerwriter\macho\macholinkingcontext.cpp(647):
      warning C4715: 'lld::MachOLinkingContext::exportSymbolNamed' :
      not all control paths return a value
      
      llvm\tools\lld\lib\readerwriter\macho\machonormalizedfilefromatoms.cpp(723):
      warning C4715: '`anonymous namespace'::Util::getSymbolTableRegion' :
      not all control paths return a value
      
      While all enum values do appear in the switch, an uninitialized or corrupted
      enum variable would not be caught without the default: case in the switch.
      
      llvm-svn: 218197
      84f3816f
    • Ed Maste's avatar
      Enable libcxx map test on FreeBSD again · da7c5b25
      Ed Maste authored
      The test used to trigger an assertion failure "Cannot get layout of
      forward declarations!", but it no longer fails when built with
      Clang 3.4.1 (system compiler) or 3.5 from SVN on FreeBSD.
      
      llvm.org/pr17231
      
      llvm-svn: 218196
      da7c5b25
    • NAKAMURA Takumi's avatar
      RTDyldMemoryManager::getSymbolAddress(): Make sure to return 0 if symbol name... · 4b21bac5
      NAKAMURA Takumi authored
      RTDyldMemoryManager::getSymbolAddress(): Make sure to return 0 if symbol name is not met. [-Wreturn-type]
      
      llvm-svn: 218195
      4b21bac5
    • Sanjay Patel's avatar
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering to use VPERMILPD for · a454812a
      Chandler Carruth authored
      single-input shuffles with doubles. This allows them to fold memory
      operands into the shuffle, etc. This is just the analog to the v4f32
      case in my prior commit.
      
      llvm-svn: 218193
      a454812a
    • Chandler Carruth's avatar
      [x86] Add an AVX run to the 128-bit v2 tests, teach them to have · aa5b798a
      Chandler Carruth authored
      a generic SSE and AVX mode in addition to a specific AVX1 test path, and
      flesh out the AVX tests.
      
      llvm-svn: 218192
      aa5b798a
    • David Majnemer's avatar
      Update tests which broke from r218189 · fb839775
      David Majnemer authored
      llvm-svn: 218191
      fb839775
    • Chandler Carruth's avatar
      [x86] Teach the new vector shuffle lowering to use the AVX VPERMILPS · 6f80abac
      Chandler Carruth authored
      instruction for single-vector floating point shuffles. This in turn
      allows the shuffles to fold a load into the instruction which is one of
      the common regressions hit with the new shuffle lowering.
      
      llvm-svn: 218190
      6f80abac
    • David Majnemer's avatar
      MC: Fix MCSectionCOFF::PrintSwitchToSection · 7d0dc3ef
      David Majnemer authored
      We had a few bugs:
      - We were considering the GVKind instead of just looking at the section
        characteristics
      - We would never print out 'y' when a section was meant to be unreadable
      - We would never print out 's' when a section was meant to be shared
      - We translated IMAGE_SCN_MEM_DISCARDABLE to 'n' when it should've meant
        IMAGE_SCN_LNK_REMOVE
      
      llvm-svn: 218189
      7d0dc3ef
    • Chandler Carruth's avatar
      [x86] Start moving to a fancier check syntax to reduce the need for · 78a761ce
      Chandler Carruth authored
      duplication of check lines. The idea is to have broad sets of
      compilation modes that will frequently diverge without having to always
      and immediately explode to the precise ISA feature set.
      
      While this already helps due to VEX encoded differences, it will help
      much more as I teach the new shuffle lowering about more of the new VEX
      encoded instructions which can still be used to implement 128-bit
      shuffles.
      
      llvm-svn: 218188
      78a761ce
    • Lang Hames's avatar
      [MCJIT] Make RTDyldMemoryManager::getSymbolAddress's behaviour more consistent. · b7fbf593
      Lang Hames authored
      This patch modifies RTDyldMemoryManager::getSymbolAddress(Name)'s behavior to
      make it consistent with how clients are using it: Name should be mangled, and
      getSymbolAddress should demangle it on the caller's behalf before looking the
      name up in the process. This patch also fixes the one client
      (MCJIT::getPointerToFunction) that had been passing unmangled names (by having
      it pass mangled names instead).
      
      Background:
      
      RTDyldMemoryManager::getSymbolAddress(Name) has always used a re-try mechanism
      when looking up symbol names in the current process. Prior to this patch
      getSymbolAddress first tried to look up 'Name' exactly as the user passed it in
      and then, if that failed, tried to demangle 'Name' and re-try the look up. The
      implication of this behavior is that getSymbolAddress expected to be called with
      unmangled names, and that handling mangled names was a fallback for convenience.
      This is inconsistent with how clients (particularly the RuntimeDyldImpl
      subclasses, but also MCJIT) usually use this API. Most clients pass in mangled
      names, and succeed only because of the fallback case. For clients passing in
      mangled names, getSymbolAddress's old behavior was actually dangerous, as it
      could cause unmangled names in the process to shadow mangled names being looked
      up.
      
      For example, consider:
      
      foo.c:
      
      int _x = 7;
      int x() { return _x; }
      
      foo.o:
      
      000000000000000c D __x
      0000000000000000 T _x
      
      If foo.c becomes part of the process (E.g. via dlopen("libfoo.dylib")) it will
      add symbols 'x' (the function) and '_x' (the variable) to the process. However
      jit clients looking for the function 'x' will be using the mangled function name
      '_x' (note how function 'x' appears in foo.o). When getSymbolAddress goes
      looking for '_x' it will find the variable instead, and return its address and
      in place of the function, leading to JIT'd code calling the variable and
      crashing (if we're lucky).
      
      By requiring that getSymbolAddress be called with mangled names, and demangling
      only when we're about to do a lookup in the process, the new behavior
      implemented in this patch should eliminate any chance of names being shadowed
      during lookup.
      
      There's no good way to test this at the moment: This issue only arrises when
      looking up process symbols (not JIT'd symbols). Any test case would have to
      generate a platform-appropriate dylib to pass to llvm-rtdyld, and I'm not
      aware of any in-tree tool for doing this in a portable way.
      
      llvm-svn: 218187
      b7fbf593