[llvm-bugs] [Bug 44588] New: [InstCombine] icmp not pushed through shufflevector

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jan 19 01:26:11 PST 2020


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

            Bug ID: 44588
           Summary: [InstCombine] icmp not pushed through shufflevector
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nikita.ppv at gmail.com
                CC: llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
                    spatel+llvm at rotateright.com

Instcombine pushes binary operations through shufflevector instructions,
however the same does not happen with icmps:

define <2 x i1> @test(i64 %X) {
  %.splatinsert = insertelement <2 x i64> undef, i64 %X, i32 0
  %.splat = shufflevector <2 x i64> %.splatinsert, <2 x i64> undef, <2 x i32>
zeroinitializer
  %A.idx = mul nsw <2 x i64> %.splat, <i64 4, i64 4>
  %A.offs = add <2 x i64> %A.idx, <i64 4, i64 4>
  %C = icmp eq <2 x i64> %A.offs, <i64 4, i64 4> 
  ret <2 x i1> %C
}

opt -instcombine

define <2 x i1> @test(i64 %X) {
  %.splatinsert = insertelement <2 x i64> undef, i64 %X, i32 0
  %1 = shl <2 x i64> %.splatinsert, <i64 2, i64 undef>
  %2 = add <2 x i64> %1, <i64 4, i64 undef>
  %A.offs = shufflevector <2 x i64> %2, <2 x i64> undef, <2 x i32>
zeroinitializer
  %C = icmp eq <2 x i64> %A.offs, <i64 4, i64 4>
  ret <2 x i1> %C
}

This means that the add+eq pair that would normally get folded ends up
separated by a shufflevector.

(As a side-note, it seems like there's an opportunity here to push instructions
through insertelement if the other lanes are undef anyway.)

-- 
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/20200119/8c69c18e/attachment-0001.html>


More information about the llvm-bugs mailing list