https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91362
Bug ID: 91362
Summary: program compiled with O3 optimization give different
output than without optimization
Product: gcc
Version: 9.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: matic at nimp dot co.uk
Target Milestone: ---
Created attachment 46674
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46674&action=edit
test case, gcc --version output, lscpu output, binaries generated
The attached program give a different output when using O3 optimization level.
The problems seems related to the following piece of code.
if SAFE_AND_SLOW is defined, O3 gives the same results as no optimization
if it is not defined, O3 gives a different result.
for(unsigned int j = 0;j<2;j++){
ctx->c[0] ^= 0xf;
ctx->c[2] ^= gascon_rotr64_interleaved2(ctx->c[2]) ^
gascon_rotr64_interleaved2(ctx->c[2]);
#ifndef SAFE_AND_SLOW
uint32_t*r32 = (uint32_t*)ctx->r;
uint32_t *cpart = ((uint32_t*)ctx->c);
for(unsigned int i=0;ic;
uint8_t*r8 = (uint8_t*)ctx->r;
for(unsigned int i=0;i ref output
0F00 -> ref output
0F00 -> O3 with
SAFE_AND_SLOW
0F00 -> O3 with
SAFE_AND_SLOW
-> O3
-> O3
the testcase is a reduced version of the code here:
https://github.com/sebastien-riou/DryGASCON/tree/master/Implementations/crypto_hash/drygascon128/le32