llvm-project/llvm/test
Sam Elliott 9f155bc6e5 [RISCV] Prevent re-ordering some adds after shifts
Summary:
DAGCombine will normally turn a `(shl (add x, c1), c2)` into `(add (shl x, c2), c1 << c2)`, where `c1` and `c2` are constants. This can be prevented by a callback in TargetLowering.

On RISC-V, materialising the constant `c1 << c2` can be more expensive than materialising `c1`, because materialising the former may take more instructions, and may use a register, where materialising the latter would not.

This patch implements the hook in RISCVTargetLowering to prevent this transform, in the cases where:
- `c1` fits into the immediate field in an `addi` instruction.
- `c1` takes fewer instructions to materialise than `c1 << c2`.

In future, DAGCombine could do the check to see whether `c1` fits into an add immediate, which might simplify more targets hooks than just RISC-V.

Reviewers: asb, luismarques, efriedma

Reviewed By: asb

Subscribers: xbolva00, lebedev.ri, craig.topper, lewis-revill, Jim, hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, llvm-commits

Tags: #llvm

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

llvm-svn: 363736
2019-06-18 20:38:08 +00:00
..
Analysis [MemorySSA] Don't use template when the clone is a simplified instruction. 2019-06-17 18:58:40 +00:00
Assembler hwasan: Add a tag_offset DWARF attribute to instrumented stack variables. 2019-06-17 23:39:41 +00:00
Bindings
Bitcode [SVE][IR] Scalable Vector IR Type with pr42210 fix 2019-06-18 10:11:56 +00:00
BugPoint
CodeGen [RISCV] Prevent re-ordering some adds after shifts 2019-06-18 20:38:08 +00:00
DebugInfo [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
Demangle llvm-undname: Correctly demangle vararg parameters 2019-06-04 19:10:08 +00:00
Examples
ExecutionEngine [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
Feature
FileCheck FileCheck [6/12]: Introduce numeric variable definition 2019-06-06 13:21:06 +00:00
Instrumentation hwasan: Use bits [3..11) of the ring buffer entry address as the base stack tag. 2019-06-17 23:39:51 +00:00
Integer
JitListener [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
LTO [ThinLTO]LTO]Legacy] Fix dependent libraries support by adding querying of the IRSymtab 2019-06-12 11:07:56 +00:00
Linker Reapply: IR: add optional type to 'byval' function parameters 2019-05-30 18:48:23 +00:00
MC [ARM] Add MVE vector shift instructions. 2019-06-18 16:19:59 +00:00
MachineVerifier GlobalISel: Verify intrinsics 2019-06-17 17:01:32 +00:00
Object [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
ObjectYAML [yaml2obj][MachO] Don't fill dummy data for virtual sections 2019-06-17 02:07:20 +00:00
Other [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
SafepointIRVerifier
Support
SymbolRewriter
TableGen
ThinLTO/X86 [Remarks] Extend -fsave-optimization-record to specify the format 2019-06-17 16:06:00 +00:00
Transforms Fix broken debug info in in an !llvm.loop attachment in this testcase. 2019-06-18 20:07:53 +00:00
Unit
Verifier Add debug location verification for !llvm.loop attachments. 2019-06-18 20:09:09 +00:00
YAMLParser
tools [llvm-readobj] Allow --hex-dump/--string-dump to dump multiple sections 2019-06-18 14:01:03 +00:00
.clang-format
CMakeLists.txt [tools] Introduce llvm-lipo 2019-05-28 23:22:12 +00:00
TestRunner.sh
lit.cfg.py
lit.site.cfg.py.in