llvm-6502/lib/IR
Michael J. Spencer d4b4f2d340 [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
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 [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
CMakeLists.txt
ConstantFold.cpp [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
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 [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
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 [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
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 [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
Metadata.cpp [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
Module.cpp Fix bug 19437 - Only add discriminators for DWARF 4 and above. 2014-04-17 22:33:50 +00:00
Pass.cpp [PM] Add pass run listeners to the pass manager. 2014-04-28 18:19:25 +00:00
PassManager.cpp [PM] Fix a bug where we didn't properly clear the list map when the list 2014-04-21 11:11:54 +00:00
PassRegistry.cpp Use unique_ptr to manage PassInfo instances in the PassRegistry 2014-04-15 15:17:14 +00:00
SymbolTableListTraitsImpl.h [C++] Use 'nullptr'. 2014-04-28 04:05:08 +00:00
Type.cpp [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
TypeFinder.cpp
Use.cpp
User.cpp
Value.cpp [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-15 06:32:26 +00:00
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