aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Module.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2020-12-23 22:26:28 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2020-12-23 22:28:09 +0300
commite124844709228a076483d8b6101bbb362caf625f (patch)
treef27a8d4adce7a7d76e0904689e4edf463a6e4513 /clang/lib/Basic/Module.cpp
parent4c37453a04f942dd676af1eda5d0760d4ffe8927 (diff)
downloadllvm-e124844709228a076483d8b6101bbb362caf625f.zip
llvm-e124844709228a076483d8b6101bbb362caf625f.tar.gz
llvm-e124844709228a076483d8b6101bbb362caf625f.tar.bz2
[LoopIdiom] Introduce 'left-shift until bittest' idiom
The motivation here is the following inner loop in fp16/fp24 -> fp32 expander, that runs as part of the floating-point DNG decompression in RawSpeed library: https://github.com/darktable-org/rawspeed/blob/cd380bb9a209bd2e7a0e7022b0cab04528d151e7/src/librawspeed/decompressors/DeflateDecompressor.cpp#L112-L115 ``` while (!(fp32_fraction & (1 << 23))) { fp32_exponent -= 1; fp32_fraction <<= 1; } ``` (https://godbolt.org/z/r13YMh) As one might notice, that loop is currently uncountable, and that whole code stays scalar. Yet, it is rather trivial to make that loop countable: https://godbolt.org/z/do8WMz and we can prove that via alive2: https://alive2.llvm.org/ce/z/7vQnji (ha nice, isn't it?) ... and that allow for the whole fp16->fp32 code to vectorize: https://godbolt.org/z/7hYr13 Now, while i'd love to get there, i feel like i should take it in steps. For now, this introduces support for the most basic case, where the bit position is known as a variable, and the loop *will* go away (has no live-outs other than the recurrence, no extra instructions in the loop). I have added sufficient (i believe) test coverage, and alive2 is happy with those transforms. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D91038
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
0 files changed, 0 insertions, 0 deletions