1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/lib/IR
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
..
AsmWriter.cpp Add 'musttail' marker to call instructions 2014-04-24 20:14:34 +00:00
AsmWriter.h
AttributeImpl.h
Attributes.cpp
AutoUpgrade.cpp
BasicBlock.cpp
CMakeLists.txt
ConstantFold.cpp
ConstantFold.h
ConstantRange.cpp
Constants.cpp [IR] Make {extract,insert}element accept an index of any integer type. 2014-05-01 22:12:39 +00:00
ConstantsContext.h Try to fix the msvc build. 2014-04-29 23:37:02 +00:00
Core.cpp raw_ostream: Forward declare OpenFlags and include FileSystem.h only where necessary. 2014-04-29 23:26:49 +00:00
DataLayout.cpp Use pointer size function where only a pointer is expected 2014-04-23 21:10:15 +00:00
DebugInfo.cpp
DebugLoc.cpp
DiagnosticInfo.cpp
DiagnosticPrinter.cpp
DIBuilder.cpp PR19623: Implement typedefs of void. 2014-05-01 17:56:13 +00:00
Dominators.cpp
Function.cpp
GCOV.cpp llvm-cov: Add support for gcov's --long-file-names option 2014-04-23 21:44:55 +00:00
Globals.cpp
GVMaterializer.cpp
InlineAsm.cpp
Instruction.cpp
Instructions.cpp [IR] Make {extract,insert}element accept an index of any integer type. 2014-05-01 22:12:39 +00:00
IntrinsicInst.cpp
IRBuilder.cpp
IRPrintingPasses.cpp
LeakDetector.cpp
LeaksContext.h [C++] Use 'nullptr'. 2014-04-28 04:05:08 +00:00
LegacyPassManager.cpp [PM] Add pass run listeners to the pass manager. 2014-04-28 18:19:25 +00:00
LLVMBuild.txt
LLVMContext.cpp [PM] Add pass run listeners to the pass manager. 2014-04-28 18:19:25 +00:00
LLVMContextImpl.cpp [PM] Add pass run listeners to the pass manager. 2014-04-28 18:19:25 +00:00
LLVMContextImpl.h [PM] Add pass run listeners to the pass manager. 2014-04-28 18:19:25 +00:00
Makefile
Mangler.cpp
MDBuilder.cpp
Metadata.cpp
Module.cpp
Pass.cpp [PM] Add pass run listeners to the pass manager. 2014-04-28 18:19:25 +00:00
PassManager.cpp
PassRegistry.cpp
SymbolTableListTraitsImpl.h [C++] Use 'nullptr'. 2014-04-28 04:05:08 +00:00
Type.cpp
TypeFinder.cpp
Use.cpp
User.cpp
Value.cpp
ValueSymbolTable.cpp [Modules] Remove potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:02:50 +00:00
ValueTypes.cpp
Verifier.cpp IR: Conservatively verify inalloca arguments 2014-04-30 17:22:00 +00:00