Hi! The testcase uses -m32 in dg-options, something we try hard not to do, if something should be tested only for -m32, it is { target ia32 } test, if it can be tested for -m64/-mx32 too, just some extra options are needed for ia32, it should have dg-additional-options with ia32 target.
Furthermore, the submitter is asking for credit in the testcase, I think we don't generally do that unless the test is unreduced, but this test wasn't actually properly reduced, so I think it is better to reduce it (as done in the patch, the test still FAILs before r15-7700 and succeeds with current trunk). Ok for trunk? 2025-02-28 Jakub Jelinek <ja...@redhat.com> PR target/118940 * gcc.target/i386/pr118940.c: Drop -w, -g and -m32 from dg-options, move -march=i386 -mregparm=3 to dg-additional-options for ia32 and -fno-pie to dg-additional-options for pie. Reduce the test. --- gcc/testsuite/gcc.target/i386/pr118940.c.jj 2025-02-27 22:04:36.045027595 +0100 +++ gcc/testsuite/gcc.target/i386/pr118940.c 2025-02-28 08:55:14.831842185 +0100 @@ -1,127 +1,30 @@ +/* PR target/118940 */ /* { dg-do compile } */ -/* { dg-options "-w -g -Os -march=i386 -mregparm=3 -m32 -fno-PIE" } */ - -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -typedef unsigned int size_t; -typedef uint32_t bigint_element_t; - -/** - * Define a big-integer type - * - * @v size Number of elements - * @ret bigint_t Big integer type - */ - #define bigint_t( size ) \ - struct { \ - bigint_element_t element[ (size) ]; \ - } - -/** -* Determine number of elements required for a big-integer type -* -* @v len Maximum length of big integer, in bytes -* @ret size Number of elements -*/ -#define bigint_required_size( len ) \ - ( ( (len) + sizeof ( bigint_element_t ) - 1 ) / \ - sizeof ( bigint_element_t ) ) - -/** - * Determine number of elements in big-integer type - * - * @v bigint Big integer - * @ret size Number of elements - */ - #define bigint_size( bigint ) \ - ( sizeof ( *(bigint) ) / sizeof ( (bigint)->element[0] ) ) - - /** - * Initialise big integer - * - * @v value Big integer to initialise - * @v data Raw data - * @v len Length of raw data - */ -#define bigint_init( value, data, len ) do { \ - unsigned int size = bigint_size (value); \ - bigint_init_raw ( (value)->element, size, (data), (len) ); \ - } while ( 0 ) - - -/** - * Calculate temporary working space required for moduluar exponentiation - * - * @v modulus Big integer modulus - * @ret len Length of temporary working space - */ - #define bigint_mod_exp_tmp_len( modulus ) ( { \ - unsigned int size = bigint_size (modulus); \ - sizeof ( struct { \ - bigint_t ( size ) temp[4]; \ - } ); } ) - - -/** - * Initialise big integer - * - * @v value0 Element 0 of big integer to initialise - * @v size Number of elements - * @v data Raw data - * @v len Length of raw data - */ - static inline __attribute__ (( always_inline )) void - bigint_init_raw ( uint32_t *value0, unsigned int size, - const void *data, size_t len ) { - bigint_t ( size ) __attribute__ (( may_alias )) *value = - ( ( void * ) value0 ); - long pad_len = ( sizeof ( *value ) - len ); - void *discard_D; - long discard_c; - - /* Copy raw data in reverse order, padding with zeros */ - __asm__ __volatile__ ( "\n1:\n\t" - "movb -1(%3,%1), %%al\n\t" - "stosb\n\t" - "loop 1b\n\t" - "xorl %%eax, %%eax\n\t" - "mov %4, %1\n\t" - "rep stosb\n\t" - : "=&D" ( discard_D ), "=&c" ( discard_c ), - "+m" ( *value ) - : "r" ( data ), "g" ( pad_len ), "0" ( value0 ), - "1" ( len ) - : "eax" ); - } - -extern void touch (void *, ...); -extern void touch3 (void *, void *, void *); -extern void touch2 (void *, void *); - -/** - * Perform big integer self-tests - * - */ -void bigint_test_exec ( void ) { - do{ - static const uint8_t base_raw[3] = {0}; - static const uint8_t modulus_raw[3] = {0}; - static const uint8_t exponent_raw[25] = {0}; - unsigned int size = - bigint_required_size ( sizeof ( base_raw ) ); - unsigned int exponent_size = - bigint_required_size ( sizeof ( exponent_raw ) ); - bigint_t ( size ) base_temp; - bigint_t ( size ) modulus_temp; - bigint_t ( exponent_size ) exponent_temp; - size_t tmp_len = bigint_mod_exp_tmp_len ( &modulus_temp ); - +/* { dg-options "-Os" } */ +/* { dg-additional-options "-march=i386 -mregparm=3" { target ia32 } } */ +/* { dg-additional-options "-fno-pie" { target pie } } */ + +struct A { int a[10]; }; +void *b; +long c; +char d[100]; +int e; +void foo (void *, void *, void *); + +void +bar (int *x, int y, void *z, int w) +{ + (void) y; + struct A *f = (void *) x; + asm ("" : "=&D" (b), "=&c" (c), "+m" (*f) : "r" (z), "0" (x), "1" (w) : "eax"); +} - touch ( &base_temp ); - bigint_init ( &modulus_temp, modulus_raw, - sizeof ( modulus_raw ) ); - bigint_init ( &exponent_temp, exponent_raw, - sizeof ( exponent_raw ) ); - touch3 ( &base_temp, &modulus_temp, &exponent_temp ); - } while ( 0 ); +void +baz (void) +{ + struct A g, h; + struct B { int a[e]; } i; + bar (h.a, 0, d, 0); + bar (i.a, 0, (void *) baz, 0); + foo (&g, &h, &i); } Jakub