1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/lib
David Sherwood 8067824e3d [InstCombine] Fold extractelement + vector GEP with one use
We sometimes see code like this:

Case 1:
  %gep = getelementptr i32, i32* %a, <2 x i64> %splat
  %ext = extractelement <2 x i32*> %gep, i32 0

or this:

Case 2:
  %gep = getelementptr i32, <4 x i32*> %a, i64 1
  %ext = extractelement <4 x i32*> %gep, i32 0

where there is only one use of the GEP. In such cases it makes
sense to fold the two together such that we create a scalar GEP:

Case 1:
  %ext = extractelement <2 x i64> %splat, i32 0
  %gep = getelementptr i32, i32* %a, i64 %ext

Case 2:
  %ext = extractelement <2 x i32*> %a, i32 0
  %gep = getelementptr i32, i32* %ext, i64 1

This may create further folding opportunities as a result, i.e.
the extract of a splat vector can be completely eliminated. Also,
even for the general case where the vector operand is not a splat
it seems beneficial to create a scalar GEP and extract the scalar
element from the operand. Therefore, in this patch I've assumed
that a scalar GEP is always preferrable to a vector GEP and have
added code to unconditionally fold the extract + GEP.

I haven't added folds for the case when we have both a vector of
pointers and a vector of indices, since this would require
generating an additional extractelement operation.

Tests have been added here:

  Transforms/InstCombine/gep-vector-indices.ll

Differential Revision: https://reviews.llvm.org/D101900
2021-05-26 09:54:26 +01:00
..
Analysis [NFC] Fix 'unused' warning 2021-05-25 12:23:57 -07:00
AsmParser [OpaquePtr] Make atomicrmw work with opaque pointers 2021-05-25 20:16:21 -07:00
BinaryFormat
Bitcode [OpaquePtr] Make atomicrmw work with opaque pointers 2021-05-25 20:16:21 -07:00
Bitstream
CodeGen [SelectionDAG] Propagate scoped AA metadata when lowering mem intrinsics. 2021-05-25 14:42:26 -04:00
DebugInfo Add support for DWARF embedded source to llvm-symbolizer. 2021-05-20 21:40:28 +04:00
Demangle [Demangle][Rust] Parse function signatures 2021-05-22 11:49:08 +02:00
DWARFLinker [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
ExecutionEngine [JITLink][MachO][arm64] Build GOT entries for defined symbols too. 2021-05-25 12:19:09 -07:00
Extensions
FileCheck
Frontend [NFC][OMP] Fix 'unused' warning 2021-05-24 17:14:38 -07:00
Fuzzer
FuzzMutate
InterfaceStub
IR [OpaquePtr] Make atomicrmw work with opaque pointers 2021-05-25 20:16:21 -07:00
IRReader
LineEditor
Linker
LTO [SampleFDO] New hierarchical discriminator for Flow Sensitive SampleFDO 2021-05-18 16:23:43 -07:00
MC [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
MCA [MCA][RegisterFile] Refactor the move elimination logic to address PR50258. 2021-05-08 18:10:35 +01:00
Object [NFC][object] Change the input parameter of the method isDebugSection. 2021-05-26 08:47:53 +00:00
ObjectYAML [AMDGPU] Add gfx1034 target 2021-05-13 14:25:18 -04:00
Option
Passes Revert "[LoopUnrollAndJam] Change LoopUnrollAndJamPass to LoopNest pass" 2021-05-25 11:39:49 +09:00
ProfileData [CoverageMapping] Handle gaps in counter IDs for source-based coverage 2021-05-19 10:46:38 -07:00
Remarks
Support [SystemZ][z/OS] Implement getHostCPUName for z/OS 2021-05-25 11:18:12 -04:00
TableGen [TableGen] Make the NUL character invalid in .td files 2021-05-13 10:17:45 -04:00
Target [ARM] Add patterns for vmulh 2021-05-26 09:22:12 +01:00
Testing
TextAPI [TextAPI] Reformat llvm_unreachable message 2021-05-11 09:59:26 -07:00
ToolDrivers
Transforms [InstCombine] Fold extractelement + vector GEP with one use 2021-05-26 09:54:26 +01:00
WindowsManifest
XRay
CMakeLists.txt