aboutsummaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-12/0029-Patch-MicroBlaze-re-arrangement-of-the-compare-branc.patch
blob: 0a275c0bb39328b4c3051fdbea40652cfc5139db (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
From 10d5e7d6cad5e7349b88b7469eb5ae20d87eb908 Mon Sep 17 00:00:00 2001
From: Mahesh Bodapati <mbodapat@xilinx.com>
Date: Tue, 13 Sep 2022 14:45:15 +0530
Subject: [PATCH 29/53] [Patch,MicroBlaze] : re-arrangement of the compare
 branches

Upstream-Status: Pending

Signed-off-by: Mark Hatle <mark.hatle@amd.com>

---
 gcc/config/microblaze/microblaze.cc |  28 ++----
 gcc/config/microblaze/microblaze.md | 141 +++++++++++++---------------
 2 files changed, 73 insertions(+), 96 deletions(-)

diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
index 9d3628c6816..4792e3ba370 100644
--- a/gcc/config/microblaze/microblaze.cc
+++ b/gcc/config/microblaze/microblaze.cc
@@ -3698,11 +3698,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
     {
       comp_reg = cmp_op0;
       condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
-      if (mode == Pmode)
-        emit_jump_insn (gen_condjump (condition, label1));
-      else
-        emit_jump_insn (gen_long_condjump (condition, label1));
-
+      emit_jump_insn (gen_condjump (condition, label1));
     }
 
   else if (code == EQ || code == NE)
@@ -3713,10 +3709,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
       else
         emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
       condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
-      if (mode == SImode)
-        emit_jump_insn (gen_condjump (condition, label1));
-      else
-        emit_jump_insn (gen_long_condjump (condition, label1));
+      emit_jump_insn (gen_condjump (condition, label1));
     }
   else
     {
@@ -3749,10 +3742,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
       comp_reg = cmp_op0;
       condition = gen_rtx_fmt_ee (signed_condition (code),
                                   mode, comp_reg, const0_rtx);
-      if (mode == SImode)
-        emit_jump_insn (gen_condjump (condition, label1));
-      else
-        emit_jump_insn (gen_long_condjump (condition, label1));
+      emit_jump_insn (gen_condjump (condition, label1));
     }
   else if (code == EQ)
     {
@@ -3767,10 +3757,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
                                            cmp_op1));
 	}
       condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
-      if (mode == SImode)
-        emit_jump_insn (gen_condjump (condition, label1));
-      else
-        emit_jump_insn (gen_long_condjump (condition, label1));
+      emit_jump_insn (gen_condjump (condition, label1));
  
     }
   else if (code == NE)
@@ -3786,10 +3773,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
                                            cmp_op1));
 	}
       condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
-      if (mode == SImode)
-        emit_jump_insn (gen_condjump (condition, label1));
-      else
-        emit_jump_insn (gen_long_condjump (condition, label1));
+      emit_jump_insn (gen_condjump (condition, label1));
     }
   else
     {
@@ -3831,7 +3815,7 @@ microblaze_expand_conditional_branch_df (rtx operands[])
 
   emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
   condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
-  emit_jump_insn (gen_long_condjump (condition, operands[3]));
+  emit_jump_insn (gen_condjump (condition, operands[3]));
 }
 
 /* Implement TARGET_FRAME_POINTER_REQUIRED.  */
diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
index c99150ff0da..566c53ba228 100644
--- a/gcc/config/microblaze/microblaze.md
+++ b/gcc/config/microblaze/microblaze.md
@@ -2268,7 +2268,27 @@ else
 		      (label_ref (match_operand 1))
 		      (pc)))])
 
-(define_insn "branch_zero64"
+(define_insn "branch_zero_64"
+  [(set (pc)
+	(if_then_else (match_operator:SI 0 "ordered_comparison_operator"
+  				 [(match_operand:SI 1 "register_operand" "d")
+                                  (const_int 0)])
+                      (match_operand:SI 2 "pc_or_label_operand" "")
+                      (match_operand:SI 3 "pc_or_label_operand" "")))
+  ]
+  "TARGET_MB_64"
+  {
+    if (operands[3] == pc_rtx) 
+      return "bea%C0i%?\t%z1,%2";
+    else 
+      return "bea%N0i%?\t%z1,%3";
+  }
+  [(set_attr "type"	"branch")
+   (set_attr "mode"	"none")
+   (set_attr "length"	"4")]
+)
+
+(define_insn "long_branch_zero"
   [(set (pc)
 	(if_then_else (match_operator 0 "ordered_comparison_operator"
   				 [(match_operand 1 "register_operand" "d")
@@ -2279,9 +2299,9 @@ else
   "TARGET_MB_64"
   {
     if (operands[3] == pc_rtx) 
-      return "bea%C0i%?\t%z1,%2";
+      return "beal%C0i%?\t%z1,%2";
     else 
-      return "bea%N0i%?\t%z1,%3";
+      return "beal%N0i%?\t%z1,%3";
   }
   [(set_attr "type"	"branch")
    (set_attr "mode"	"none")
@@ -2310,9 +2330,9 @@ else
 
 (define_insn "branch_compare64"
   [(set (pc)
-        (if_then_else (match_operator 0 "cmp_op"
-                                         [(match_operand 1 "register_operand" "d")
-                                          (match_operand 2 "register_operand" "d")
+        (if_then_else (match_operator:SI 0 "cmp_op"
+                                         [(match_operand:SI 1 "register_operand" "d")
+                                          (match_operand:SI 2 "register_operand" "d")
                                          ])
                       (label_ref (match_operand 3))
                       (pc)))
@@ -2349,6 +2369,47 @@ else
    (set_attr "length"   "12")]
 )
 
+(define_insn "long_branch_compare"
+  [(set (pc)
+        (if_then_else (match_operator 0 "cmp_op"
+                                         [(match_operand 1 "register_operand" "d")
+                                          (match_operand 2 "register_operand" "d")
+                                         ])
+                      (label_ref (match_operand 3))
+                      (pc)))
+  (clobber(reg:DI R_TMP))]
+  "TARGET_MB_64"
+  {
+    operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+    enum rtx_code code = GET_CODE (operands[0]);
+
+    if (code == GT || code == LE)
+      {
+        output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
+        code = swap_condition (code);
+      }
+    else if (code == GTU || code == LEU)
+      {
+        output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
+        code = swap_condition (code);
+      }
+    else if (code == GE || code == LT)
+      {
+        output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
+      }
+    else if (code == GEU || code == LTU)
+      {
+        output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
+      }
+
+    operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
+    return "beal%C0i%?\tr18,%3";
+  }
+  [(set_attr "type"     "branch")
+   (set_attr "mode"     "none")
+   (set_attr "length"   "12")]
+)
+
 (define_insn "branch_compare"
   [(set (pc)
         (if_then_else (match_operator:SI 0 "cmp_op"
@@ -2431,74 +2492,6 @@ else
 
 })
 
-;; Used to implement comparison instructions
-(define_expand "long_condjump"
-  [(set (pc)
-	(if_then_else (match_operand 0)
-		      (label_ref (match_operand 1))
-		      (pc)))])
-
-(define_insn "long_branch_zero"
-  [(set (pc)
-	(if_then_else (match_operator:DI 0 "ordered_comparison_operator"
-  				 [(match_operand:DI 1 "register_operand" "d")
-                                  (const_int 0)])
-                      (match_operand:DI 2 "pc_or_label_operand" "")
-                      (match_operand:DI 3 "pc_or_label_operand" "")))
-  ]
-  "TARGET_MB_64"
-  {
-    if (operands[3] == pc_rtx) 
-      return "beal%C0i%?\t%z1,%2";
-    else 
-      return "beal%N0i%?\t%z1,%3";
-  }
-  [(set_attr "type"	"branch")
-   (set_attr "mode"	"none")
-   (set_attr "length"	"4")]
-)
-
-(define_insn "long_branch_compare"
-  [(set (pc)
-        (if_then_else (match_operator:DI 0 "cmp_op"
-                                         [(match_operand:DI 1 "register_operand" "d")
-                                          (match_operand:DI 2 "register_operand" "d")
-                                         ])
-                      (label_ref (match_operand 3))
-                      (pc)))
-  (clobber(reg:DI R_TMP))]
-  "TARGET_MB_64"
-  {
-    operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
-    enum rtx_code code = GET_CODE (operands[0]);
-
-    if (code == GT || code == LE)
-      {
-        output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
-        code = swap_condition (code);
-      }
-    else if (code == GTU || code == LEU)
-      {
-        output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
-        code = swap_condition (code);
-      }
-    else if (code == GE || code == LT)
-      {
-        output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
-      }
-    else if (code == GEU || code == LTU)
-      {
-        output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
-      }
-
-    operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
-    return "beal%C0i%?\tr18,%3";
-  }
-  [(set_attr "type"     "branch")
-   (set_attr "mode"     "none")
-   (set_attr "length"   "12")]
-)
-
 ;;----------------------------------------------------------------
 ;; Unconditional branches
 ;;----------------------------------------------------------------
-- 
2.37.1 (Apple Git-137.1)