]> granicus.if.org Git - clang/commit
[CodeGen] add rotate builtins that map to LLVM funnel shift
authorSanjay Patel <spatel@rotateright.com>
Sun, 19 Aug 2018 16:50:30 +0000 (16:50 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 19 Aug 2018 16:50:30 +0000 (16:50 +0000)
commit7cb7a1d0c12e823a761cabcd9a8f4777257c7241
treeead146e02da20f49f4cf59c2bfb37292c9d62920
parentaf5e6d3ad7018cf9aea23da9b32d6673e3e09cf5
[CodeGen] add rotate builtins that map to LLVM funnel shift
This is a partial retry of rL340137 (reverted at rL340138 because of gcc host compiler crashing)
with 1 change:
Remove the changes to make microsoft builtins also use the LLVM intrinsics.

This exposes the LLVM funnel shift intrinsics as more familiar bit rotation functions in clang
(when both halves of a funnel shift are the same value, it's a rotate).

We're free to name these as we want because we're not copying gcc, but if there's some other
existing art (eg, the microsoft ops) that we want to replicate, we can change the names.

The funnel shift intrinsics were added here:
https://reviews.llvm.org/D49242

With improved codegen in:
https://reviews.llvm.org/rL337966
https://reviews.llvm.org/rL339359

And basic IR optimization added in:
https://reviews.llvm.org/rL338218
https://reviews.llvm.org/rL340022

...so these are expected to produce asm output that's equal or better to the multi-instruction
alternatives using primitive C/IR ops.

In the motivating loop example from PR37387:
https://bugs.llvm.org/show_bug.cgi?id=37387#c7
...we get the expected 'rolq' x86 instructions if we substitute the rotate builtin into the source.

Differential Revision: https://reviews.llvm.org/D50924

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340141 91177308-0d34-0410-b5e6-96231b3b80d8
docs/LanguageExtensions.rst
include/clang/Basic/Builtins.def
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CodeGenFunction.h