[llvm-bugs] [Bug 46286] New: Combine shuffle(fneg(x), fneg(y)) -> fneg(shuffle(x, y))

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 11 09:38:39 PDT 2020


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

            Bug ID: 46286
           Summary: Combine shuffle(fneg(x),fneg(y)) -> fneg(shuffle(x,y))
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com

https://godbolt.org/z/cHgY_S

For cases such as:

define <4 x float> @fneg_concat_v2f32(<2 x float> %a0, <2 x float> %a1) {
  %1 = fneg <2 x float> %a0
  %2 = fneg <2 x float> %a1
  %3 = shufflevector <2 x float> %1, <2 x float> %2, <4 x i32> <i32 0, i32 1,
i32 2, i32 3>
  ret <4 x float> %3
}
define <4 x float> @fneg_concat_v4f32(<4 x float> %a0, <4 x float> %a1) {
  %1 = fneg <4 x float> %a0
  %2 = fneg <4 x float> %a1
  %3 = shufflevector <4 x float> %1, <4 x float> %2, <4 x i32> <i32 0, i32 1,
i32 4, i32 5>
  ret <4 x float> %3
}

we are almost certainly better off moving the fneg after the shuffle:

define <4 x float> @concat_fneg_v2f32(<2 x float> %a0, <2 x float> %a1) {
  %1 = shufflevector <2 x float> %a0, <2 x float> %a1, <4 x i32> <i32 0, i32 1,
i32 2, i32 3>
  %2 = fneg <4 x float> %1
  ret <4 x float> %2
}
define <4 x float> @concat_fneg_v4f32(<4 x float> %a0, <4 x float> %a1) {
  %1 = shufflevector <4 x float> %a0, <4 x float> %a1, <4 x i32> <i32 0, i32 1,
i32 4, i32 5>
  %2 = fneg <4 x float> %1
  ret <4 x float> %2
}

Binops would probably benefit in some cases (constant operand?) as well.

The issue that vectorcombine might encounter though is that we fail to get
costs for most length changing shuffles, so the 'concat_vectors' shuffle
pattern returns an 'Unknown' cost.

-- 
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/20200611/12c857d3/attachment.html>


More information about the llvm-bugs mailing list