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 Retire llvm::array_endof in favor of non-member std::end. 2014-04-12 16:15:53 +00:00
AutoUpgrade.cpp [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
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 Move MDBuilder's methods out of line. 2014-04-12 14:26:59 +00:00
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 [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
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 Fix use-after-free bug caught by address sanitizer: 2014-04-11 13:55:56 +00:00
DiagnosticPrinter.cpp
DIBuilder.cpp PR19623: Implement typedefs of void. 2014-05-01 17:56:13 +00:00
Dominators.cpp
Function.cpp [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
GCOV.cpp llvm-cov: Add support for gcov's --long-file-names option 2014-04-23 21:44:55 +00:00
Globals.cpp [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
GVMaterializer.cpp
InlineAsm.cpp [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
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 [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
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 [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
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 Fix some doc and comment typos 2014-04-09 14:47:27 +00:00
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