summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-bsp/recipes-microblaze/gcc/gcc-9/0060-Author-Nagaraju-nmekala-xilinx.com.patch
blob: 9f87866949904ca03f86dd8c65be99749bf2e5c6 (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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
From f0332f119c3cbe95886dae77c4b5a9b9907b4b17 Mon Sep 17 00:00:00 2001
From: Nagaraju <nmekala@xilinx.com>
Date: Thu, 18 Apr 2019 16:00:37 +0530
Subject: [PATCH 60/63] Author: Nagaraju <nmekala@xilinx.com> Date:   Wed Apr
 17 14:11:00 2019 +0530

    [Patch, microblaze]: MB-64 removal of barrel-shift instructions from default
    By default MB-64 is generatting barrel-shift instructions. It has been
    removed from default. Barrel-shift instructions will be generated only if
    barrel-shifter is enabled. Similarly to double instructions as well.

    Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
---
 gcc/config/microblaze/microblaze.c  |   2 +-
 gcc/config/microblaze/microblaze.md | 269 +++++++++++++++++++++++++++++++++---
 2 files changed, 252 insertions(+), 19 deletions(-)

diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index 220e03d..5c09452 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -4008,7 +4008,7 @@ microblaze_expand_divide (rtx operands[])
   emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
 
   if (TARGET_MB_64) {
-      emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
+      emit_insn (gen_ashldi3 (regt1, operands[1], GEN_INT(4)));
       emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
     }
   else  {
diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
index 830ef77..3e7c647 100644
--- a/gcc/config/microblaze/microblaze.md
+++ b/gcc/config/microblaze/microblaze.md
@@ -547,7 +547,7 @@
   [(set (match_operand:DF 0 "register_operand" "=d")
         (plus:DF (match_operand:DF 1 "register_operand" "d")
                  (match_operand:DF 2 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "dadd\t%0,%1,%2"
   [(set_attr "type"     "fadd")
   (set_attr "mode"      "DF")
@@ -557,7 +557,7 @@
   [(set (match_operand:DF 0 "register_operand" "=d")
         (minus:DF (match_operand:DF 1 "register_operand" "d")
                   (match_operand:DF 2 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "drsub\t%0,%2,%1"
   [(set_attr "type"     "frsub")
   (set_attr "mode"      "DF")
@@ -567,7 +567,7 @@
   [(set (match_operand:DF 0 "register_operand" "=d")
         (mult:DF (match_operand:DF 1 "register_operand" "d")
                  (match_operand:DF 2 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "dmul\t%0,%1,%2"
   [(set_attr "type"     "fmul")
   (set_attr "mode"      "DF")
@@ -577,7 +577,7 @@
   [(set (match_operand:DF 0 "register_operand" "=d")
         (div:DF (match_operand:DF 1 "register_operand" "d")
                 (match_operand:DF 2 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "ddiv\t%0,%2,%1"
   [(set_attr "type"     "fdiv")
   (set_attr "mode"      "DF")
@@ -587,7 +587,7 @@
 (define_insn "sqrtdf2"
   [(set (match_operand:DF 0 "register_operand" "=d")
         (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "dsqrt\t%0,%1"
   [(set_attr "type"     "fsqrt")
   (set_attr "mode"      "DF")
@@ -596,7 +596,7 @@
 (define_insn "floatdidf2"
   [(set (match_operand:DF 0 "register_operand" "=d")
         (float:DF (match_operand:DI 1 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "dbl\t%0,%1"
   [(set_attr "type"     "fcvt")
   (set_attr "mode"      "DF")
@@ -605,7 +605,7 @@
 (define_insn "fix_truncdfdi2"
   [(set (match_operand:DI 0 "register_operand" "=d")
         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
   "dlong\t%0,%1"
   [(set_attr "type"     "fcvt")
   (set_attr "mode"      "DI")
@@ -1301,6 +1301,34 @@
   (set_attr "mode"	"DI")
   (set_attr "length"	"4")])
 
+(define_insn "*movdi_internal2_bshift"
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,   d,d,R,m")
+	(match_operand:DI 1 "move_src_operand"         " d,I,Mnis,R,m,dJ,dJ"))]
+  "TARGET_MB_64 && TARGET_BARREL_SHIFT"
+  {
+    switch (which_alternative)
+    {
+      case 0:
+        return "addlk\t%0,%1,r0";
+     case 1:
+     case 2:
+        if (GET_CODE (operands[1]) == CONST_INT &&
+	    (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
+	  return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
+        else
+	  return "addlik\t%0,r0,%1";
+     case 3:
+     case 4:
+       return "ll%i1\t%0,%1";
+     case 5:
+     case 6:
+       return "sl%i0\t%z1,%0";
+     }
+   }
+  [(set_attr "type"	"load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
+  (set_attr "mode"	"DI")
+  (set_attr "length"	"4,4,12,4,8,4,8")])
+
 (define_insn "*movdi_internal2"
   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,   d,d,R,m")
 	(match_operand:DI 1 "move_src_operand"         " d,I,Mnis,R,m,dJ,dJ"))]
@@ -1314,7 +1342,15 @@
      case 2:
         if (GET_CODE (operands[1]) == CONST_INT && 
 	    (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
- 	  return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
+          {
+            operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+            output_asm_insn ("addlik\t%0,r0,%h1", operands);
+            output_asm_insn ("addlik\t%2,r0,32", operands);
+            output_asm_insn ("addlik\t%2,%2,-1", operands);
+            output_asm_insn ("beaneid\t%2,.-8", operands);
+            output_asm_insn ("addlk\t%0,%0,%0", operands);
+            return "addlik\t%0,%0,%j1 #li => la";
+          }
         else	
 	  return "addlik\t%0,r0,%1";
      case 3:
@@ -1388,7 +1424,7 @@
 (define_insn "movdi_long_int"
   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
 	(match_operand:DI 1 "general_operand"      "i"))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_BARREL_SHIFT"
   "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
   [(set_attr "type"	"no_delay_arith")
   (set_attr "mode"	"DI")
@@ -1655,6 +1691,33 @@
 ;; movdf_internal
 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
 ;;
+(define_insn "*movdf_internal_64_bshift"
+  [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
+        (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
+  "TARGET_MB_64 && TARGET_BARREL_SHIFT"
+  {
+    switch (which_alternative)
+    {
+      case 0:
+	return "addlk\t%0,%1,r0";
+      case 1:
+	return "addlk\t%0,r0,r0";
+      case 2:
+      case 4:
+          return "ll%i1\t%0,%1";
+      case 3:
+      {
+	return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
+      }
+      case 5:
+	return "sl%i0\t%1,%0";
+    }
+    gcc_unreachable ();
+  }
+  [(set_attr "type"     "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
+  (set_attr "mode"      "DF")
+  (set_attr "length"    "4,4,4,16,4,4")])
+
 (define_insn "*movdf_internal_64"
   [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
         (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
@@ -1671,7 +1734,13 @@
           return "ll%i1\t%0,%1";
       case 3:
       {
-	return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
+	operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+	output_asm_insn ("addlik\t%0,r0,%h1", operands);
+	output_asm_insn ("addlik\t%2,r0,32", operands);
+	output_asm_insn ("addlik\t%2,%2,-1", operands);
+	output_asm_insn ("beaneid\t%2,.-8", operands);
+	output_asm_insn ("addlk\t%0,%0,%0", operands);
+	return "addlik\t%0,%0,%j1 #li => la";
       }
       case 5:
 	return "sl%i0\t%1,%0";
@@ -1791,11 +1860,21 @@
 "TARGET_MB_64"
 {
 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
   {
     emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
     DONE;
   }
+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
+  {
+    emit_insn(gen_ashldi3_const (operands[0], operands[1],operands[2]));
+    DONE;
+  }
+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 &&  GET_CODE (operands[2]) == REG)
+  {
+    emit_insn(gen_ashldi3_reg (operands[0], operands[1],operands[2]));
+    DONE;
+  }
 else
   FAIL;
 }    
@@ -1805,7 +1884,7 @@ else
   [(set (match_operand:DI 0 "register_operand" "=d,d")
 	(ashift:DI (match_operand:DI 1 "register_operand" "d,d")
                    (match_operand:DI 2 "arith_operand"    "I,d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_BARREL_SHIFT"
   "@
   bsllli\t%0,%1,%2
   bslll\t%0,%1,%2"
@@ -1813,6 +1892,51 @@ else
   (set_attr "mode"	"DI,DI")
   (set_attr "length"	"4,4")]
 )
+
+(define_insn "ashldi3_const"
+  [(set (match_operand:DI 0 "register_operand" "=&d")
+       (ashift:DI (match_operand:DI 1 "register_operand"  "d")
+                   (match_operand:DI 2 "immediate_operand" "I")))]
+  "TARGET_MB_64"
+  {
+    operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+
+    output_asm_insn ("orli\t%3,r0,%2", operands);
+    if (REGNO (operands[0]) != REGNO (operands[1]))
+        output_asm_insn ("addlk\t%0,%1,r0", operands);
+
+    output_asm_insn ("addlik\t%3,%3,-1", operands);
+    output_asm_insn ("beaneid\t%3,.-8", operands);
+    return "addlk\t%0,%0,%0";
+  }
+  [(set_attr "type"    "multi")
+   (set_attr "mode"    "DI")
+   (set_attr "length"  "20")]
+)
+
+(define_insn "ashldi3_reg"
+  [(set (match_operand:DI 0 "register_operand" "=&d")
+       (ashift:DI (match_operand:DI 1 "register_operand"  "d")
+                   (match_operand:DI 2 "register_operand" "d")))]
+  "TARGET_MB_64"
+  {
+    operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+    output_asm_insn ("andli\t%3,%2,31", operands);
+    if (REGNO (operands[0]) != REGNO (operands[1])) 
+      output_asm_insn ("addlk\t%0,r0,%1", operands);
+    /* Exit the loop if zero shift. */
+    output_asm_insn ("beaeqid\t%3,.+24", operands);
+    /* Emit the loop.  */
+    output_asm_insn ("addlk\t%0,%0,r0", operands);
+    output_asm_insn ("addlik\t%3,%3,-1", operands);
+    output_asm_insn ("beaneid\t%3,.-8", operands);
+    return "addlk\t%0,%0,%0";
+  }
+  [(set_attr "type"    "multi")
+  (set_attr "mode"     "DI")
+  (set_attr "length"   "28")]
+)
+
 ;; The following patterns apply when there is no barrel shifter present
 
 (define_insn "*ashlsi3_with_mul_delay"
@@ -1946,11 +2070,21 @@ else
 "TARGET_MB_64"
 {
 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
   {
     emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
     DONE;
   }
+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
+  {
+    emit_insn(gen_ashrdi3_const (operands[0], operands[1],operands[2]));
+    DONE;
+  }
+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 &&  GET_CODE (operands[2]) == REG)
+  {
+    emit_insn(gen_ashrdi3_reg (operands[0], operands[1],operands[2]));
+    DONE;
+  }
 else
   FAIL;
 }    
@@ -1960,7 +2094,7 @@ else
   [(set (match_operand:DI 0 "register_operand" "=d,d")
 	(ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
                    (match_operand:DI 2 "arith_operand"    "I,d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_BARREL_SHIFT"
   "@
    bslrai\t%0,%1,%2
    bslra\t%0,%1,%2"
@@ -1968,6 +2102,51 @@ else
   (set_attr "mode"	"DI,DI")
   (set_attr "length"	"4,4")]
   )
+
+(define_insn "ashrdi3_const"
+  [(set (match_operand:DI 0 "register_operand" "=&d")
+       (ashiftrt:DI (match_operand:DI 1 "register_operand"  "d")
+                   (match_operand:DI 2 "immediate_operand" "I")))]
+  "TARGET_MB_64"
+  {
+    operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+
+    output_asm_insn ("orli\t%3,r0,%2", operands);
+    if (REGNO (operands[0]) != REGNO (operands[1]))
+        output_asm_insn ("addlk\t%0,%1,r0", operands);
+
+    output_asm_insn ("addlik\t%3,%3,-1", operands);
+    output_asm_insn ("beaneid\t%3,.-8", operands);
+    return "srla\t%0,%0";
+  }
+  [(set_attr "type"    "arith")
+  (set_attr "mode"    "DI")
+  (set_attr "length"  "20")]
+)
+
+(define_insn "ashrdi3_reg"
+  [(set (match_operand:DI 0 "register_operand" "=&d")
+       (ashiftrt:DI (match_operand:DI 1 "register_operand"  "d")
+                   (match_operand:DI 2 "register_operand" "d")))]
+  "TARGET_MB_64"
+  {
+    operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+    output_asm_insn ("andli\t%3,%2,31", operands);
+    if (REGNO (operands[0]) != REGNO (operands[1])) 
+      output_asm_insn ("addlk\t%0,r0,%1", operands);
+    /* Exit the loop if zero shift. */
+    output_asm_insn ("beaeqid\t%3,.+24", operands);
+    /* Emit the loop.  */
+    output_asm_insn ("addlk\t%0,%0,r0", operands);
+    output_asm_insn ("addlik\t%3,%3,-1", operands);
+    output_asm_insn ("beaneid\t%3,.-8", operands);
+    return "srla\t%0,%0";
+  }
+  [(set_attr "type"    "multi")
+  (set_attr "mode"     "DI")
+  (set_attr "length"   "28")]
+)
+
 (define_expand "ashrsi3"
   [(set (match_operand:SI 0 "register_operand" "=&d")
 	(ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
@@ -2085,11 +2264,21 @@ else
 "TARGET_MB_64"
 {
 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
   {
     emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
     DONE;
   }
+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
+  {
+    emit_insn(gen_lshrdi3_const (operands[0], operands[1],operands[2]));
+    DONE;
+  }
+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 &&  GET_CODE (operands[2]) == REG)
+  {
+    emit_insn(gen_lshrdi3_reg (operands[0], operands[1],operands[2]));
+    DONE;
+  }
 else
   FAIL;
 }    
@@ -2099,7 +2288,7 @@ else
   [(set (match_operand:DI 0 "register_operand" "=d,d")
 	(lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
                    (match_operand:DI 2 "arith_operand"    "I,d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_BARREL_SHIFT"
   "@
    bslrli\t%0,%1,%2
    bslrl\t%0,%1,%2"
@@ -2108,6 +2297,50 @@ else
   (set_attr "length"	"4,4")]
   )
 
+(define_insn "lshrdi3_const"
+  [(set (match_operand:DI 0 "register_operand" "=&d")
+       (lshiftrt:DI (match_operand:DI 1 "register_operand"  "d")
+                   (match_operand:DI 2 "immediate_operand" "I")))]
+  "TARGET_MB_64"
+  {
+    operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+
+    output_asm_insn ("orli\t%3,r0,%2", operands);
+    if (REGNO (operands[0]) != REGNO (operands[1]))
+        output_asm_insn ("addlk\t%0,%1,r0", operands);
+
+    output_asm_insn ("addlik\t%3,%3,-1", operands);
+    output_asm_insn ("beaneid\t%3,.-8", operands);
+    return "srll\t%0,%0";
+  }
+  [(set_attr "type"    "multi")
+  (set_attr "mode"    "DI")
+  (set_attr "length"  "20")]
+)
+
+(define_insn "lshrdi3_reg"
+  [(set (match_operand:DI 0 "register_operand" "=&d")
+       (lshiftrt:DI (match_operand:DI 1 "register_operand"  "d")
+                   (match_operand:DI 2 "register_operand" "d")))]
+  "TARGET_MB_64"
+  {
+    operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
+    output_asm_insn ("andli\t%3,%2,31", operands);
+    if (REGNO (operands[0]) != REGNO (operands[1]))
+      output_asm_insn ("addlk\t%0,r0,%1", operands);
+    /* Exit the loop if zero shift. */
+    output_asm_insn ("beaeqid\t%3,.+24", operands);
+    /* Emit the loop.  */
+    output_asm_insn ("addlk\t%0,%0,r0", operands);
+    output_asm_insn ("addlik\t%3,%3,-1", operands);
+    output_asm_insn ("beaneid\t%3,.-8", operands);
+    return "srll\t%0,%0";
+  }
+  [(set_attr "type"    "multi")
+  (set_attr "mode"     "SI")
+  (set_attr "length"   "28")]
+)
+
 (define_expand "lshrsi3"
   [(set (match_operand:SI 0 "register_operand" "=&d")
 	(lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
@@ -2235,7 +2468,7 @@ else
 	(eq:DI 
 	       (match_operand:DI 1 "register_operand" "d")
 	       (match_operand:DI 2 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
   "pcmpleq\t%0,%1,%2"
   [(set_attr "type"	"arith")
    (set_attr "mode"	"DI")
@@ -2247,7 +2480,7 @@ else
 	(ne:DI 
 	       (match_operand:DI 1 "register_operand" "d")
 	       (match_operand:DI 2 "register_operand" "d")))]
-  "TARGET_MB_64"
+  "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
   "pcmplne\t%0,%1,%2"
   [(set_attr "type"	"arith")
   (set_attr "mode"	"DI")
-- 
2.7.4