summaryrefslogtreecommitdiff
path: root/packages/gcc/gcc-4.2.2/901-avr32-fix-no-cond-exec-before-reload.patch
blob: 5d84dd82a813b230883e0bf27725542d67c492b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Index: trunk/gcc/config/avr32/avr32.c
===================================================================
--- trunk/gcc/config/avr32/avr32.c	(revision 42108)
+++ trunk/gcc/config/avr32/avr32.c	(revision 42335)
@@ -3737,7 +3737,34 @@
   return 0;
 }
 
+/* Return TRUE if X contains a MEM expression.  */
+int
+mem_mentioned_p (rtx x)
+{
+  const char *fmt;
+  int i;
 
+  if (MEM_P (x))
+    return 1;
+
+  fmt = GET_RTX_FORMAT (GET_CODE (x));
+  for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
+    {
+      if (fmt[i] == 'E')
+	{
+	  int j;
+
+	  for (j = XVECLEN (x, i) - 1; j >= 0; j--)
+	    if (mem_mentioned_p (XVECEXP (x, i, j)))
+	      return 1;
+	}
+      else if (fmt[i] == 'e' && mem_mentioned_p (XEXP (x, i)))
+	return 1;
+    }
+
+  return 0;
+}
+
 int
 avr32_legitimate_pic_operand_p (rtx x)
 {
@@ -7547,7 +7574,7 @@
                    /* We cannot move memory loads outside of the if-then-else
                       since the memory access should not be perfomed if the
                       condition is not met. */
-                   && !MEM_P (SET_SRC (op)) )
+                   && !mem_mentioned_p (SET_SRC (op)) )
                 {
                   rtx scratch_reg = gen_reg_rtx (mode);
                   rtx op_pattern = copy_rtx (op);