1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/include/llvm/Target
Jessica Paquette c4d2d8a4de [GlobalISel] Combine (a[0]) | (a[1] << k1) | ...| (a[m] << kn) into a wide load
This is a restricted version of the combine in `DAGCombiner::MatchLoadCombine`.
(See D27861)

This tries to recognize patterns like below (assuming a little-endian target):

```
s8* x = ...
s32 val = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24)
->
s32 val = *((i32)a)

s8* x = ...
s32 val = a[3] | (a[2] << 8) | (a[1] << 16) | (a[0] << 24)
->
s32 val = BSWAP(*((s32)a))
```

(This patch also handles the big-endian target case as well, in which the first
example above has a BSWAP, and the second example above does not.)

To recognize the pattern, this searches from the last G_OR in the expression
tree.

E.g.

```
    Reg   Reg
     \    /
      OR_1   Reg
       \    /
        OR_2
          \     Reg
           .. /
          Root
```

Each non-OR register in the tree is put in a list. Each register in the list is
then checked to see if it's an appropriate load + shift logic.

If every register is a load + potentially a shift, the combine checks if those
loads + shifts, when OR'd together, are equivalent to a wide load (possibly with
a BSWAP.)

To simplify things, this patch

(1) Only handles G_ZEXTLOADs (which appear to be the common case)
(2) Only works in a single MachineBasicBlock
(3) Only handles G_SHL as the bit twiddling to stick the small load into a
    specific location

An IR example of this is here: https://godbolt.org/z/4sP9Pj (lifted from
test/CodeGen/AArch64/load-combine.ll)

At -Os on AArch64, this is a 0.5% code size improvement for CTMark/sqlite3,
and a 0.4% improvement for CTMark/7zip-benchmark.

Also fix a bug in `isPredecessor` which caused it to fail whenever `DefMI` was
the first instruction in the block.

Differential Revision: https://reviews.llvm.org/D94350
2021-01-19 10:24:27 -08:00
..
GlobalISel [GlobalISel] Combine (a[0]) | (a[1] << k1) | ...| (a[m] << kn) into a wide load 2021-01-19 10:24:27 -08:00
CGPassBuilderOption.h [llvm] Ensure newlines at the end of files (NFC) 2021-01-10 09:24:57 -08:00
CodeGenCWrappers.h
GenericOpcodes.td [TableGen] Clean up Target .td include files 2020-11-17 09:45:14 -05:00
Target.td Prevent FENTRY_CALL reordering 2020-12-09 00:59:01 +01:00
TargetCallingConv.td [TableGen] Clean up Target .td include files 2020-11-17 09:45:14 -05:00
TargetInstrPredicate.td [TableGen] Clean up Target .td include files 2020-11-17 09:45:14 -05:00
TargetIntrinsicInfo.h TargetIntrinsicInfo.h - remove unnecessary Compiler.h include. NFC. 2020-05-19 09:28:13 +01:00
TargetItinerary.td [TableGen] Clean up Target .td include files 2020-11-17 09:45:14 -05:00
TargetLoweringObjectFile.h [NFC] cleanup cg-profile emission on TargetLowerinng 2020-12-14 13:07:44 -08:00
TargetMachine.h [NFC] Rename registerAliasAnalyses -> registerDefaultAliasAnalyses 2021-01-05 11:07:58 -08:00
TargetOptions.h [AIX][XCOFF] emit traceback table for function in aix 2020-12-11 17:50:25 -05:00
TargetPfmCounters.td [TableGen] Clean up Target .td include files 2020-11-17 09:45:14 -05:00
TargetSchedule.td [TableGen] Clean up Target .td include files 2020-11-17 09:45:14 -05:00
TargetSelectionDAG.td [SelectionDAG] Extend immAll(Ones|Zeros)V to handle ISD::SPLAT_VECTOR 2021-01-09 17:05:31 +00:00