1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-24 05:23:45 +02:00
llvm-mirror/test
Artur Pilipenko 5f36ddf06d [DAGCombiner] Match load by bytes idiom and fold it into a single load
Match a pattern where a wide type scalar value is loaded by several narrow loads and combined by shifts and ors. Fold it into a single load or a load and a bswap if the targets supports it.

Assuming little endian target:
  i8 *a = ...
  i32 val = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24)
=>
  i32 val = *((i32)a)

  i8 *a = ...
  i32 val = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]
=>
  i32 val = BSWAP(*((i32)a))

This optimization was discussed on llvm-dev some time ago in "Load combine pass" thread. We came to the conclusion that we want to do this transformation late in the pipeline because in presence of atomic loads load widening is irreversible transformation and it might hinder other optimizations.

Eventually we'd like to support folding patterns like this where the offset has a variable and a constant part:
  i32 val = a[i] | (a[i + 1] << 8) | (a[i + 2] << 16) | (a[i + 3] << 24)

Matching the pattern above is easier at SelectionDAG level since address reassociation has already happened and the fact that the loads are adjacent is clear. Understanding that these loads are adjacent at IR level would have involved looking through geps/zexts/adds while looking at the addresses.

The general scheme is to match OR expressions by recursively calculating the origin of individual bits which constitute the resulting OR value. If all the OR bits come from memory verify that they are adjacent and match with little or big endian encoding of a wider value. If so and the load of the wider type (and bswap if needed) is allowed by the target generate a load and a bswap if needed.

Reviewed By: hfinkel, RKSimon, filcab

Differential Revision: https://reviews.llvm.org/D26149

llvm-svn: 289538
2016-12-13 14:21:14 +00:00
..
Analysis [Verifier] Add verification for TBAA metadata 2016-12-11 20:07:15 +00:00
Assembler [DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation 2016-12-05 18:04:47 +00:00
Bindings
Bitcode [DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation 2016-12-05 18:04:47 +00:00
BugPoint
CodeGen [DAGCombiner] Match load by bytes idiom and fold it into a single load 2016-12-13 14:21:14 +00:00
DebugInfo Recommit r288212: Emit 'no line' information for interesting 'orphan' instructions. 2016-12-12 20:49:11 +00:00
Examples
ExecutionEngine
Feature
FileCheck
Instrumentation [Verifier] Add verification for TBAA metadata 2016-12-11 20:07:15 +00:00
Integer
JitListener
LibDriver
Linker [ThinLTO] Stop importing constant global vars as copies in the backend 2016-12-02 01:02:30 +00:00
LTO [LTOs] Allow generation of hotness information 2016-12-02 17:53:56 +00:00
MC [mips] For PIC code convert unconditional jump to unconditional branch 2016-12-12 17:40:26 +00:00
Object llvm/test/Object/archive-thin-create.test: Make sure that %t is empty to stabilize the test. 2016-12-09 11:44:57 +00:00
ObjectYAML [ObjectYAML] Support for DWARF debug_aranges 2016-12-09 00:26:44 +00:00
Other [PM] Further broaden this test's regex as both the CGSCC and Function 2016-12-10 07:59:59 +00:00
SymbolRewriter
TableGen [tablegen] Delete duplicates from a vector without skipping elements 2016-12-01 19:38:50 +00:00
ThinLTO/X86 [ThinLTO] Import only necessary DICompileUnit fields 2016-12-12 16:09:30 +00:00
tools [LIT] Fix system-windows 2016-12-13 00:29:56 +00:00
Transforms [X86][InstCombine] Fix SimplifyDemandedVectorElts to handle frcz scalar intrinsics correctly. 2016-12-13 07:45:45 +00:00
Unit
Verifier [Verifier] Add verification for TBAA metadata 2016-12-11 20:07:15 +00:00
YAMLParser
.clang-format
CMakeLists.txt Add llvm-modextract tool. 2016-11-29 21:54:33 +00:00
lit.cfg Missed a file in r289503. 2016-12-13 00:32:43 +00:00
lit.site.cfg.in
TestRunner.sh