summaryrefslogtreecommitdiff
path: root/docs/LangRef.rst
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2014-05-01 22:12:39 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2014-05-01 22:12:39 +0000
commitd4b4f2d3402c0e94730646eb63874fa5265602f5 (patch)
tree01cee689a4799fee847cf1c19e07e786ace465d7 /docs/LangRef.rst
parent6010d958a029f8887ca481c96eca66742a0810dc (diff)
downloadllvm-d4b4f2d3402c0e94730646eb63874fa5265602f5.tar.gz
llvm-d4b4f2d3402c0e94730646eb63874fa5265602f5.tar.bz2
llvm-d4b4f2d3402c0e94730646eb63874fa5265602f5.tar.xz
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207801 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LangRef.rst')
-rw-r--r--docs/LangRef.rst8
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index a6595f7fd0..3d99a0e79b 100644
--- a/docs/LangRef.rst
+++ b/docs/LangRef.rst
@@ -4470,7 +4470,7 @@ Syntax:
::
- <result> = extractelement <n x <ty>> <val>, i32 <idx> ; yields <ty>
+ <result> = extractelement <n x <ty>> <val>, <ty2> <idx> ; yields <ty>
Overview:
"""""""""
@@ -4484,7 +4484,7 @@ Arguments:
The first operand of an '``extractelement``' instruction is a value of
:ref:`vector <t_vector>` type. The second operand is an index indicating
the position from which to extract the element. The index may be a
-variable.
+variable of any integer type.
Semantics:
""""""""""
@@ -4510,7 +4510,7 @@ Syntax:
::
- <result> = insertelement <n x <ty>> <val>, <ty> <elt>, i32 <idx> ; yields <n x <ty>>
+ <result> = insertelement <n x <ty>> <val>, <ty> <elt>, <ty2> <idx> ; yields <n x <ty>>
Overview:
"""""""""
@@ -4525,7 +4525,7 @@ The first operand of an '``insertelement``' instruction is a value of
:ref:`vector <t_vector>` type. The second operand is a scalar value whose
type must equal the element type of the first operand. The third operand
is an index indicating the position at which to insert the value. The
-index may be a variable.
+index may be a variable of any integer type.
Semantics:
""""""""""