1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-25 14:02:52 +02:00
Commit Graph

7 Commits

Author SHA1 Message Date
Michael J. Spencer
eeeb060307 [IR] Make {extract,insert}element accept an index of any integer type.
Given the following C code llvm currently generates suboptimal code for
x86-64:

__m128 bss4( const __m128 *ptr, size_t i, size_t j )
{
    float f = ptr[i][j];
    return (__m128) { f, f, f, f };
}

=================================================

define <4 x float> @_Z4bss4PKDv4_fmm(<4 x float>* nocapture readonly %ptr, i64 %i, i64 %j) #0 {
  %a1 = getelementptr inbounds <4 x float>* %ptr, i64 %i
  %a2 = load <4 x float>* %a1, align 16, !tbaa !1
  %a3 = trunc i64 %j to i32
  %a4 = extractelement <4 x float> %a2, i32 %a3
  %a5 = insertelement <4 x float> undef, float %a4, i32 0
  %a6 = insertelement <4 x float> %a5, float %a4, i32 1
  %a7 = insertelement <4 x float> %a6, float %a4, i32 2
  %a8 = insertelement <4 x float> %a7, float %a4, i32 3
  ret <4 x float> %a8
}

=================================================

        shlq    $4, %rsi
        addq    %rdi, %rsi
        movslq  %edx, %rax
        vbroadcastss    (%rsi,%rax,4), %xmm0
        retq

=================================================

The movslq is uneeded, but is present because of the trunc to i32 and then
sext back to i64 that the backend adds for vbroadcastss.

We can't remove it because it changes the meaning. The IR that clang
generates is already suboptimal. What clang really should emit is:

  %a4 = extractelement <4 x float> %a2, i64 %j

This patch makes that legal. A separate patch will teach clang to do it.

Differential Revision: http://reviews.llvm.org/D3519

llvm-svn: 207801
2014-05-01 22:12:39 +00:00
Tanya Lattner
726c082fd5 Remove llvm-upgrade and update tests.
llvm-svn: 47784
2008-03-01 07:38:40 +00:00
Reid Spencer
9741d8a603 Redefinition of functions is no longer permitted.
llvm-svn: 33000
2007-01-07 19:33:49 +00:00
Reid Spencer
7f5ef2d7a5 Use the llvm-upgrade program to upgrade llvm assembly.
llvm-svn: 32115
2006-12-02 04:23:10 +00:00
Chris Lattner
eb990aaaf6 new testcase for shufflevector
llvm-svn: 27508
2006-04-08 01:17:42 +00:00
Robert Bocchino
8714c48055 Test case for the insertelement operation.
llvm-svn: 25409
2006-01-17 20:07:30 +00:00
Chris Lattner
8f96cc65bb new testcase for extractelement instruction
llvm-svn: 25186
2006-01-10 20:00:20 +00:00