public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alexander Lakhin <[email protected]>
To: Greg Burd <[email protected]>
To: Tom Lane <[email protected]>
To: Michael Paquier <[email protected]>
Cc: pgsql-hackers <[email protected]>
Cc: Thomas Munro <[email protected]>
Subject: Re: pgcrypto/des tests fail on riscv64 due to clang's code generation anomaly
Date: Mon, 16 Mar 2026 20:00:00 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Hello,
16.03.2026 14:13, Greg Burd wrote:
>> Seems like this might be worth a bug report to the clang people.
> Thanks Alexander for digging and a solid report of the issue, and Michael for spending some time on this, and Tom for chiming in as well. I agree this looks like a compiler issue. I know that Thomas (added/CC'ed) you've posted bugs against clang before, any thoughts on this one?
>
Please find attached the reduced test code, which works for me as follows:
$ clang-20 -O2 -march=rv64gcv crypt-des-test.c -o crypt-des-test && ./crypt-des-test
!!!des_init| un_pbox: 15 6 19 20 28 11 27 16 0 14 22 25 4 17 30 9 1 7 23 13 31 26 2 8 18 12 29 5 21 10 3 24
$ clang-20 -O2 -march=rv64gc crypt-des-test.c -o crypt-des-test && ./crypt-des-test
!!!des_init| un_pbox: 8 16 22 30 12 27 1 17 23 15 29 5 25 19 9 0 7 13 24 2 3 28 10 18 31 11 21 6 4 26 14 20
$ clang-20 -O1 -march=rv64gcv crypt-des-test.c -o crypt-des-test && ./crypt-des-test
!!!des_init| un_pbox: 8 16 22 30 12 27 1 17 23 15 29 5 25 19 9 0 7 13 24 2 3 28 10 18 31 11 21 6 4 26 14 20
$ clang-20 --version
Ubuntu clang version 20.1.2 (0ubuntu1~24.04.2)
Best regards,
Alexander
Attachments:
[text/x-csrc] crypt-des-test.c (741B, 2-crypt-des-test.c)
download | inline:
#include <stdio.h>
#define uint8 unsigned char
#define uint32 unsigned int
#define pg_compiler_barrier() __asm__ __volatile__("" ::: "memory")
static uint8 un_pbox[32];
static uint8 pbox[32] = {
16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
};
static void
des_init(void)
{
int i;
/*
* Invert the P-box permutation, and convert into OR-masks for handling
* the output of the S-box arrays setup above.
*/
for (i = 0; i < 32; i++)
{
un_pbox[pbox[i] - 1] = i;
//pg_compiler_barrier();
}
fprintf(stderr, "!!!des_init| un_pbox:");
for (i = 0; i < 32; i++)
fprintf(stderr, " %d", un_pbox[i]);
fprintf(stderr, "\n");
}
int main()
{
des_init();
}
view thread (4+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: pgcrypto/des tests fail on riscv64 due to clang's code generation anomaly
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox