This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! This restricts the X constraint in asm statements, which can be easily folded by combine in something completely invalid. It is necessary to allow scratch here, because on i386 the md_asm_adjust hook inserts them. The second test case fails because lra does not allow all register for anything_ok operands (aka X) and later it fails to match the two X constraints in case '0': if (curr_alt[m] == NO_REGS) break. There is also an identical bug in the reload pass, but I do not know how to fix that, as it is almost used nowhere today. Boot-strapped and regression-tested on x86_64-pc-linux-gnu. OK for trunk? Thanks Bernd.
Attachment:
changelog-pr59155.txt
Description: changelog-pr59155.txt
Index: gcc/lra-constraints.c =================================================================== --- gcc/lra-constraints.c (revision 236569) +++ gcc/lra-constraints.c (working copy) @@ -1854,7 +1854,7 @@ process_alt_operands (int only_alternative) if (curr_static_id->operand_alternative[opalt_num].anything_ok) { /* Fast track for no constraints at all. */ - curr_alt[nop] = NO_REGS; + curr_alt[nop] = ALL_REGS; CLEAR_HARD_REG_SET (curr_alt_set[nop]); curr_alt_win[nop] = true; curr_alt_match_win[nop] = false; Index: gcc/recog.c =================================================================== --- gcc/recog.c (revision 236569) +++ gcc/recog.c (working copy) @@ -1757,6 +1757,10 @@ asm_operand_ok (rtx op, const char *constraint, co result = 1; break; + case 'X': + if (scratch_operand (op, VOIDmode)) + result = 1; + /* ... fall through ... */ case 'g': if (general_operand (op, VOIDmode)) result = 1; Index: gcc/testsuite/gcc.dg/torture/pr59155-1.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr59155-1.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr59155-1.c (working copy) @@ -0,0 +1,7 @@ +double f(double x){ + asm volatile("":"+X"(x)); + return x; +} +double g(double x,double y){ + return f(f(x)+f(y)); +} Index: gcc/testsuite/gcc.dg/torture/pr59155-2.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr59155-2.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr59155-2.c (working copy) @@ -0,0 +1,7 @@ +double f(double x){ + asm volatile("":"+X"(x)); + return x; +} +double g(){ + return f(1.); +} Index: gcc/testsuite/gcc.dg/torture/pr59155-3.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr59155-3.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr59155-3.c (working copy) @@ -0,0 +1,27 @@ +void +noprop1 (int **x, int y, int z) +{ + int *ptr = *x + y * z / 11; + asm volatile ("noprop1 %0" : : "X" (*ptr)); +} + +void +noprop2 (int **x, int y, int z) +{ + int *ptr = *x + y * z / 11; + asm volatile ("noprop2 %0" : : "X" (ptr)); +} + +int *global_var; + +void +const1 (void) +{ + asm volatile ("const1 %0" : : "X" (global_var)); +} + +void +const2 (void) +{ + asm volatile ("const2 %0" : : "X" (*global_var)); +}
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |