llvm with tablegen backend for capstone disassembler
Go to file
Sergey Kachkov 3d7df0a547
[RISCV][CostModel] Estimate cost of Extract/InsertElement with non-constant index when vector instructions are not available (#67334)
This patch fixes the compilation time issue of matrix-types-spec test
from test-suite.

Reproduction of the problem:
```
clang++ -DNDEBUG --target=riscv64-linux-gnu --sysroot=<sysroot path> --gcc-toolchain=<gcc path> -O2 -fenable-matrix <test-suite-path>/SingleSource/UnitTests/matrix-types-spec.cpp
```

On my machine, compilation takes 50.44s. In comparison, the same test
with RVV (-march=rv64gcv) compiles in 3.06s, and for x86-64 target it
takes 1.71s. It turns out that the main issue is unrolling of loop in
multiplySpec function, that has extractelements with non-constant index:
```
for.body9.i:                                      ; preds = %for.body9.i, %for.cond6.preheader.i
  %indvars.iv.i92 = phi i64 [ 0, %for.cond6.preheader.i ], [ %indvars.iv.next.i93, %for.body9.i ]
  %Elt.033.i = phi double [ 0.000000e+00, %for.cond6.preheader.i ], [ %80, %for.body9.i ]
  %77 = mul nuw nsw i64 %indvars.iv.i92, 25
  %78 = add nuw nsw i64 %77, %indvars.iv39.i91
  %matrixext.i = extractelement <475 x double> %62, i64 %78
  %79 = add nuw nsw i64 %indvars.iv.i92, %74
  %matrixext13.i = extractelement <209 x double> %73, i64 %79
  %80 = tail call double @llvm.fmuladd.f64(double %matrixext.i, double %matrixext13.i, double %Elt.033.i)
  %indvars.iv.next.i93 = add nuw nsw i64 %indvars.iv.i92, 1
  %exitcond.not.i94 = icmp eq i64 %indvars.iv.next.i93, 19
  br i1 %exitcond.not.i94, label %for.cond.cleanup8.i, label %for.body9.i, !llvm.loop !21
```

When RVV is supported, extractelement/insertelement with non-constant
index can be lowered quite efficiently with vslidedown/vslideup;
otherwise it's lowered via stack memory operations, i.e. for
extractelement each vector element is stored on stack and then the
needed element is loaded back; for insertelement is stores all vector
elements, rewrites the required element value and then loads vector
back. Currently the cost of such expensive operation is estimated as
zero, so loop unroll processes the loop more aggresively. The proper
estimation of cost (in a way like in X86 target) prohibits unrolling of
this loop and fixes compilation time (2.77s on my machine).
2023-09-27 13:12:42 +03:00
.ci [ci] builkite don't escape windows targets (#66192) 2023-09-13 13:02:55 +02:00
.github workflows/pr-receive: Ignore draft pull requests (#66578) 2023-09-26 15:58:04 -07:00
bolt [BOLT][RISCV] Implement LO/HI relocations (#67444) 2023-09-26 15:54:11 +00:00
clang Revert "[NVPTX] Add support for maxclusterrank in launch_bounds (#66496)" 2023-09-27 10:59:04 +02:00
clang-tools-extra [clang-tidy][NFC] Removing lefover AST dump() 2023-09-26 20:24:52 +00:00
cmake
compiler-rt [sanitizer] Add another weak symbol #67491 2023-09-26 23:26:11 -07:00
cross-project-tests [Dexter] Associate parser errors with correct file (#66765) 2023-09-19 14:16:17 +01:00
flang [Flang][OpenMP] NFC: Versions of critical, master tests with HLFIR flow 2023-09-27 06:29:12 +00:00
libc [libc] Scan the ports more fairly in the RPC server (#66680) 2023-09-26 16:09:48 -05:00
libclc libclc: Fix signed integer underflow in abs_diff 2023-08-31 14:28:16 +01:00
libcxx [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated 2023-09-27 09:26:06 +09:00
libcxxabi [libc++][lit] Allow overriding the executor for tests (#66545) 2023-09-26 15:19:31 +01:00
libunwind [libc++][lit] Allow overriding the executor for tests (#66545) 2023-09-26 15:19:31 +01:00
lld [lld-macho][NFC] Remove redundant checks (#67450) 2023-09-26 14:59:18 -07:00
lldb [llvm][tblgen] Add Source Filename for emitSourceFileHeader (#65744) 2023-09-26 13:40:56 +08:00
llvm [RISCV][CostModel] Estimate cost of Extract/InsertElement with non-constant index when vector instructions are not available (#67334) 2023-09-27 13:12:42 +03:00
llvm-libgcc [llvm-libgcc][CMake] Refactor llvm-libgcc (#65455) 2023-09-18 22:56:03 -07:00
mlir Fix MLIR parser to actually error out when hitting a parse error on TensorType encoding field 2023-09-27 01:14:39 -07:00
openmp [Libomptarget] Fix Nvidia offloading hanging on dataRetrieve using RPC (#66817) 2023-09-26 16:03:34 -05:00
polly Move CallInst::CreateFree to IRBuilderBase 2023-09-19 12:04:17 +02:00
pstl
runtimes [llvm-libgcc][CMake] Refactor llvm-libgcc (#65455) 2023-09-18 22:56:03 -07:00
third-party Reland "Update GoogleTest to v1.14.0 (#65823)" 2023-09-13 14:17:24 -07:00
utils [mlir][tosa] Add scaffolding for bytecode version. (#67374) 2023-09-26 11:55:30 -07:00
.arcconfig
.arclint
.clang-format
.clang-tidy
.git-blame-ignore-revs
.gitignore Revert accidental .gitignore change from 9b7763821a 2023-09-07 22:42:05 -07:00
.mailmap
CODE_OF_CONDUCT.md [llvm] Add CODE_OF_CONDUCT.md (#65816) 2023-09-09 10:55:31 -07:00
CONTRIBUTING.md Update CONTRIBUTING.md to remove the not about not accepting PR 2023-09-10 15:21:06 -07:00
LICENSE.TXT
README.md
SECURITY.md

The LLVM Compiler Infrastructure

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.

Other components include: the libc++ C++ standard library, the LLD linker, and more.

Getting the Source Code and Building LLVM

Consult the Getting Started with LLVM page for information on building and running LLVM.

For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.

Getting in touch

Join the LLVM Discourse forums, Discord chat, or #llvm IRC channel on OFTC.

The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.