2018-11-17 01:48:52 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2018-11-19 20:29:41 +08:00
|
|
|
; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefixes=CHECK,X86,X86-FAST
|
|
|
|
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+slow-shld | FileCheck %s --check-prefixes=CHECK,X86,X86-SLOW
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=CHECK,X64,X64-FAST
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+slow-shld | FileCheck %s --check-prefixes=CHECK,X64,X64-SLOW
|
2018-11-17 01:48:52 +08:00
|
|
|
|
|
|
|
declare i8 @llvm.fshl.i8(i8, i8, i8) nounwind readnone
|
|
|
|
declare i16 @llvm.fshl.i16(i16, i16, i16) nounwind readnone
|
|
|
|
declare i32 @llvm.fshl.i32(i32, i32, i32) nounwind readnone
|
|
|
|
declare i64 @llvm.fshl.i64(i64, i64, i64) nounwind readnone
|
|
|
|
|
|
|
|
;
|
|
|
|
; Variable Funnel Shift
|
|
|
|
;
|
|
|
|
|
|
|
|
define i8 @var_shift_i8(i8 %x, i8 %y, i8 %z) nounwind {
|
|
|
|
; X86-LABEL: var_shift_i8:
|
|
|
|
; X86: # %bb.0:
|
2020-05-24 15:08:34 +08:00
|
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-NEXT: movzbl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: shll $8, %eax
|
|
|
|
; X86-NEXT: orl %edx, %eax
|
|
|
|
; X86-NEXT: andb $7, %cl
|
|
|
|
; X86-NEXT: shll %cl, %eax
|
|
|
|
; X86-NEXT: movb %ah, %al
|
2018-11-17 01:48:52 +08:00
|
|
|
; X86-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: var_shift_i8:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movl %edx, %ecx
|
2020-05-24 15:08:34 +08:00
|
|
|
; X64-NEXT: shll $8, %edi
|
[X86] Promote i8 CMOV's (PR40965)
Summary:
@mclow.lists brought up this issue up in IRC, it came up during
implementation of libc++ `std::midpoint()` implementation (D59099)
https://godbolt.org/z/oLrHBP
Currently LLVM X86 backend only promotes i8 CMOV if it came from 2x`trunc`.
This differential proposes to always promote i8 CMOV.
There are several concerns here:
* Is this actually more performant, or is it just the ASM that looks cuter?
* Does this result in partial register stalls?
* What about branch predictor?
# Indeed, performance should be the main point here.
Let's look at a simple microbenchmark: {F8412076}
```
#include "benchmark/benchmark.h"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iterator>
#include <limits>
#include <random>
#include <type_traits>
#include <utility>
#include <vector>
// Future preliminary libc++ code, from Marshall Clow.
namespace std {
template <class _Tp>
__inline _Tp midpoint(_Tp __a, _Tp __b) noexcept {
using _Up = typename std::make_unsigned<typename remove_cv<_Tp>::type>::type;
int __sign = 1;
_Up __m = __a;
_Up __M = __b;
if (__a > __b) {
__sign = -1;
__m = __b;
__M = __a;
}
return __a + __sign * _Tp(_Up(__M - __m) >> 1);
}
} // namespace std
template <typename T>
std::vector<T> getVectorOfRandomNumbers(size_t count) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<T> dis(std::numeric_limits<T>::min(),
std::numeric_limits<T>::max());
std::vector<T> v;
v.reserve(count);
std::generate_n(std::back_inserter(v), count,
[&dis, &gen]() { return dis(gen); });
assert(v.size() == count);
return v;
}
struct RandRand {
template <typename T>
static std::pair<std::vector<T>, std::vector<T>> Gen(size_t count) {
return std::make_pair(getVectorOfRandomNumbers<T>(count),
getVectorOfRandomNumbers<T>(count));
}
};
struct ZeroRand {
template <typename T>
static std::pair<std::vector<T>, std::vector<T>> Gen(size_t count) {
return std::make_pair(std::vector<T>(count, T(0)),
getVectorOfRandomNumbers<T>(count));
}
};
template <class T, class Gen>
void BM_StdMidpoint(benchmark::State& state) {
const size_t Length = state.range(0);
const std::pair<std::vector<T>, std::vector<T>> Data =
Gen::template Gen<T>(Length);
const std::vector<T>& a = Data.first;
const std::vector<T>& b = Data.second;
assert(a.size() == Length && b.size() == a.size());
benchmark::ClobberMemory();
benchmark::DoNotOptimize(a);
benchmark::DoNotOptimize(a.data());
benchmark::DoNotOptimize(b);
benchmark::DoNotOptimize(b.data());
for (auto _ : state) {
for (size_t i = 0; i < Length; i++) {
const auto calculated = std::midpoint(a[i], b[i]);
benchmark::DoNotOptimize(calculated);
}
}
state.SetComplexityN(Length);
state.counters["midpoints"] =
benchmark::Counter(Length, benchmark::Counter::kIsIterationInvariant);
state.counters["midpoints/sec"] =
benchmark::Counter(Length, benchmark::Counter::kIsIterationInvariantRate);
const size_t BytesRead = 2 * sizeof(T) * Length;
state.counters["bytes_read/iteration"] =
benchmark::Counter(BytesRead, benchmark::Counter::kDefaults,
benchmark::Counter::OneK::kIs1024);
state.counters["bytes_read/sec"] = benchmark::Counter(
BytesRead, benchmark::Counter::kIsIterationInvariantRate,
benchmark::Counter::OneK::kIs1024);
}
template <typename T>
static void CustomArguments(benchmark::internal::Benchmark* b) {
const size_t L2SizeBytes = 2 * 1024 * 1024;
// What is the largest range we can check to always fit within given L2 cache?
const size_t MaxLen = L2SizeBytes / /*total bufs*/ 2 /
/*maximal elt size*/ sizeof(T) / /*safety margin*/ 2;
b->RangeMultiplier(2)->Range(1, MaxLen)->Complexity(benchmark::oN);
}
// Both of the values are random.
// The comparison is unpredictable.
BENCHMARK_TEMPLATE(BM_StdMidpoint, int32_t, RandRand)
->Apply(CustomArguments<int32_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint32_t, RandRand)
->Apply(CustomArguments<uint32_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, int64_t, RandRand)
->Apply(CustomArguments<int64_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint64_t, RandRand)
->Apply(CustomArguments<uint64_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, int16_t, RandRand)
->Apply(CustomArguments<int16_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint16_t, RandRand)
->Apply(CustomArguments<uint16_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, int8_t, RandRand)
->Apply(CustomArguments<int8_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint8_t, RandRand)
->Apply(CustomArguments<uint8_t>);
// One value is always zero, and another is bigger or equal than zero.
// The comparison is predictable.
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint32_t, ZeroRand)
->Apply(CustomArguments<uint32_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint64_t, ZeroRand)
->Apply(CustomArguments<uint64_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint16_t, ZeroRand)
->Apply(CustomArguments<uint16_t>);
BENCHMARK_TEMPLATE(BM_StdMidpoint, uint8_t, ZeroRand)
->Apply(CustomArguments<uint8_t>);
```
```
$ ~/src/googlebenchmark/tools/compare.py --no-utest benchmarks ./llvm-cmov-bench-OLD ./llvm-cmov-bench-NEW
RUNNING: ./llvm-cmov-bench-OLD --benchmark_out=/tmp/tmp5a5qjm
2019-03-06 21:53:31
Running ./llvm-cmov-bench-OLD
Run on (8 X 4000 MHz CPU s)
CPU Caches:
L1 Data 16K (x8)
L1 Instruction 64K (x4)
L2 Unified 2048K (x4)
L3 Unified 8192K (x1)
Load Average: 1.78, 1.81, 1.36
----------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters<...>
----------------------------------------------------------------------------------------------------
<...>
BM_StdMidpoint<int32_t, RandRand>/131072 300398 ns 300404 ns 2330 bytes_read/iteration=1024k bytes_read/sec=3.25083G/s midpoints=305.398M midpoints/sec=436.319M/s
BM_StdMidpoint<int32_t, RandRand>_BigO 2.29 N 2.29 N
BM_StdMidpoint<int32_t, RandRand>_RMS 2 % 2 %
<...>
BM_StdMidpoint<uint32_t, RandRand>/131072 300433 ns 300433 ns 2330 bytes_read/iteration=1024k bytes_read/sec=3.25052G/s midpoints=305.398M midpoints/sec=436.278M/s
BM_StdMidpoint<uint32_t, RandRand>_BigO 2.29 N 2.29 N
BM_StdMidpoint<uint32_t, RandRand>_RMS 2 % 2 %
<...>
BM_StdMidpoint<int64_t, RandRand>/65536 169857 ns 169858 ns 4121 bytes_read/iteration=1024k bytes_read/sec=5.74929G/s midpoints=270.074M midpoints/sec=385.828M/s
BM_StdMidpoint<int64_t, RandRand>_BigO 2.59 N 2.59 N
BM_StdMidpoint<int64_t, RandRand>_RMS 3 % 3 %
<...>
BM_StdMidpoint<uint64_t, RandRand>/65536 169770 ns 169771 ns 4125 bytes_read/iteration=1024k bytes_read/sec=5.75223G/s midpoints=270.336M midpoints/sec=386.026M/s
BM_StdMidpoint<uint64_t, RandRand>_BigO 2.59 N 2.59 N
BM_StdMidpoint<uint64_t, RandRand>_RMS 3 % 3 %
<...>
BM_StdMidpoint<int16_t, RandRand>/262144 591169 ns 591179 ns 1182 bytes_read/iteration=1024k bytes_read/sec=1.65189G/s midpoints=309.854M midpoints/sec=443.426M/s
BM_StdMidpoint<int16_t, RandRand>_BigO 2.25 N 2.25 N
BM_StdMidpoint<int16_t, RandRand>_RMS 1 % 1 %
<...>
BM_StdMidpoint<uint16_t, RandRand>/262144 591264 ns 591274 ns 1184 bytes_read/iteration=1024k bytes_read/sec=1.65162G/s midpoints=310.378M midpoints/sec=443.354M/s
BM_StdMidpoint<uint16_t, RandRand>_BigO 2.25 N 2.25 N
BM_StdMidpoint<uint16_t, RandRand>_RMS 1 % 1 %
<...>
BM_StdMidpoint<int8_t, RandRand>/524288 2983669 ns 2983689 ns 235 bytes_read/iteration=1024k bytes_read/sec=335.156M/s midpoints=123.208M midpoints/sec=175.718M/s
BM_StdMidpoint<int8_t, RandRand>_BigO 5.69 N 5.69 N
BM_StdMidpoint<int8_t, RandRand>_RMS 0 % 0 %
<...>
BM_StdMidpoint<uint8_t, RandRand>/524288 2668398 ns 2668419 ns 262 bytes_read/iteration=1024k bytes_read/sec=374.754M/s midpoints=137.363M midpoints/sec=196.479M/s
BM_StdMidpoint<uint8_t, RandRand>_BigO 5.09 N 5.09 N
BM_StdMidpoint<uint8_t, RandRand>_RMS 0 % 0 %
<...>
BM_StdMidpoint<uint32_t, ZeroRand>/131072 300887 ns 300887 ns 2331 bytes_read/iteration=1024k bytes_read/sec=3.24561G/s midpoints=305.529M midpoints/sec=435.619M/s
BM_StdMidpoint<uint32_t, ZeroRand>_BigO 2.29 N 2.29 N
BM_StdMidpoint<uint32_t, ZeroRand>_RMS 2 % 2 %
<...>
BM_StdMidpoint<uint64_t, ZeroRand>/65536 169634 ns 169634 ns 4102 bytes_read/iteration=1024k bytes_read/sec=5.75688G/s midpoints=268.829M midpoints/sec=386.338M/s
BM_StdMidpoint<uint64_t, ZeroRand>_BigO 2.59 N 2.59 N
BM_StdMidpoint<uint64_t, ZeroRand>_RMS 3 % 3 %
<...>
BM_StdMidpoint<uint16_t, ZeroRand>/262144 592252 ns 592255 ns 1182 bytes_read/iteration=1024k bytes_read/sec=1.64889G/s midpoints=309.854M midpoints/sec=442.62M/s
BM_StdMidpoint<uint16_t, ZeroRand>_BigO 2.26 N 2.26 N
BM_StdMidpoint<uint16_t, ZeroRand>_RMS 1 % 1 %
<...>
BM_StdMidpoint<uint8_t, ZeroRand>/524288 987295 ns 987309 ns 711 bytes_read/iteration=1024k bytes_read/sec=1012.85M/s midpoints=372.769M midpoints/sec=531.028M/s
BM_StdMidpoint<uint8_t, ZeroRand>_BigO 1.88 N 1.88 N
BM_StdMidpoint<uint8_t, ZeroRand>_RMS 1 % 1 %
RUNNING: ./llvm-cmov-bench-NEW --benchmark_out=/tmp/tmpPvwpfW
2019-03-06 21:56:58
Running ./llvm-cmov-bench-NEW
Run on (8 X 4000 MHz CPU s)
CPU Caches:
L1 Data 16K (x8)
L1 Instruction 64K (x4)
L2 Unified 2048K (x4)
L3 Unified 8192K (x1)
Load Average: 1.17, 1.46, 1.30
----------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters<...>
----------------------------------------------------------------------------------------------------
<...>
BM_StdMidpoint<int32_t, RandRand>/131072 300878 ns 300880 ns 2324 bytes_read/iteration=1024k bytes_read/sec=3.24569G/s midpoints=304.611M midpoints/sec=435.629M/s
BM_StdMidpoint<int32_t, RandRand>_BigO 2.29 N 2.29 N
BM_StdMidpoint<int32_t, RandRand>_RMS 2 % 2 %
<...>
BM_StdMidpoint<uint32_t, RandRand>/131072 300231 ns 300226 ns 2330 bytes_read/iteration=1024k bytes_read/sec=3.25276G/s midpoints=305.398M midpoints/sec=436.578M/s
BM_StdMidpoint<uint32_t, RandRand>_BigO 2.29 N 2.29 N
BM_StdMidpoint<uint32_t, RandRand>_RMS 2 % 2 %
<...>
BM_StdMidpoint<int64_t, RandRand>/65536 170819 ns 170777 ns 4115 bytes_read/iteration=1024k bytes_read/sec=5.71835G/s midpoints=269.681M midpoints/sec=383.752M/s
BM_StdMidpoint<int64_t, RandRand>_BigO 2.60 N 2.60 N
BM_StdMidpoint<int64_t, RandRand>_RMS 3 % 3 %
<...>
BM_StdMidpoint<uint64_t, RandRand>/65536 171705 ns 171708 ns 4106 bytes_read/iteration=1024k bytes_read/sec=5.68733G/s midpoints=269.091M midpoints/sec=381.671M/s
BM_StdMidpoint<uint64_t, RandRand>_BigO 2.62 N 2.62 N
BM_StdMidpoint<uint64_t, RandRand>_RMS 3 % 3 %
<...>
BM_StdMidpoint<int16_t, RandRand>/262144 592510 ns 592516 ns 1182 bytes_read/iteration=1024k bytes_read/sec=1.64816G/s midpoints=309.854M midpoints/sec=442.425M/s
BM_StdMidpoint<int16_t, RandRand>_BigO 2.26 N 2.26 N
BM_StdMidpoint<int16_t, RandRand>_RMS 1 % 1 %
<...>
BM_StdMidpoint<uint16_t, RandRand>/262144 614823 ns 614823 ns 1180 bytes_read/iteration=1024k bytes_read/sec=1.58836G/s midpoints=309.33M midpoints/sec=426.373M/s
BM_StdMidpoint<uint16_t, RandRand>_BigO 2.33 N 2.33 N
BM_StdMidpoint<uint16_t, RandRand>_RMS 4 % 4 %
<...>
BM_StdMidpoint<int8_t, RandRand>/524288 1073181 ns 1073201 ns 650 bytes_read/iteration=1024k bytes_read/sec=931.791M/s midpoints=340.787M midpoints/sec=488.527M/s
BM_StdMidpoint<int8_t, RandRand>_BigO 2.05 N 2.05 N
BM_StdMidpoint<int8_t, RandRand>_RMS 1 % 1 %
BM_StdMidpoint<uint8_t, RandRand>/524288 1071010 ns 1071020 ns 653 bytes_read/iteration=1024k bytes_read/sec=933.689M/s midpoints=342.36M midpoints/sec=489.522M/s
BM_StdMidpoint<uint8_t, RandRand>_BigO 2.05 N 2.05 N
BM_StdMidpoint<uint8_t, RandRand>_RMS 1 % 1 %
<...>
BM_StdMidpoint<uint32_t, ZeroRand>/131072 300413 ns 300416 ns 2330 bytes_read/iteration=1024k bytes_read/sec=3.2507G/s midpoints=305.398M midpoints/sec=436.302M/s
BM_StdMidpoint<uint32_t, ZeroRand>_BigO 2.29 N 2.29 N
BM_StdMidpoint<uint32_t, ZeroRand>_RMS 2 % 2 %
<...>
BM_StdMidpoint<uint64_t, ZeroRand>/65536 169667 ns 169669 ns 4123 bytes_read/iteration=1024k bytes_read/sec=5.75568G/s midpoints=270.205M midpoints/sec=386.257M/s
BM_StdMidpoint<uint64_t, ZeroRand>_BigO 2.59 N 2.59 N
BM_StdMidpoint<uint64_t, ZeroRand>_RMS 3 % 3 %
<...>
BM_StdMidpoint<uint16_t, ZeroRand>/262144 591396 ns 591404 ns 1184 bytes_read/iteration=1024k bytes_read/sec=1.65126G/s midpoints=310.378M midpoints/sec=443.257M/s
BM_StdMidpoint<uint16_t, ZeroRand>_BigO 2.26 N 2.26 N
BM_StdMidpoint<uint16_t, ZeroRand>_RMS 1 % 1 %
<...>
BM_StdMidpoint<uint8_t, ZeroRand>/524288 1069421 ns 1069413 ns 655 bytes_read/iteration=1024k bytes_read/sec=935.092M/s midpoints=343.409M midpoints/sec=490.258M/s
BM_StdMidpoint<uint8_t, ZeroRand>_BigO 2.04 N 2.04 N
BM_StdMidpoint<uint8_t, ZeroRand>_RMS 0 % 0 %
Comparing ./llvm-cmov-bench-OLD to ./llvm-cmov-bench-NEW
Benchmark Time CPU Time Old Time New CPU Old CPU New
----------------------------------------------------------------------------------------------------------------------------------------
<...>
BM_StdMidpoint<int32_t, RandRand>/131072 +0.0016 +0.0016 300398 300878 300404 300880
<...>
BM_StdMidpoint<uint32_t, RandRand>/131072 -0.0007 -0.0007 300433 300231 300433 300226
<...>
BM_StdMidpoint<int64_t, RandRand>/65536 +0.0057 +0.0054 169857 170819 169858 170777
<...>
BM_StdMidpoint<uint64_t, RandRand>/65536 +0.0114 +0.0114 169770 171705 169771 171708
<...>
BM_StdMidpoint<int16_t, RandRand>/262144 +0.0023 +0.0023 591169 592510 591179 592516
<...>
BM_StdMidpoint<uint16_t, RandRand>/262144 +0.0398 +0.0398 591264 614823 591274 614823
<...>
BM_StdMidpoint<int8_t, RandRand>/524288 -0.6403 -0.6403 2983669 1073181 2983689 1073201
<...>
BM_StdMidpoint<uint8_t, RandRand>/524288 -0.5986 -0.5986 2668398 1071010 2668419 1071020
<...>
BM_StdMidpoint<uint32_t, ZeroRand>/131072 -0.0016 -0.0016 300887 300413 300887 300416
<...>
BM_StdMidpoint<uint64_t, ZeroRand>/65536 +0.0002 +0.0002 169634 169667 169634 169669
<...>
BM_StdMidpoint<uint16_t, ZeroRand>/262144 -0.0014 -0.0014 592252 591396 592255 591404
<...>
BM_StdMidpoint<uint8_t, ZeroRand>/524288 +0.0832 +0.0832 987295 1069421 987309 1069413
```
What can we tell from the benchmark?
* `BM_StdMidpoint<[u]int8_t, RandRand>` indeed has the worst performance.
* All `BM_StdMidpoint<uint{8,16,32}_t, ZeroRand>` are all performant, even the 8-bit case.
That is because there we are computing mid point between zero and some random number,
thus if the branch predictor is in use, it is in optimal situation.
* Promoting 8-bit CMOV did improve performance of `BM_StdMidpoint<[u]int8_t, RandRand>`, by -59%..-64%.
# What about branch predictor?
* `BM_StdMidpoint<uint8_t, ZeroRand>` was faster than `BM_StdMidpoint<uint{16,32,64}_t, ZeroRand>`,
which may mean that well-predicted branch is better than `cmov`.
* Promoting 8-bit CMOV degraded performance of `BM_StdMidpoint<uint8_t, ZeroRand>`,
`cmov` is up to +10% worse than well-predicted branch.
* However, i do not believe this is a concern. If the branch is well predicted, then the PGO
will also say that it is well predicted, and LLVM will happily expand cmov back into branch:
https://godbolt.org/z/P5ufig
# What about partial register stalls?
I'm not really able to answer that.
What i can say is that if the branch is unpredictable (if it is predictable, then use PGO and you'll have branch)
in ~50% of cases you will have to pay branch misprediction penalty.
```
$ grep -i MispredictPenalty X86Sched*.td
X86SchedBroadwell.td: let MispredictPenalty = 16;
X86SchedHaswell.td: let MispredictPenalty = 16;
X86SchedSandyBridge.td: let MispredictPenalty = 16;
X86SchedSkylakeClient.td: let MispredictPenalty = 14;
X86SchedSkylakeServer.td: let MispredictPenalty = 14;
X86ScheduleBdVer2.td: let MispredictPenalty = 20; // Minimum branch misdirection penalty.
X86ScheduleBtVer2.td: let MispredictPenalty = 14; // Minimum branch misdirection penalty
X86ScheduleSLM.td: let MispredictPenalty = 10;
X86ScheduleZnver1.td: let MispredictPenalty = 17;
```
.. which it can be as small as 10 cycles and as large as 20 cycles.
Partial register stalls do not seem to be an issue for AMD CPU's.
For intel CPU's, they should be around ~5 cycles?
Is that actually an issue here? I'm not sure.
In short, i'd say this is an improvement, at least on this microbenchmark.
Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40965 | PR40965 ]].
Reviewers: craig.topper, RKSimon, spatel, andreadb, nikic
Reviewed By: craig.topper, andreadb
Subscribers: jfb, jdoerfert, llvm-commits, mclow.lists
Tags: #llvm, #libc
Differential Revision: https://reviews.llvm.org/D59035
llvm-svn: 356300
2019-03-16 05:17:53 +08:00
|
|
|
; X64-NEXT: movzbl %sil, %eax
|
2020-05-24 15:08:34 +08:00
|
|
|
; X64-NEXT: orl %edi, %eax
|
|
|
|
; X64-NEXT: andb $7, %cl
|
|
|
|
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
|
|
|
|
; X64-NEXT: shll %cl, %eax
|
|
|
|
; X64-NEXT: shrl $8, %eax
|
2018-11-17 01:48:52 +08:00
|
|
|
; X64-NEXT: # kill: def $al killed $al killed $eax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
%tmp = tail call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %z)
|
|
|
|
ret i8 %tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @var_shift_i16(i16 %x, i16 %y, i16 %z) nounwind {
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-LABEL: var_shift_i16:
|
|
|
|
; X86-FAST: # %bb.0:
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-FAST-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-FAST-NEXT: andb $15, %cl
|
|
|
|
; X86-FAST-NEXT: shldw %cl, %dx, %ax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-NEXT: retl
|
2018-11-17 01:48:52 +08:00
|
|
|
;
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-LABEL: var_shift_i16:
|
|
|
|
; X86-SLOW: # %bb.0:
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: movb {{[0-9]+}}(%esp), %cl
|
2020-05-24 15:08:34 +08:00
|
|
|
; X86-SLOW-NEXT: movzwl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-SLOW-NEXT: shll $16, %eax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: orl %edx, %eax
|
2020-05-24 15:08:34 +08:00
|
|
|
; X86-SLOW-NEXT: andb $15, %cl
|
|
|
|
; X86-SLOW-NEXT: shll %cl, %eax
|
|
|
|
; X86-SLOW-NEXT: shrl $16, %eax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
|
|
|
|
; X86-SLOW-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-FAST-LABEL: var_shift_i16:
|
|
|
|
; X64-FAST: # %bb.0:
|
|
|
|
; X64-FAST-NEXT: movl %edx, %ecx
|
|
|
|
; X64-FAST-NEXT: movl %edi, %eax
|
2018-12-05 19:12:12 +08:00
|
|
|
; X64-FAST-NEXT: andb $15, %cl
|
|
|
|
; X64-FAST-NEXT: # kill: def $cl killed $cl killed $ecx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-FAST-NEXT: shldw %cl, %si, %ax
|
|
|
|
; X64-FAST-NEXT: # kill: def $ax killed $ax killed $eax
|
|
|
|
; X64-FAST-NEXT: retq
|
|
|
|
;
|
|
|
|
; X64-SLOW-LABEL: var_shift_i16:
|
|
|
|
; X64-SLOW: # %bb.0:
|
|
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
2020-05-24 15:08:34 +08:00
|
|
|
; X64-SLOW-NEXT: shll $16, %edi
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: movzwl %si, %eax
|
2020-05-24 15:08:34 +08:00
|
|
|
; X64-SLOW-NEXT: orl %edi, %eax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: andb $15, %cl
|
|
|
|
; X64-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
|
2020-05-24 15:08:34 +08:00
|
|
|
; X64-SLOW-NEXT: shll %cl, %eax
|
|
|
|
; X64-SLOW-NEXT: shrl $16, %eax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
|
|
|
|
; X64-SLOW-NEXT: retq
|
2018-11-17 01:48:52 +08:00
|
|
|
%tmp = tail call i16 @llvm.fshl.i16(i16 %x, i16 %y, i16 %z)
|
|
|
|
ret i16 %tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @var_shift_i32(i32 %x, i32 %y, i32 %z) nounwind {
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-LABEL: var_shift_i32:
|
|
|
|
; X86-FAST: # %bb.0:
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-NEXT: shldl %cl, %edx, %eax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-NEXT: retl
|
2018-11-17 01:48:52 +08:00
|
|
|
;
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-LABEL: var_shift_i32:
|
|
|
|
; X86-SLOW: # %bb.0:
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-SLOW-NEXT: shll %cl, %edx
|
2020-05-24 18:25:09 +08:00
|
|
|
; X86-SLOW-NEXT: notb %cl
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: shrl %eax
|
|
|
|
; X86-SLOW-NEXT: shrl %cl, %eax
|
|
|
|
; X86-SLOW-NEXT: orl %edx, %eax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-FAST-LABEL: var_shift_i32:
|
|
|
|
; X64-FAST: # %bb.0:
|
|
|
|
; X64-FAST-NEXT: movl %edx, %ecx
|
|
|
|
; X64-FAST-NEXT: movl %edi, %eax
|
2018-12-05 19:12:12 +08:00
|
|
|
; X64-FAST-NEXT: # kill: def $cl killed $cl killed $ecx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-FAST-NEXT: shldl %cl, %esi, %eax
|
|
|
|
; X64-FAST-NEXT: retq
|
|
|
|
;
|
|
|
|
; X64-SLOW-LABEL: var_shift_i32:
|
|
|
|
; X64-SLOW: # %bb.0:
|
|
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: movl %esi, %eax
|
|
|
|
; X64-SLOW-NEXT: shll %cl, %edi
|
|
|
|
; X64-SLOW-NEXT: shrl %eax
|
2020-05-24 18:25:09 +08:00
|
|
|
; X64-SLOW-NEXT: notb %cl
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: # kill: def $cl killed $cl killed $ecx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-SLOW-NEXT: shrl %cl, %eax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: orl %edi, %eax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-SLOW-NEXT: retq
|
2018-11-17 01:48:52 +08:00
|
|
|
%tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)
|
|
|
|
ret i32 %tmp
|
|
|
|
}
|
|
|
|
|
2018-12-16 03:32:26 +08:00
|
|
|
define i32 @var_shift_i32_optsize(i32 %x, i32 %y, i32 %z) nounwind optsize {
|
2018-12-16 03:43:44 +08:00
|
|
|
; X86-LABEL: var_shift_i32_optsize:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: shldl %cl, %edx, %eax
|
|
|
|
; X86-NEXT: retl
|
2018-12-16 03:32:26 +08:00
|
|
|
;
|
2018-12-16 03:43:44 +08:00
|
|
|
; X64-LABEL: var_shift_i32_optsize:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movl %edx, %ecx
|
|
|
|
; X64-NEXT: movl %edi, %eax
|
|
|
|
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
|
|
|
|
; X64-NEXT: shldl %cl, %esi, %eax
|
|
|
|
; X64-NEXT: retq
|
2018-12-16 03:32:26 +08:00
|
|
|
%tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)
|
|
|
|
ret i32 %tmp
|
|
|
|
}
|
|
|
|
|
[PGO][PGSO] Enable size optimizations in code gen / target passes for cold code.
Summary: Split off of D67120.
Reviewers: davidxl
Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71288
2019-11-08 00:52:05 +08:00
|
|
|
define i32 @var_shift_i32_pgso(i32 %x, i32 %y, i32 %z) nounwind !prof !14 {
|
|
|
|
; X86-LABEL: var_shift_i32_pgso:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: shldl %cl, %edx, %eax
|
|
|
|
; X86-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: var_shift_i32_pgso:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movl %edx, %ecx
|
|
|
|
; X64-NEXT: movl %edi, %eax
|
|
|
|
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
|
|
|
|
; X64-NEXT: shldl %cl, %esi, %eax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
%tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)
|
|
|
|
ret i32 %tmp
|
|
|
|
}
|
|
|
|
|
2018-11-17 01:48:52 +08:00
|
|
|
define i64 @var_shift_i64(i64 %x, i64 %y, i64 %z) nounwind {
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-LABEL: var_shift_i64:
|
|
|
|
; X86-FAST: # %bb.0:
|
|
|
|
; X86-FAST-NEXT: pushl %ebx
|
|
|
|
; X86-FAST-NEXT: pushl %edi
|
|
|
|
; X86-FAST-NEXT: pushl %esi
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ebx
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edi
|
|
|
|
; X86-FAST-NEXT: movb {{[0-9]+}}(%esp), %ch
|
|
|
|
; X86-FAST-NEXT: movb %ch, %cl
|
|
|
|
; X86-FAST-NEXT: notb %cl
|
|
|
|
; X86-FAST-NEXT: shrdl $1, %edi, %esi
|
|
|
|
; X86-FAST-NEXT: shrl %edi
|
|
|
|
; X86-FAST-NEXT: shrdl %cl, %edi, %esi
|
|
|
|
; X86-FAST-NEXT: shrl %cl, %edi
|
|
|
|
; X86-FAST-NEXT: testb $32, %cl
|
[PGO][PGSO] Enable size optimizations in code gen / target passes for cold code.
Summary: Split off of D67120.
Reviewers: davidxl
Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71288
2019-11-08 00:52:05 +08:00
|
|
|
; X86-FAST-NEXT: je .LBB5_2
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-NEXT: # %bb.1:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-FAST-NEXT: movl %edi, %esi
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-NEXT: xorl %edi, %edi
|
[PGO][PGSO] Enable size optimizations in code gen / target passes for cold code.
Summary: Split off of D67120.
Reviewers: davidxl
Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71288
2019-11-08 00:52:05 +08:00
|
|
|
; X86-FAST-NEXT: .LBB5_2:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-FAST-NEXT: movl %ebx, %eax
|
|
|
|
; X86-FAST-NEXT: movb %ch, %cl
|
|
|
|
; X86-FAST-NEXT: shll %cl, %eax
|
|
|
|
; X86-FAST-NEXT: shldl %cl, %ebx, %edx
|
|
|
|
; X86-FAST-NEXT: testb $32, %ch
|
|
|
|
; X86-FAST-NEXT: je .LBB5_4
|
|
|
|
; X86-FAST-NEXT: # %bb.3:
|
|
|
|
; X86-FAST-NEXT: movl %eax, %edx
|
|
|
|
; X86-FAST-NEXT: xorl %eax, %eax
|
|
|
|
; X86-FAST-NEXT: .LBB5_4:
|
|
|
|
; X86-FAST-NEXT: orl %edi, %edx
|
|
|
|
; X86-FAST-NEXT: orl %esi, %eax
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-FAST-NEXT: popl %esi
|
|
|
|
; X86-FAST-NEXT: popl %edi
|
|
|
|
; X86-FAST-NEXT: popl %ebx
|
|
|
|
; X86-FAST-NEXT: retl
|
|
|
|
;
|
|
|
|
; X86-SLOW-LABEL: var_shift_i64:
|
|
|
|
; X86-SLOW: # %bb.0:
|
|
|
|
; X86-SLOW-NEXT: pushl %ebp
|
|
|
|
; X86-SLOW-NEXT: pushl %ebx
|
|
|
|
; X86-SLOW-NEXT: pushl %edi
|
|
|
|
; X86-SLOW-NEXT: pushl %esi
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ebx
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %esi
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: shrl %eax
|
|
|
|
; X86-SLOW-NEXT: movl %esi, %edi
|
|
|
|
; X86-SLOW-NEXT: shll $31, %edi
|
|
|
|
; X86-SLOW-NEXT: orl %eax, %edi
|
|
|
|
; X86-SLOW-NEXT: movl %ecx, %eax
|
|
|
|
; X86-SLOW-NEXT: movb %cl, %ch
|
|
|
|
; X86-SLOW-NEXT: notb %ch
|
|
|
|
; X86-SLOW-NEXT: movb %ch, %cl
|
|
|
|
; X86-SLOW-NEXT: shrl %cl, %edi
|
|
|
|
; X86-SLOW-NEXT: shrl %esi
|
|
|
|
; X86-SLOW-NEXT: leal (%esi,%esi), %ebp
|
|
|
|
; X86-SLOW-NEXT: movb %al, %cl
|
|
|
|
; X86-SLOW-NEXT: shll %cl, %ebp
|
|
|
|
; X86-SLOW-NEXT: shll %cl, %ebx
|
|
|
|
; X86-SLOW-NEXT: movl %edx, %eax
|
|
|
|
; X86-SLOW-NEXT: shrl %eax
|
|
|
|
; X86-SLOW-NEXT: movb %ch, %cl
|
|
|
|
; X86-SLOW-NEXT: shrl %cl, %eax
|
|
|
|
; X86-SLOW-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-SLOW-NEXT: shll %cl, %edx
|
|
|
|
; X86-SLOW-NEXT: testb $32, {{[0-9]+}}(%esp)
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: jne .LBB5_1
|
|
|
|
; X86-SLOW-NEXT: # %bb.2:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: orl %eax, %ebx
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: jmp .LBB5_3
|
|
|
|
; X86-SLOW-NEXT: .LBB5_1:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: movl %edx, %ebx
|
|
|
|
; X86-SLOW-NEXT: xorl %edx, %edx
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: .LBB5_3:
|
|
|
|
; X86-SLOW-NEXT: movb %ch, %cl
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: shrl %cl, %esi
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: testb $32, %ch
|
|
|
|
; X86-SLOW-NEXT: jne .LBB5_4
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-SLOW-NEXT: # %bb.5:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: orl %edi, %ebp
|
2020-04-02 18:36:01 +08:00
|
|
|
; X86-SLOW-NEXT: jmp .LBB5_6
|
|
|
|
; X86-SLOW-NEXT: .LBB5_4:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: movl %esi, %ebp
|
|
|
|
; X86-SLOW-NEXT: xorl %esi, %esi
|
[PGO][PGSO] Enable size optimizations in code gen / target passes for cold code.
Summary: Split off of D67120.
Reviewers: davidxl
Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71288
2019-11-08 00:52:05 +08:00
|
|
|
; X86-SLOW-NEXT: .LBB5_6:
|
2020-04-01 00:24:07 +08:00
|
|
|
; X86-SLOW-NEXT: orl %ebp, %edx
|
|
|
|
; X86-SLOW-NEXT: orl %esi, %ebx
|
|
|
|
; X86-SLOW-NEXT: movl %edx, %eax
|
|
|
|
; X86-SLOW-NEXT: movl %ebx, %edx
|
2018-12-05 19:12:12 +08:00
|
|
|
; X86-SLOW-NEXT: popl %esi
|
|
|
|
; X86-SLOW-NEXT: popl %edi
|
|
|
|
; X86-SLOW-NEXT: popl %ebx
|
|
|
|
; X86-SLOW-NEXT: popl %ebp
|
|
|
|
; X86-SLOW-NEXT: retl
|
2018-11-17 01:48:52 +08:00
|
|
|
;
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-FAST-LABEL: var_shift_i64:
|
|
|
|
; X64-FAST: # %bb.0:
|
|
|
|
; X64-FAST-NEXT: movq %rdx, %rcx
|
|
|
|
; X64-FAST-NEXT: movq %rdi, %rax
|
2018-12-05 19:12:12 +08:00
|
|
|
; X64-FAST-NEXT: # kill: def $cl killed $cl killed $rcx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-FAST-NEXT: shldq %cl, %rsi, %rax
|
|
|
|
; X64-FAST-NEXT: retq
|
|
|
|
;
|
|
|
|
; X64-SLOW-LABEL: var_shift_i64:
|
|
|
|
; X64-SLOW: # %bb.0:
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: movq %rdx, %rcx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-SLOW-NEXT: movq %rsi, %rax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: shlq %cl, %rdi
|
|
|
|
; X64-SLOW-NEXT: shrq %rax
|
2020-05-24 18:25:09 +08:00
|
|
|
; X64-SLOW-NEXT: notb %cl
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: # kill: def $cl killed $cl killed $rcx
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-SLOW-NEXT: shrq %cl, %rax
|
2020-04-02 18:36:01 +08:00
|
|
|
; X64-SLOW-NEXT: orq %rdi, %rax
|
2018-11-19 20:29:41 +08:00
|
|
|
; X64-SLOW-NEXT: retq
|
2018-11-17 01:48:52 +08:00
|
|
|
%tmp = tail call i64 @llvm.fshl.i64(i64 %x, i64 %y, i64 %z)
|
|
|
|
ret i64 %tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
;
|
|
|
|
; Const Funnel Shift
|
|
|
|
;
|
|
|
|
|
|
|
|
define i8 @const_shift_i8(i8 %x, i8 %y) nounwind {
|
|
|
|
; X86-LABEL: const_shift_i8:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %al
|
|
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
|
|
; X86-NEXT: shrb %cl
|
|
|
|
; X86-NEXT: shlb $7, %al
|
|
|
|
; X86-NEXT: orb %cl, %al
|
|
|
|
; X86-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: const_shift_i8:
|
|
|
|
; X64: # %bb.0:
|
2019-03-06 02:37:33 +08:00
|
|
|
; X64-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2018-11-17 01:48:52 +08:00
|
|
|
; X64-NEXT: shrb %sil
|
2019-03-06 02:37:33 +08:00
|
|
|
; X64-NEXT: shlb $7, %dil
|
|
|
|
; X64-NEXT: leal (%rdi,%rsi), %eax
|
2018-11-17 01:48:52 +08:00
|
|
|
; X64-NEXT: # kill: def $al killed $al killed $eax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
%tmp = tail call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 7)
|
|
|
|
ret i8 %tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @const_shift_i16(i16 %x, i16 %y) nounwind {
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-LABEL: const_shift_i16:
|
|
|
|
; X86-FAST: # %bb.0:
|
|
|
|
; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-FAST-NEXT: shldw $7, %cx, %ax
|
|
|
|
; X86-FAST-NEXT: retl
|
2018-11-17 01:48:52 +08:00
|
|
|
;
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-LABEL: const_shift_i16:
|
|
|
|
; X86-SLOW: # %bb.0:
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-SLOW-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-SLOW-NEXT: shrl $9, %ecx
|
|
|
|
; X86-SLOW-NEXT: shll $7, %eax
|
|
|
|
; X86-SLOW-NEXT: orl %ecx, %eax
|
|
|
|
; X86-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
|
|
|
|
; X86-SLOW-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-FAST-LABEL: const_shift_i16:
|
|
|
|
; X64-FAST: # %bb.0:
|
|
|
|
; X64-FAST-NEXT: movl %edi, %eax
|
|
|
|
; X64-FAST-NEXT: shldw $7, %si, %ax
|
|
|
|
; X64-FAST-NEXT: # kill: def $ax killed $ax killed $eax
|
|
|
|
; X64-FAST-NEXT: retq
|
|
|
|
;
|
|
|
|
; X64-SLOW-LABEL: const_shift_i16:
|
|
|
|
; X64-SLOW: # %bb.0:
|
|
|
|
; X64-SLOW-NEXT: movzwl %si, %eax
|
|
|
|
; X64-SLOW-NEXT: shll $7, %edi
|
|
|
|
; X64-SLOW-NEXT: shrl $9, %eax
|
|
|
|
; X64-SLOW-NEXT: orl %edi, %eax
|
|
|
|
; X64-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
|
|
|
|
; X64-SLOW-NEXT: retq
|
2018-11-17 01:48:52 +08:00
|
|
|
%tmp = tail call i16 @llvm.fshl.i16(i16 %x, i16 %y, i16 7)
|
|
|
|
ret i16 %tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @const_shift_i32(i32 %x, i32 %y) nounwind {
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-LABEL: const_shift_i32:
|
|
|
|
; X86-FAST: # %bb.0:
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-FAST-NEXT: shldl $7, %ecx, %eax
|
|
|
|
; X86-FAST-NEXT: retl
|
2018-11-17 01:48:52 +08:00
|
|
|
;
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-LABEL: const_shift_i32:
|
|
|
|
; X86-SLOW: # %bb.0:
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-SLOW-NEXT: shrl $25, %ecx
|
|
|
|
; X86-SLOW-NEXT: shll $7, %eax
|
|
|
|
; X86-SLOW-NEXT: orl %ecx, %eax
|
|
|
|
; X86-SLOW-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-FAST-LABEL: const_shift_i32:
|
|
|
|
; X64-FAST: # %bb.0:
|
|
|
|
; X64-FAST-NEXT: movl %edi, %eax
|
|
|
|
; X64-FAST-NEXT: shldl $7, %esi, %eax
|
|
|
|
; X64-FAST-NEXT: retq
|
|
|
|
;
|
|
|
|
; X64-SLOW-LABEL: const_shift_i32:
|
|
|
|
; X64-SLOW: # %bb.0:
|
|
|
|
; X64-SLOW-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; X64-SLOW-NEXT: # kill: def $edi killed $edi def $rdi
|
|
|
|
; X64-SLOW-NEXT: shrl $25, %esi
|
|
|
|
; X64-SLOW-NEXT: shll $7, %edi
|
|
|
|
; X64-SLOW-NEXT: leal (%rdi,%rsi), %eax
|
|
|
|
; X64-SLOW-NEXT: retq
|
2018-11-17 01:48:52 +08:00
|
|
|
%tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 7)
|
|
|
|
ret i32 %tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @const_shift_i64(i64 %x, i64 %y) nounwind {
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-FAST-LABEL: const_shift_i64:
|
|
|
|
; X86-FAST: # %bb.0:
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-FAST-NEXT: shrdl $25, %ecx, %eax
|
|
|
|
; X86-FAST-NEXT: shldl $7, %ecx, %edx
|
|
|
|
; X86-FAST-NEXT: retl
|
2018-11-17 01:48:52 +08:00
|
|
|
;
|
2018-11-19 20:29:41 +08:00
|
|
|
; X86-SLOW-LABEL: const_shift_i64:
|
|
|
|
; X86-SLOW: # %bb.0:
|
|
|
|
; X86-SLOW-NEXT: pushl %esi
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
|
|
; X86-SLOW-NEXT: shrl $25, %esi
|
|
|
|
; X86-SLOW-NEXT: movl %ecx, %eax
|
|
|
|
; X86-SLOW-NEXT: shll $7, %eax
|
|
|
|
; X86-SLOW-NEXT: orl %esi, %eax
|
|
|
|
; X86-SLOW-NEXT: shrl $25, %ecx
|
|
|
|
; X86-SLOW-NEXT: shll $7, %edx
|
|
|
|
; X86-SLOW-NEXT: orl %ecx, %edx
|
|
|
|
; X86-SLOW-NEXT: popl %esi
|
|
|
|
; X86-SLOW-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-FAST-LABEL: const_shift_i64:
|
|
|
|
; X64-FAST: # %bb.0:
|
|
|
|
; X64-FAST-NEXT: movq %rdi, %rax
|
|
|
|
; X64-FAST-NEXT: shldq $7, %rsi, %rax
|
|
|
|
; X64-FAST-NEXT: retq
|
|
|
|
;
|
|
|
|
; X64-SLOW-LABEL: const_shift_i64:
|
|
|
|
; X64-SLOW: # %bb.0:
|
|
|
|
; X64-SLOW-NEXT: shrq $57, %rsi
|
|
|
|
; X64-SLOW-NEXT: shlq $7, %rdi
|
|
|
|
; X64-SLOW-NEXT: leaq (%rdi,%rsi), %rax
|
|
|
|
; X64-SLOW-NEXT: retq
|
2018-11-17 01:48:52 +08:00
|
|
|
%tmp = tail call i64 @llvm.fshl.i64(i64 %x, i64 %y, i64 7)
|
|
|
|
ret i64 %tmp
|
|
|
|
}
|
[PGO][PGSO] Enable size optimizations in code gen / target passes for cold code.
Summary: Split off of D67120.
Reviewers: davidxl
Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71288
2019-11-08 00:52:05 +08:00
|
|
|
|
2020-03-04 23:04:03 +08:00
|
|
|
;
|
|
|
|
; Combine Consecutive Loads
|
|
|
|
;
|
|
|
|
|
|
|
|
define i8 @combine_fshl_load_i8(i8* %p) nounwind {
|
|
|
|
; X86-LABEL: combine_fshl_load_i8:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: movb 1(%eax), %al
|
|
|
|
; X86-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: combine_fshl_load_i8:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movb 1(%rdi), %al
|
|
|
|
; X64-NEXT: retq
|
|
|
|
%p1 = getelementptr i8, i8* %p, i32 1
|
|
|
|
%ld0 = load i8, i8 *%p
|
|
|
|
%ld1 = load i8, i8 *%p1
|
|
|
|
%res = call i8 @llvm.fshl.i8(i8 %ld1, i8 %ld0, i8 8)
|
|
|
|
ret i8 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @combine_fshl_load_i16(i16* %p) nounwind {
|
2020-03-06 19:36:00 +08:00
|
|
|
; X86-LABEL: combine_fshl_load_i16:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: movzwl 1(%eax), %eax
|
|
|
|
; X86-NEXT: retl
|
2020-03-04 23:04:03 +08:00
|
|
|
;
|
2020-03-06 19:36:00 +08:00
|
|
|
; X64-LABEL: combine_fshl_load_i16:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movzwl 1(%rdi), %eax
|
|
|
|
; X64-NEXT: retq
|
2020-03-04 23:04:03 +08:00
|
|
|
%p0 = getelementptr i16, i16* %p, i32 0
|
|
|
|
%p1 = getelementptr i16, i16* %p, i32 1
|
|
|
|
%ld0 = load i16, i16 *%p0
|
|
|
|
%ld1 = load i16, i16 *%p1
|
|
|
|
%res = call i16 @llvm.fshl.i16(i16 %ld1, i16 %ld0, i16 8)
|
|
|
|
ret i16 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @combine_fshl_load_i32(i32* %p) nounwind {
|
2020-03-06 19:36:00 +08:00
|
|
|
; X86-LABEL: combine_fshl_load_i32:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: movl 11(%eax), %eax
|
|
|
|
; X86-NEXT: retl
|
2020-03-04 23:04:03 +08:00
|
|
|
;
|
2020-03-06 19:36:00 +08:00
|
|
|
; X64-LABEL: combine_fshl_load_i32:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movl 11(%rdi), %eax
|
|
|
|
; X64-NEXT: retq
|
2020-03-04 23:04:03 +08:00
|
|
|
%p0 = getelementptr i32, i32* %p, i32 2
|
|
|
|
%p1 = getelementptr i32, i32* %p, i32 3
|
|
|
|
%ld0 = load i32, i32 *%p0
|
|
|
|
%ld1 = load i32, i32 *%p1
|
|
|
|
%res = call i32 @llvm.fshl.i32(i32 %ld1, i32 %ld0, i32 8)
|
|
|
|
ret i32 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @combine_fshl_load_i64(i64* %p) nounwind {
|
2020-03-12 02:55:18 +08:00
|
|
|
; X86-LABEL: combine_fshl_load_i64:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X86-NEXT: movl 13(%ecx), %eax
|
|
|
|
; X86-NEXT: movl 17(%ecx), %edx
|
|
|
|
; X86-NEXT: retl
|
2020-03-04 23:04:03 +08:00
|
|
|
;
|
2020-03-06 19:36:00 +08:00
|
|
|
; X64-LABEL: combine_fshl_load_i64:
|
|
|
|
; X64: # %bb.0:
|
|
|
|
; X64-NEXT: movq 13(%rdi), %rax
|
|
|
|
; X64-NEXT: retq
|
2020-03-04 23:04:03 +08:00
|
|
|
%p0 = getelementptr i64, i64* %p, i64 1
|
|
|
|
%p1 = getelementptr i64, i64* %p, i64 2
|
|
|
|
%ld0 = load i64, i64 *%p0
|
|
|
|
%ld1 = load i64, i64 *%p1
|
|
|
|
%res = call i64 @llvm.fshl.i64(i64 %ld1, i64 %ld0, i64 24)
|
|
|
|
ret i64 %res
|
|
|
|
}
|
|
|
|
|
[PGO][PGSO] Enable size optimizations in code gen / target passes for cold code.
Summary: Split off of D67120.
Reviewers: davidxl
Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71288
2019-11-08 00:52:05 +08:00
|
|
|
!llvm.module.flags = !{!0}
|
|
|
|
!0 = !{i32 1, !"ProfileSummary", !1}
|
|
|
|
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
|
|
|
|
!2 = !{!"ProfileFormat", !"InstrProf"}
|
|
|
|
!3 = !{!"TotalCount", i64 10000}
|
|
|
|
!4 = !{!"MaxCount", i64 10}
|
|
|
|
!5 = !{!"MaxInternalCount", i64 1}
|
|
|
|
!6 = !{!"MaxFunctionCount", i64 1000}
|
|
|
|
!7 = !{!"NumCounts", i64 3}
|
|
|
|
!8 = !{!"NumFunctions", i64 3}
|
|
|
|
!9 = !{!"DetailedSummary", !10}
|
|
|
|
!10 = !{!11, !12, !13}
|
|
|
|
!11 = !{i32 10000, i64 100, i32 1}
|
|
|
|
!12 = !{i32 999000, i64 100, i32 1}
|
|
|
|
!13 = !{i32 999999, i64 1, i32 2}
|
|
|
|
!14 = !{!"function_entry_count", i64 0}
|