[llvm-bugs] [Bug 26702] New: [InstCombine] bitcasts hinder simple vector logic ops

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 22 13:43:45 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26702

            Bug ID: 26702
           Summary: [InstCombine] bitcasts hinder simple vector logic ops
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

#include <xmmintrin.h>

// There are no 'less-than' or 'less-than-or-equal' instructions.
// So use 'not greater-than -1'.
__m128i is_negative(__m128i x) {
  __m128i ones = _mm_set1_epi32(-1);
  __m128i isposorzero = _mm_cmpgt_epi32(x, ones); // x > -1
  __m128i isneg = _mm_xor_si128(isposorzero, ones); // not pos or zero
  return isneg;
}

$ ./clang pcmp.c -O1 -mavx -S -o -
...
    vpsrad    $31, %xmm0, %xmm0
    vpcmpeqd    %xmm1, %xmm1, %xmm1
    vpxor    %xmm1, %xmm0, %xmm0
    vpxor    %xmm1, %xmm0, %xmm0
    retq

------------------------------------------------------------------------------

The first problem seems to be in instcombine:

define <2 x i64> @is_negative(<2 x i64> %x) #0 {
entry:
  %0 = bitcast <2 x i64> %x to <4 x i32>
  %.lobit = ashr <4 x i32> %0, <i32 31, i32 31, i32 31, i32 31>
  %.lobit.not = xor <4 x i32> %.lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
  %1 = bitcast <4 x i32> %.lobit.not to <2 x i64>
  %xor.i = xor <2 x i64> %1, <i64 -1, i64 -1>
  ret <2 x i64> %xor.i
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160222/046ac7af/attachment.html>


More information about the llvm-bugs mailing list