mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
e207952556
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
506 lines
16 KiB
LLVM
506 lines
16 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; 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
|
|
|
|
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:
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %ah
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %al
|
|
; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
|
|
; X86-NEXT: andb $7, %dl
|
|
; X86-NEXT: movb %al, %ch
|
|
; X86-NEXT: movb %dl, %cl
|
|
; X86-NEXT: shlb %cl, %ch
|
|
; X86-NEXT: movb $8, %cl
|
|
; X86-NEXT: subb %dl, %cl
|
|
; X86-NEXT: shrb %cl, %ah
|
|
; X86-NEXT: testb %dl, %dl
|
|
; X86-NEXT: je .LBB0_2
|
|
; X86-NEXT: # %bb.1:
|
|
; X86-NEXT: orb %ah, %ch
|
|
; X86-NEXT: movb %ch, %al
|
|
; X86-NEXT: .LBB0_2:
|
|
; X86-NEXT: retl
|
|
;
|
|
; X64-LABEL: var_shift_i8:
|
|
; X64: # %bb.0:
|
|
; X64-NEXT: andb $7, %dl
|
|
; X64-NEXT: movl %edi, %eax
|
|
; X64-NEXT: movl %edx, %ecx
|
|
; X64-NEXT: shlb %cl, %al
|
|
; X64-NEXT: movb $8, %cl
|
|
; X64-NEXT: subb %dl, %cl
|
|
; X64-NEXT: shrb %cl, %sil
|
|
; X64-NEXT: orb %al, %sil
|
|
; X64-NEXT: movzbl %sil, %eax
|
|
; X64-NEXT: testb %dl, %dl
|
|
; X64-NEXT: cmovel %edi, %eax
|
|
; 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 {
|
|
; X86-FAST-LABEL: var_shift_i16:
|
|
; X86-FAST: # %bb.0:
|
|
; 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
|
|
; X86-FAST-NEXT: retl
|
|
;
|
|
; X86-SLOW-LABEL: var_shift_i16:
|
|
; X86-SLOW: # %bb.0:
|
|
; X86-SLOW-NEXT: pushl %edi
|
|
; X86-SLOW-NEXT: pushl %esi
|
|
; X86-SLOW-NEXT: movzwl {{[0-9]+}}(%esp), %esi
|
|
; X86-SLOW-NEXT: movb {{[0-9]+}}(%esp), %dl
|
|
; X86-SLOW-NEXT: andb $15, %dl
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-SLOW-NEXT: movl %eax, %edi
|
|
; X86-SLOW-NEXT: movl %edx, %ecx
|
|
; X86-SLOW-NEXT: shll %cl, %edi
|
|
; X86-SLOW-NEXT: movb $16, %cl
|
|
; X86-SLOW-NEXT: subb %dl, %cl
|
|
; X86-SLOW-NEXT: shrl %cl, %esi
|
|
; X86-SLOW-NEXT: testb %dl, %dl
|
|
; X86-SLOW-NEXT: je .LBB1_2
|
|
; X86-SLOW-NEXT: # %bb.1:
|
|
; X86-SLOW-NEXT: orl %esi, %edi
|
|
; X86-SLOW-NEXT: movl %edi, %eax
|
|
; X86-SLOW-NEXT: .LBB1_2:
|
|
; X86-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
|
|
; X86-SLOW-NEXT: popl %esi
|
|
; X86-SLOW-NEXT: popl %edi
|
|
; 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
|
|
; X64-FAST-NEXT: andb $15, %cl
|
|
; X64-FAST-NEXT: # kill: def $cl killed $cl killed $ecx
|
|
; 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: movzwl %si, %eax
|
|
; X64-SLOW-NEXT: andb $15, %dl
|
|
; X64-SLOW-NEXT: movl %edi, %esi
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
|
; X64-SLOW-NEXT: shll %cl, %esi
|
|
; X64-SLOW-NEXT: movb $16, %cl
|
|
; X64-SLOW-NEXT: subb %dl, %cl
|
|
; X64-SLOW-NEXT: shrl %cl, %eax
|
|
; X64-SLOW-NEXT: orl %esi, %eax
|
|
; X64-SLOW-NEXT: testb %dl, %dl
|
|
; X64-SLOW-NEXT: cmovel %edi, %eax
|
|
; X64-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
|
|
; X64-SLOW-NEXT: retq
|
|
%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 {
|
|
; X86-FAST-LABEL: var_shift_i32:
|
|
; X86-FAST: # %bb.0:
|
|
; X86-FAST-NEXT: movb {{[0-9]+}}(%esp), %cl
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-FAST-NEXT: shldl %cl, %edx, %eax
|
|
; X86-FAST-NEXT: retl
|
|
;
|
|
; X86-SLOW-LABEL: var_shift_i32:
|
|
; X86-SLOW: # %bb.0:
|
|
; X86-SLOW-NEXT: pushl %edi
|
|
; X86-SLOW-NEXT: pushl %esi
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
; X86-SLOW-NEXT: movb {{[0-9]+}}(%esp), %dl
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-SLOW-NEXT: movl %eax, %edi
|
|
; X86-SLOW-NEXT: movl %edx, %ecx
|
|
; X86-SLOW-NEXT: shll %cl, %edi
|
|
; X86-SLOW-NEXT: andb $31, %dl
|
|
; X86-SLOW-NEXT: movl %edx, %ecx
|
|
; X86-SLOW-NEXT: negb %cl
|
|
; X86-SLOW-NEXT: shrl %cl, %esi
|
|
; X86-SLOW-NEXT: testb %dl, %dl
|
|
; X86-SLOW-NEXT: je .LBB2_2
|
|
; X86-SLOW-NEXT: # %bb.1:
|
|
; X86-SLOW-NEXT: orl %esi, %edi
|
|
; X86-SLOW-NEXT: movl %edi, %eax
|
|
; X86-SLOW-NEXT: .LBB2_2:
|
|
; X86-SLOW-NEXT: popl %esi
|
|
; X86-SLOW-NEXT: popl %edi
|
|
; 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
|
|
; X64-FAST-NEXT: # kill: def $cl killed $cl killed $ecx
|
|
; 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 %esi, %eax
|
|
; X64-SLOW-NEXT: movl %edi, %esi
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
|
; X64-SLOW-NEXT: shll %cl, %esi
|
|
; X64-SLOW-NEXT: andb $31, %dl
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
|
; X64-SLOW-NEXT: negb %cl
|
|
; X64-SLOW-NEXT: shrl %cl, %eax
|
|
; X64-SLOW-NEXT: orl %esi, %eax
|
|
; X64-SLOW-NEXT: testb %dl, %dl
|
|
; X64-SLOW-NEXT: cmovel %edi, %eax
|
|
; X64-SLOW-NEXT: retq
|
|
%tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)
|
|
ret i32 %tmp
|
|
}
|
|
|
|
define i32 @var_shift_i32_optsize(i32 %x, i32 %y, i32 %z) nounwind optsize {
|
|
; 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
|
|
;
|
|
; 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
|
|
%tmp = tail call i32 @llvm.fshl.i32(i32 %x, i32 %y, i32 %z)
|
|
ret i32 %tmp
|
|
}
|
|
|
|
define i64 @var_shift_i64(i64 %x, i64 %y, i64 %z) nounwind {
|
|
; X86-FAST-LABEL: var_shift_i64:
|
|
; X86-FAST: # %bb.0:
|
|
; X86-FAST-NEXT: pushl %ebp
|
|
; X86-FAST-NEXT: pushl %ebx
|
|
; X86-FAST-NEXT: pushl %edi
|
|
; X86-FAST-NEXT: pushl %esi
|
|
; X86-FAST-NEXT: pushl %eax
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-FAST-NEXT: movl %eax, (%esp) # 4-byte Spill
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ebp
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %ebx
|
|
; X86-FAST-NEXT: andl $63, %ebx
|
|
; X86-FAST-NEXT: movl %eax, %edi
|
|
; X86-FAST-NEXT: movl %ebx, %ecx
|
|
; X86-FAST-NEXT: shll %cl, %edi
|
|
; X86-FAST-NEXT: shldl %cl, %eax, %ebp
|
|
; X86-FAST-NEXT: testb $32, %bl
|
|
; X86-FAST-NEXT: je .LBB4_2
|
|
; X86-FAST-NEXT: # %bb.1:
|
|
; X86-FAST-NEXT: movl %edi, %ebp
|
|
; X86-FAST-NEXT: xorl %edi, %edi
|
|
; X86-FAST-NEXT: .LBB4_2:
|
|
; X86-FAST-NEXT: movb $64, %cl
|
|
; X86-FAST-NEXT: subb %bl, %cl
|
|
; X86-FAST-NEXT: movl %edx, %esi
|
|
; X86-FAST-NEXT: shrl %cl, %esi
|
|
; X86-FAST-NEXT: shrdl %cl, %edx, (%esp) # 4-byte Folded Spill
|
|
; X86-FAST-NEXT: testb $32, %cl
|
|
; X86-FAST-NEXT: jne .LBB4_3
|
|
; X86-FAST-NEXT: # %bb.4:
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
; X86-FAST-NEXT: movl (%esp), %ecx # 4-byte Reload
|
|
; X86-FAST-NEXT: testl %ebx, %ebx
|
|
; X86-FAST-NEXT: jne .LBB4_6
|
|
; X86-FAST-NEXT: jmp .LBB4_7
|
|
; X86-FAST-NEXT: .LBB4_3:
|
|
; X86-FAST-NEXT: movl %esi, %ecx
|
|
; X86-FAST-NEXT: xorl %esi, %esi
|
|
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
; X86-FAST-NEXT: testl %ebx, %ebx
|
|
; X86-FAST-NEXT: je .LBB4_7
|
|
; X86-FAST-NEXT: .LBB4_6:
|
|
; X86-FAST-NEXT: orl %esi, %ebp
|
|
; X86-FAST-NEXT: orl %ecx, %edi
|
|
; X86-FAST-NEXT: movl %edi, %eax
|
|
; X86-FAST-NEXT: movl %ebp, %edx
|
|
; X86-FAST-NEXT: .LBB4_7:
|
|
; X86-FAST-NEXT: addl $4, %esp
|
|
; X86-FAST-NEXT: popl %esi
|
|
; X86-FAST-NEXT: popl %edi
|
|
; X86-FAST-NEXT: popl %ebx
|
|
; X86-FAST-NEXT: popl %ebp
|
|
; 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
|
|
; X86-SLOW-NEXT: subl $8, %esp
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edi
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ebx
|
|
; X86-SLOW-NEXT: andl $63, %ebx
|
|
; X86-SLOW-NEXT: movb $64, %dh
|
|
; X86-SLOW-NEXT: subb %bl, %dh
|
|
; X86-SLOW-NEXT: movl %eax, (%esp) # 4-byte Spill
|
|
; X86-SLOW-NEXT: movb %dh, %cl
|
|
; X86-SLOW-NEXT: shrl %cl, %eax
|
|
; X86-SLOW-NEXT: movb %dh, %dl
|
|
; X86-SLOW-NEXT: andb $31, %dl
|
|
; X86-SLOW-NEXT: movl %edx, %ecx
|
|
; X86-SLOW-NEXT: negb %cl
|
|
; X86-SLOW-NEXT: movl %esi, %ebp
|
|
; X86-SLOW-NEXT: shll %cl, %ebp
|
|
; X86-SLOW-NEXT: testb %dl, %dl
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
; X86-SLOW-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
|
|
; X86-SLOW-NEXT: je .LBB4_2
|
|
; X86-SLOW-NEXT: # %bb.1:
|
|
; X86-SLOW-NEXT: orl %eax, %ebp
|
|
; X86-SLOW-NEXT: movl %ebp, (%esp) # 4-byte Spill
|
|
; X86-SLOW-NEXT: .LBB4_2:
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %ebp
|
|
; X86-SLOW-NEXT: movl %ebp, %eax
|
|
; X86-SLOW-NEXT: movl %ebx, %ecx
|
|
; X86-SLOW-NEXT: shll %cl, %eax
|
|
; X86-SLOW-NEXT: movb %bl, %ch
|
|
; X86-SLOW-NEXT: andb $31, %ch
|
|
; X86-SLOW-NEXT: movb %ch, %cl
|
|
; X86-SLOW-NEXT: negb %cl
|
|
; X86-SLOW-NEXT: shrl %cl, %edi
|
|
; X86-SLOW-NEXT: testb %ch, %ch
|
|
; X86-SLOW-NEXT: je .LBB4_4
|
|
; X86-SLOW-NEXT: # %bb.3:
|
|
; X86-SLOW-NEXT: orl %edi, %eax
|
|
; X86-SLOW-NEXT: movl %eax, %ebp
|
|
; X86-SLOW-NEXT: .LBB4_4:
|
|
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-SLOW-NEXT: movl %eax, %edi
|
|
; X86-SLOW-NEXT: movl %ebx, %ecx
|
|
; X86-SLOW-NEXT: shll %cl, %edi
|
|
; X86-SLOW-NEXT: testb $32, %bl
|
|
; X86-SLOW-NEXT: je .LBB4_6
|
|
; X86-SLOW-NEXT: # %bb.5:
|
|
; X86-SLOW-NEXT: movl %edi, %ebp
|
|
; X86-SLOW-NEXT: xorl %edi, %edi
|
|
; X86-SLOW-NEXT: .LBB4_6:
|
|
; X86-SLOW-NEXT: movb %dh, %cl
|
|
; X86-SLOW-NEXT: shrl %cl, %esi
|
|
; X86-SLOW-NEXT: testb $32, %dh
|
|
; X86-SLOW-NEXT: jne .LBB4_7
|
|
; X86-SLOW-NEXT: # %bb.8:
|
|
; X86-SLOW-NEXT: movl (%esp), %ecx # 4-byte Reload
|
|
; X86-SLOW-NEXT: testl %ebx, %ebx
|
|
; X86-SLOW-NEXT: jne .LBB4_10
|
|
; X86-SLOW-NEXT: jmp .LBB4_11
|
|
; X86-SLOW-NEXT: .LBB4_7:
|
|
; X86-SLOW-NEXT: movl %esi, %ecx
|
|
; X86-SLOW-NEXT: xorl %esi, %esi
|
|
; X86-SLOW-NEXT: testl %ebx, %ebx
|
|
; X86-SLOW-NEXT: je .LBB4_11
|
|
; X86-SLOW-NEXT: .LBB4_10:
|
|
; X86-SLOW-NEXT: orl %esi, %ebp
|
|
; X86-SLOW-NEXT: orl %ecx, %edi
|
|
; X86-SLOW-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
|
|
; X86-SLOW-NEXT: movl %edi, %eax
|
|
; X86-SLOW-NEXT: .LBB4_11:
|
|
; X86-SLOW-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
|
|
; X86-SLOW-NEXT: addl $8, %esp
|
|
; X86-SLOW-NEXT: popl %esi
|
|
; X86-SLOW-NEXT: popl %edi
|
|
; X86-SLOW-NEXT: popl %ebx
|
|
; X86-SLOW-NEXT: popl %ebp
|
|
; X86-SLOW-NEXT: retl
|
|
;
|
|
; X64-FAST-LABEL: var_shift_i64:
|
|
; X64-FAST: # %bb.0:
|
|
; X64-FAST-NEXT: movq %rdx, %rcx
|
|
; X64-FAST-NEXT: movq %rdi, %rax
|
|
; X64-FAST-NEXT: # kill: def $cl killed $cl killed $rcx
|
|
; X64-FAST-NEXT: shldq %cl, %rsi, %rax
|
|
; X64-FAST-NEXT: retq
|
|
;
|
|
; X64-SLOW-LABEL: var_shift_i64:
|
|
; X64-SLOW: # %bb.0:
|
|
; X64-SLOW-NEXT: movq %rsi, %rax
|
|
; X64-SLOW-NEXT: movq %rdi, %rsi
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
|
; X64-SLOW-NEXT: shlq %cl, %rsi
|
|
; X64-SLOW-NEXT: andb $63, %dl
|
|
; X64-SLOW-NEXT: movl %edx, %ecx
|
|
; X64-SLOW-NEXT: negb %cl
|
|
; X64-SLOW-NEXT: shrq %cl, %rax
|
|
; X64-SLOW-NEXT: orq %rsi, %rax
|
|
; X64-SLOW-NEXT: testb %dl, %dl
|
|
; X64-SLOW-NEXT: cmoveq %rdi, %rax
|
|
; X64-SLOW-NEXT: retq
|
|
%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:
|
|
; X64-NEXT: # kill: def $esi killed $esi def $rsi
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
|
; X64-NEXT: shrb %sil
|
|
; X64-NEXT: shlb $7, %dil
|
|
; X64-NEXT: leal (%rdi,%rsi), %eax
|
|
; 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 {
|
|
; 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
|
|
;
|
|
; 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
|
|
%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 {
|
|
; 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
|
|
;
|
|
; 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
|
|
%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 {
|
|
; 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
|
|
;
|
|
; 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
|
|
%tmp = tail call i64 @llvm.fshl.i64(i64 %x, i64 %y, i64 7)
|
|
ret i64 %tmp
|
|
}
|