Skip to content
  1. Mar 23, 2015
  2. Mar 22, 2015
  3. Mar 21, 2015
    • Benjamin Kramer's avatar
    • Benjamin Kramer's avatar
      [SimplifyLibCalls] Turn memchr(const, C, const) into a bitfield check. · 7857d723
      Benjamin Kramer authored
      strchr("123!", C) != nullptr is a common pattern to check if C is one
      of 1, 2, 3 or !. If the largest element of the string is smaller than
      the target's register size we can easily create a bitfield and just
      do a simple test for set membership.
      
      int foo(char C) { return strchr("123!", C) != nullptr; } now becomes
      
      	cmpl	$64, %edi ## range check
      	sbbb	%al, %al
      	movabsq	$0xE000200000001, %rcx
      	btq	%rdi, %rcx ## bit test
      	sbbb	%cl, %cl
      	andb	%al, %cl ## and the two conditions
      	andb	$1, %cl
      	movzbl	%cl, %eax ## returning an int
      	ret
      
      (imho the backend should expand this into a series of branches, but
      that's a different story)
      
      The code is currently limited to bit fields that fit in a register, so
      usually 64 or 32 bits. Sadly, this misses anything using alpha chars
      or {}. This could be fixed by just emitting a i128 bit field, but that
      can generate really ugly code so we have to find a better way. To some
      degree this is also recreating switch lowering logic, but we can't
      simply emit a switch instruction and thus change the CFG within
      instcombine.
      
      llvm-svn: 232902
      7857d723
    • Benjamin Kramer's avatar
      SimplifyLibCalls: Add basic optimization of memchr calls. · 691363e7
      Benjamin Kramer authored
      This is just memchr(x, y, 0) -> nullptr and constant folding.
      
      llvm-svn: 232896
      691363e7
    • Benjamin Kramer's avatar
      ValueTracking: Forward getConstantStringInfo's TrimAtNul param into recursive invocation · 0248a3e5
      Benjamin Kramer authored
      Currently this is only used to tweak the backend's memcpy inlining
      heuristics, testing that isn't very helpful. A real test case will
      follow in the next commit, where this behavior would cause a real
      miscompilation.
      
      llvm-svn: 232895
      0248a3e5
    • David Majnemer's avatar
      MemoryDependenceAnalysis: Don't miscompile atomics · e165502e
      David Majnemer authored
      r216771 introduced a change to MemoryDependenceAnalysis that allowed it
      to reason about acquire/release operations.  However, this change does
      not ensure that the acquire/release operations pair.  Unfortunately,
      this leads to miscompiles as we won't see an acquire load as properly
      memory effecting.  This largely reverts r216771.
      
      This fixes PR22708.
      
      llvm-svn: 232889
      e165502e
    • Eric Christopher's avatar
      Remove the target independent TargetMachine::getSubtarget and · 4d0f35a9
      Eric Christopher authored
      TargetMachine::getSubtargetImpl routines.
      
      This keeps the target independent code free of bare subtarget
      calls while the remainder of the backends are migrated, or not
      if they don't wish to support per-function subtargets as would
      be needed for function multiversioning or LTO of disparate
      cpu subarchitecture types, e.g.
      
      clang -msse4.2 -c foo.c -emit-llvm -o foo.bc
      clang -c bar.c -emit-llvm -o bar.bc
      llvm-link foo.bc bar.bc -o baz.bc
      llc baz.bc
      
      and get appropriate code for what the command lines requested.
      
      llvm-svn: 232885
      4d0f35a9
    • Eric Christopher's avatar
      Remove the bare getSubtargetImpl call from the AArch64 port. As part · faad6205
      Eric Christopher authored
      of this add a test that shows we can generate code for functions
      that specifically enable a subtarget feature.
      
      llvm-svn: 232884
      faad6205
    • Eric Christopher's avatar
      Remove the bare getSubtargetImpl call from the PPC port. As part · 83eb13c9
      Eric Christopher authored
      of this add a test that shows we can generate code with
      for functions that differ by subtarget feature.
      
      llvm-svn: 232882
      83eb13c9
    • Eric Christopher's avatar
      Grab a subtarget off of an AMDGPUTargetMachine rather than a · 8024d030
      Eric Christopher authored
      bare target machine in preparation for the TargetMachine bare
      getSubtarget/getSubtargetImpl calls going away.
      
      llvm-svn: 232880
      8024d030
Loading