aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2023-01-14 18:55:24 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2023-01-14 19:12:18 +0300
commitcc39c3b17fb2598e20ca0854f9fe6d69169d85c7 (patch)
treeea01f55a76f2b9cfb311ecd263416e5b602de07e /clang/lib/Frontend/CompilerInvocation.cpp
parent69961626df42f5695acc464953378b2bad1483e1 (diff)
downloadllvm-cc39c3b17fb2598e20ca0854f9fe6d69169d85c7.zip
llvm-cc39c3b17fb2598e20ca0854f9fe6d69169d85c7.tar.gz
llvm-cc39c3b17fb2598e20ca0854f9fe6d69169d85c7.tar.bz2
[Codegen][LegalizeIntegerTypes] New legalization strategy for scalar shifts: shift through stack
https://reviews.llvm.org/D140493 is going to teach SROA how to promote allocas that have variably-indexed loads. That does bring up questions of cost model, since that requires creating wide shifts. Indeed, our legalization for them is not optimal. We either split it into parts, or lower it into a libcall. But if the shift amount is by a multiple of CHAR_BIT, we can also legalize it throught stack. The basic idea is very simple: 1. Get a stack slot 2x the width of the shift type 2. store the value we are shifting into one half of the slot 3. pad the other half of the slot. for logical shifts, with zero, for arithmetic shift with signbit 4. index into the slot (starting from the base half into which we spilled, either upwards or downwards) 5. load 6. split loaded integer This works for both little-endian and big-endian machines: https://alive2.llvm.org/ce/z/YNVwd5 And better yet, if the original shift amount was not a multiple of CHAR_BIT, we can just shift by that remainder afterwards: https://alive2.llvm.org/ce/z/pz5G-K I think, if we are going perform shift->shift-by-parts expansion more than once, we should instead go through stack, which is what this patch does. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D140638
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions