This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix inline asm rejects-valid introduced in PR21299 (PR inline-asm/30505)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 19 Mar 2007 10:22:47 -0500
- Subject: [PATCH] Fix inline asm rejects-valid introduced in PR21299 (PR inline-asm/30505)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following valid testcase is rejected because PR21299 check
is done too early and SUBREGs aren't simplified yet.
constrain_operands sees "g" constraint for (subreg:SI (mem:DI ...) 0)
and calls general_operand ((mem:DI ...), SImode) which of course
fails. The following patch fixes it by just calling the PR21299
check later in the same loop, after cleanup_subreg_operands
has been called.
I have verified the PR21299 testcase (which hasn't been checked in, why?)
still doesn't ICE.
Ok for 4.2/trunk (the branches where PR21299 fix has been applied)?
2007-03-19 Jakub Jelinek <jakub@redhat.com>
PR inline-asm/30505
* reload1.c (reload): Do invalid ASM checking after
cleanup_subreg_operands.
--- gcc/reload1.c.jj 2007-03-12 17:18:17.000000000 +0100
+++ gcc/reload1.c 2007-03-19 15:58:39.000000000 +0100
@@ -1173,20 +1173,6 @@ reload (rtx first, int global)
{
rtx *pnote;
- /* Clean up invalid ASMs so that they don't confuse later passes.
- See PR 21299. */
- if (asm_noperands (PATTERN (insn)) >= 0)
- {
- extract_insn (insn);
- if (!constrain_operands (1))
- {
- error_for_asm (insn,
- "%<asm%> operand has impossible constraints");
- delete_insn (insn);
- continue;
- }
- }
-
if (CALL_P (insn))
replace_pseudos_in (& CALL_INSN_FUNCTION_USAGE (insn),
VOIDmode, CALL_INSN_FUNCTION_USAGE (insn));
@@ -1245,8 +1231,22 @@ reload (rtx first, int global)
add_auto_inc_notes (insn, PATTERN (insn));
#endif
- /* And simplify (subreg (reg)) if it appears as an operand. */
+ /* Simplify (subreg (reg)) if it appears as an operand. */
cleanup_subreg_operands (insn);
+
+ /* Clean up invalid ASMs so that they don't confuse later passes.
+ See PR 21299. */
+ if (asm_noperands (PATTERN (insn)) >= 0)
+ {
+ extract_insn (insn);
+ if (!constrain_operands (1))
+ {
+ error_for_asm (insn,
+ "%<asm%> operand has impossible constraints");
+ delete_insn (insn);
+ continue;
+ }
+ }
}
/* If we are doing stack checking, give a warning if this function's
--- gcc/testsuite/gcc.target/i386/pr30505.c.jj 2007-03-19 16:13:41.000000000 +0100
+++ gcc/testsuite/gcc.target/i386/pr30505.c 2007-03-19 16:12:07.000000000 +0100
@@ -0,0 +1,19 @@
+/* PR inline-asm/30505 */
+/* { dg-do compile { target ilp32 } } */
+/* { dg-options "-O2" } */
+
+unsigned long long a, c;
+unsigned int b, d;
+
+void
+test ()
+{
+ unsigned int e, f;
+
+ __asm__ ("divl %5;movl %1, %0;movl %4, %1;divl %5"
+ : "=&rm" (e), "=a" (f), "=d" (d)
+ : "1" ((unsigned int) (a >> 32)), "g" ((unsigned int) a),
+ "rm" (b), "2" (0)
+ : "cc");
+ c = (unsigned long long) e << 32 | f;
+}
Jakub