https://llvm.org/bugs/show_bug.cgi?id=31286
Bug ID: 31286 Summary: Instcombine(?) should factor broadcasts across math Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: mku...@google.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Not actually sure "factor" is the right term here, what I mean is that we're missing: bcast(x) + bcast(y) -> bcast(x + y) Right now, for: #include <immintrin.h> __m128 bar(float f, float g, float h, float i) { __m128 v0 = _mm_set_ps1(f); __m128 v1 = _mm_set_ps1(g); __m128 v2 = _mm_set_ps1(h); __m128 v3 = _mm_set_ps1(i); return v0 + v1 + v2 + v3; } We get: bar(float, float, float, float): # @bar(float, float, float, float) shufps $0, %xmm0, %xmm0 # xmm0 = xmm0[0,0,0,0] shufps $0, %xmm1, %xmm1 # xmm1 = xmm1[0,0,0,0] shufps $0, %xmm2, %xmm2 # xmm2 = xmm2[0,0,0,0] shufps $0, %xmm3, %xmm3 # xmm3 = xmm3[0,0,0,0] addps %xmm1, %xmm0 addps %xmm2, %xmm0 addps %xmm3, %xmm0 retq Instead of: bar(float, float, float, float): addss %xmm1, %xmm0 addss %xmm2, %xmm0 addss %xmm3, %xmm0 shufps $0, %xmm0, %xmm0 ret There's another odd thing here - in IR we represent each broadcast as a sequence of insertelements, instead of an insert + shuffle, which, I believe, is the canonical form (at least, this is what the vectorizer produces) That should probably be fixed first, so we have only one canonical broadcast to match. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs