[llvm-bugs] [Bug 32078] New: [SLP] convert multiple scalar comparisons into vector comparison and horizontal reduction

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 27 11:23:59 PST 2017


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

            Bug ID: 32078
           Summary: [SLP] convert multiple scalar comparisons into vector
                    comparison and horizontal reduction
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

define i1 @cmpv2f32(<2 x i32> %x, <2 x i32> %y) {
entry:
  %x0 = extractelement <2 x i32> %x, i32 0
  %y0 = extractelement <2 x i32> %y, i32 0
  %cmp0 = icmp eq i32 %x0, %y0
  br i1 %cmp0, label %if, label %endif

if:
  %x1 = extractelement <2 x i32> %x, i32 1
  %y1 = extractelement <2 x i32> %y, i32 1
  %cmp1 = icmp eq i32 %x1, %y1
  br label %endif

endif:
  %and_of_cmps = phi i1 [ false, %entry ], [ %cmp1, %if ]
  ret i1 %and_of_cmps
}

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

Can we (instcombine + SLP vectorizer?) transform this to:

define i1 @rrcmpv2f32(<2 x i32> %x, <2 x i32> %y) {
  %vcmp = icmp eq <2 x i32> %x, %y
  %cmp0 = extractelement <2 x i1> %vcmp, i32 0
  %cmp1 = extractelement <2 x i1> %vcmp, i32 1
  %and_of_cmps = and i1 %cmp0, %cmp1
  ret i1 %and_of_cmps
}

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

This example is reduced from source for an x86 target, so the ultimate goal is
to have this produce a vector compare and 'movmsk':

bool cmpv4f32_0(__m128 a, __m128 b) {
  union {
    __m128 v;
    int i32[4];
  } _a, _b;
  _a.v = a;
  _b.v = b;
  return (_a.i32[0] == _b.i32[0] && 
          _a.i32[1] == _b.i32[1] &&
          _a.i32[2] == _b.i32[2] &&
          _a.i32[3] == _b.i32[3]);
}

-- 
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/20170227/e6da9709/attachment.html>


More information about the llvm-bugs mailing list