llvm-project/llvm/lib
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 [GlobalISel][Localizer] Rewrite localizer to run in 2 phases, inter & intra block. 2019-06-17 23:20:29 +00:00
AsmParser [SVE][IR] Scalable Vector IR Type with pr42210 fix 2019-06-18 10:11:56 +00:00
BinaryFormat hwasan: Add a tag_offset DWARF attribute to instrumented stack variables. 2019-06-17 23:39:41 +00:00
Bitcode [SVE][IR] Scalable Vector IR Type with pr42210 fix 2019-06-18 10:11:56 +00:00
CodeGen [MachinePipeliner][NFC] Do resource tracking log only when requested. 2019-06-18 20:24:49 +00:00
DebugInfo Symbolize: Remove dead code. NFCI. 2019-06-13 22:49:34 +00:00
Demangle llvm-undname: Correctly demangle vararg parameters 2019-06-04 19:10:08 +00:00
ExecutionEngine [JITLink] Move JITLinkMemoryManager into its own header. 2019-06-14 19:41:21 +00:00
FuzzMutate [opaque pointer types] Pass value type to LoadInst creation. 2019-02-01 20:44:24 +00:00
Fuzzer
IR Add debug location verification for !llvm.loop attachments. 2019-06-18 20:09:09 +00:00
IRReader [IRReader] Expose getLazyIRModule 2019-02-11 22:01:13 +00:00
LTO [Remarks] Extend -fsave-optimization-record to specify the format 2019-06-17 16:06:00 +00:00
LineEditor Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Linker Reapply: IR: add optional type to 'byval' function parameters 2019-05-30 18:48:23 +00:00
MC MCContext: Delete unused functions 2019-06-18 12:30:06 +00:00
MCA [MCA] Ignore invalid processor resource writes of zero cycles. NFCI 2019-06-14 13:31:21 +00:00
Object Share /machine: handling code with llvm-cvtres too 2019-06-12 11:32:43 +00:00
ObjectYAML [yaml2obj] - Allow setting cutom Flags for implicit sections. 2019-06-14 11:01:14 +00:00
Option Option spell checking: Penalize delimiter flags if input has no argument 2019-05-01 16:45:15 +00:00
Passes [Attributor] Pass infrastructure and fixpoint framework 2019-06-05 03:02:24 +00:00
ProfileData [Coverage] Speculative fix for r363325 for an older compiler 2019-06-14 00:03:22 +00:00
Remarks [Remarks] Fix usage of enum class 2019-05-30 22:01:56 +00:00
Support [clang] Add storage for APValue in ConstantExpr 2019-06-15 10:24:47 +00:00
TableGen TableGen: Handle nontrivial foreach range bounds 2019-05-22 21:28:20 +00:00
Target [RISCV] Prevent re-ordering some adds after shifts 2019-06-18 20:38:08 +00:00
Testing [Testing] Move clangd::Annotations to llvm testing support 2019-04-25 10:08:31 +00:00
TextAPI [TextAPI] Fix Symbol::dump which was failing to append the SymbolKind string. 2019-04-29 18:25:04 +00:00
ToolDrivers Share /machine: handling code with llvm-cvtres too 2019-06-12 11:32:43 +00:00
Transforms [coroutines] Add missing pass dependency. 2019-06-18 19:49:48 +00:00
WindowsManifest Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
XRay Recommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef> 2019-05-16 13:24:04 +00:00
CMakeLists.txt [OptRemarks] Make OptRemarks more generic: rename OptRemarks to Remarks 2019-03-05 20:45:17 +00:00
LLVMBuild.txt [OptRemarks] Make OptRemarks more generic: rename OptRemarks to Remarks 2019-03-05 20:45:17 +00:00