]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/27528 (compiling linux kernels 2.6.16.14/15 2.6.17-rc3 on powerpc...
authorRichard Sandiford <richard@codesourcery.com>
Sat, 11 Nov 2006 09:47:35 +0000 (09:47 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 11 Nov 2006 09:47:35 +0000 (09:47 +0000)
gcc/
PR middle-end/27528
* stmt.c (expand_asm_operands): Use EXPAND_INITIALIZER if the
constraints accept neither registers or memories.

gcc/testsuite/
PR middle-end/27528
* gcc.c-torture/compile/pr27528.c: New test.
* gcc.dg/pr27528.c: Likewise.

From-SVN: r118689

gcc/ChangeLog
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr27528.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr27528.c [new file with mode: 0644]

index 142c0eca4be0e7ddcc90cfcffb6f0bd5fe7410bd..99ac929e379e9c4b3623a665085c82879f10e44a 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-11  Richard Sandiford  <richard@codesourcery.com>
+
+       PR middle-end/27528
+       * stmt.c (expand_asm_operands): Use EXPAND_INITIALIZER if the
+       constraints accept neither registers or memories.
+
 2006-11-11  Jie Zhang  <jie.zhang@analog.com>
 
        * config/bfin/bfin.h (FUNCTION_PROFILER): Don't use LABELNO.
index 193745314ad62c48226535a4cc80e3025143093f..d5a181b9d2d997c8d04b1b02c424e693b9e9d0d4 100644 (file)
@@ -885,9 +885,13 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
 
       val = TREE_VALUE (tail);
       type = TREE_TYPE (val);
+      /* EXPAND_INITIALIZER will not generate code for valid initializer
+        constants, but will still generate code for other types of operand.
+        This is the behavior we want for constant constraints.  */
       op = expand_expr (val, NULL_RTX, VOIDmode,
-                       (allows_mem && !allows_reg
-                        ? EXPAND_MEMORY : EXPAND_NORMAL));
+                       allows_reg ? EXPAND_NORMAL
+                       : allows_mem ? EXPAND_MEMORY
+                       : EXPAND_INITIALIZER);
 
       /* Never pass a CONCAT to an ASM.  */
       if (GET_CODE (op) == CONCAT)
index b928b3667fa8664f8264e9b33bcc088c1a0ac365..be5d63cebf6a5f9ff78f231dfcf5f49af26fddd2 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-11  Richard Sandiford  <richard@codesourcery.com>
+
+       PR middle-end/27528
+       * gcc.c-torture/compile/pr27528.c: New test.
+       * gcc.dg/pr27528.c: Likewise.
+
 2006-11-10  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/builtins-20.c: Add more cases for stripping sign ops.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr27528.c b/gcc/testsuite/gcc.c-torture/compile/pr27528.c
new file mode 100644 (file)
index 0000000..ee3cf65
--- /dev/null
@@ -0,0 +1,38 @@
+/* Check that constant constraints like "i", "n" and "s" can be used in
+   cases where the operand is an initializer constant.  */
+int x[2] = { 1, 2 };
+
+#ifdef __OPTIMIZE__
+static inline void __attribute__((__always_inline__))
+insn1 (int x)
+{
+  asm volatile ("# %0 %1" :: "n" (x), "i" (x));
+}
+
+static inline void __attribute__((__always_inline__))
+insn2 (const void *x)
+{
+  asm volatile ("# %0 %1" :: "s" (x), "i" (x));
+}
+#endif
+
+void
+foo (void)
+{
+#ifdef __OPTIMIZE__
+  insn1 (2);
+  insn1 (2);
+  insn1 (400);
+  insn1 (__LINE__);
+  insn2 (x);
+  insn2 (x);
+  insn2 (&x[1]);
+  insn2 ("string");
+#endif
+  asm volatile ("# %0 %1" :: "s" (x), "i" (x));
+  /* At the time of writing, &x[1] is decomposed before reaching expand
+     when compiling with -O0.  */
+  asm volatile ("# %0 %1" :: "s" ("string"), "i" ("string"));
+  asm volatile ("# %0 %1" :: "s" (__FILE__), "i" (__FILE__));
+  asm volatile ("# %0 %1" :: "s" (__FUNCTION__), "i" (__FUNCTION__));
+}
diff --git a/gcc/testsuite/gcc.dg/pr27528.c b/gcc/testsuite/gcc.dg/pr27528.c
new file mode 100644 (file)
index 0000000..4f33a31
--- /dev/null
@@ -0,0 +1,18 @@
+/* Check the warnings and errors generated for asm operands that aren't
+   obviously constant but that are constrained to be constants.  */
+/* { dg-options "" } */
+/* { dg-error "impossible constraint" "" { target *-*-* } 13 } */
+/* { dg-error "impossible constraint" "" { target *-*-* } 14 } */
+/* { dg-error "impossible constraint" "" { target *-*-* } 15 } */
+/* { dg-error "impossible constraint" "" { target *-*-* } 16 } */
+int bar (int);
+void
+foo (int *x, int y)
+{
+  int constant = 0;
+  asm ("# %0" :: "i" (x)); /* { dg-warning "probably doesn't match" } */
+  asm ("# %0" :: "i" (bar (*x))); /* { dg-warning "probably doesn't match" } */
+  asm ("# %0" :: "i" (*x + 0x11)); /* { dg-warning "probably doesn't match" } */
+  asm ("# %0" :: "i" (constant)); /* { dg-warning "probably doesn't match" } */
+  asm ("# %0" :: "i" (y * 0)); /* folded */
+}