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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to