diff options
author | QingShan Zhang <qshanz@cn.ibm.com> | 2019-06-10 05:40:21 +0000 |
---|---|---|
committer | QingShan Zhang <qshanz@cn.ibm.com> | 2019-06-10 05:40:21 +0000 |
commit | ab846da7e8ad456769bb39b84264fc6a99a5c739 (patch) | |
tree | 3eb9b795a7237c499c7cbaec0179fab8a17abe3f /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 9000a72a4b723513499d97fb88a25a860132c323 (diff) | |
download | bcm5719-llvm-ab846da7e8ad456769bb39b84264fc6a99a5c739.tar.gz bcm5719-llvm-ab846da7e8ad456769bb39b84264fc6a99a5c739.zip |
[DAGCombine] Match a pattern where a wide type scalar value is stored by several narrow stores
This opportunity is found from spec 2017 557.xz_r. And it is used by the sha encrypt/decrypt. See sha-2/sha512.c
static void store64(u64 x, unsigned char* y)
{
for(int i = 0; i != 8; ++i)
y[i] = (x >> ((7-i) * 8)) & 255;
}
static u64 load64(const unsigned char* y)
{
u64 res = 0;
for(int i = 0; i != 8; ++i)
res |= (u64)(y[i]) << ((7-i) * 8);
return res;
}
The load64 has been implemented by https://reviews.llvm.org/D26149
This patch is trying to implement the store pattern.
Match a pattern where a wide type scalar value is stored by several narrow
stores. Fold it into a single store or a BSWAP and a store if the targets
supports it.
Assuming little endian target:
i8 *p = ...
i32 val = ...
p[0] = (val >> 0) & 0xFF;
p[1] = (val >> 8) & 0xFF;
p[2] = (val >> 16) & 0xFF;
p[3] = (val >> 24) & 0xFF;
>
*((i32)p) = val;
i8 *p = ...
i32 val = ...
p[0] = (val >> 24) & 0xFF;
p[1] = (val >> 16) & 0xFF;
p[2] = (val >> 8) & 0xFF;
p[3] = (val >> 0) & 0xFF;
>
*((i32)p) = BSWAP(val);
Differential Revision: https://reviews.llvm.org/D62897
llvm-svn: 362921
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
0 files changed, 0 insertions, 0 deletions