2
votes

I am trying to optimize an Arm processor (Corte-A53) with an Armv8 architecture for crypto purposes.

The problem is that however the compiler accepts -mcpu=cortex-a53+crypto etc it doesn't change the output (I checked the assembly output).

Changing mfpu, mcpu add futures like crypto or simd, it doesn't matter, it is completely ignored.

To enable Neon code -ftree-vectorize is needed, how to make use of crypto?

(I checked the -O(1,2,3) flags, it won't help).

Edit: I realized I made a mistake by thinking the crypto flag works like an optimization flag solved by the compiler. My bad.

1
Why do you expect compiler to emit crypto instructions? Compiler flag is probably just for checking optional behavior. - auselen
What is the code you're compiling? Unless you're actually building e.g. a crypto library containing some assembly using the crypto instructions, simply enabling their use is unlikely to do much on its own. I don't believe GCC is clever enough say "hey, this random C code looks like a SHA-1 implementation, let's optimise it!" all by itself... - Notlikethat
The code is using c implemented AES instructions, I expected (hoped) that the compiler would do anything with it, like an optimization flag. I haven't found useful documentation (or implementations) about it yet. You think the flag is just a check? So all code should be written as inline assembly? - koldewb
yes, I am using a crypto library, but its all c implemented. - koldewb
I guess I see my mistake in here, but still, whats the use of the crypto flag? - koldewb

1 Answers

2
votes

You had two questions...

Why does -mcpu=cortex-a53+crypto not change code output?

The crypto extensions are an optional feature under the AArch64 state of ARMv8-A. The +crypto feature flag indicates to the compiler that these instructions are available use. From a practical perspective, in GCC 4.8/4.9/5.1, this defines the macro __ARM_FEATURE_CRYPTO, and controls whether or not you can use the crypto intrinsics defined in ACLE, for example:

uint8x16_t vaeseq_u8 (uint8x16_t data, uint8x16_t key)

There is no optimisation in current GCC which will automatically convert a sequence of C code to use the cryptography instructions. If you want to make this transformation, you have to do it by hand (and guard it by the appropriate feature macro).

Why do the +fpu and +simd flags not change code output?

For -mcpu=cortex-a53 the +fp and +simd flags are implied by default (for some configurations of GCC +crypto may also be implied by default). Adding these feature flags will therefore not change code generation.