1; RUN: llc  < %s -march=mipsel -mcpu=mips32 | FileCheck %s -check-prefix=32
2; RUN: llc  < %s -march=mipsel -mcpu=mips32r2 | FileCheck %s -check-prefix=32R2
3; RUN: llc  < %s -march=mips64el -mcpu=mips64 -mattr=n64 | FileCheck %s -check-prefix=64
4; RUN: llc  < %s -march=mips64el -mcpu=mips64r2 -mattr=n64 | FileCheck %s -check-prefix=64R2
5
6define double @func0(double %d0, double %d1) nounwind readnone {
7entry:
8;
9; 32: lui  $[[MSK1:[0-9]+]], 32768
10; 32: and  $[[AND1:[0-9]+]], ${{[0-9]+}}, $[[MSK1]]
11; 32: lui  $[[T0:[0-9]+]], 32767
12; 32: ori  $[[MSK0:[0-9]+]], $[[T0]], 65535
13; 32: and  $[[AND0:[0-9]+]], ${{[0-9]+}}, $[[MSK0]]
14; 32: or   $[[OR:[0-9]+]], $[[AND0]], $[[AND1]]
15; 32: mtc1 $[[OR]], $f1
16
17; 32R2: ext  $[[EXT:[0-9]+]], ${{[0-9]+}}, 31, 1
18; 32R2: ins  $[[INS:[0-9]+]], $[[EXT]], 31, 1
19; 32R2: mtc1 $[[INS]], $f1
20
21; 64: daddiu $[[T0:[0-9]+]], $zero, 1
22; 64: dsll   $[[MSK1:[0-9]+]], $[[T0]], 63
23; 64: and    $[[AND1:[0-9]+]], ${{[0-9]+}}, $[[MSK1]]
24; 64: daddiu $[[MSK0:[0-9]+]], $[[MSK1]], -1
25; 64: and    $[[AND0:[0-9]+]], ${{[0-9]+}}, $[[MSK0]]
26; 64: or     $[[OR:[0-9]+]], $[[AND0]], $[[AND1]]
27; 64: dmtc1  $[[OR]], $f0
28
29; 64R2: dext  $[[EXT:[0-9]+]], ${{[0-9]+}}, 63, 1
30; 64R2: dins  $[[INS:[0-9]+]], $[[EXT]], 63, 1
31; 64R2: dmtc1 $[[INS]], $f0
32
33  %call = tail call double @copysign(double %d0, double %d1) nounwind readnone
34  ret double %call
35}
36
37declare double @copysign(double, double) nounwind readnone
38
39define float @func1(float %f0, float %f1) nounwind readnone {
40entry:
41
42; 32: lui  $[[MSK1:[0-9]+]], 32768
43; 32: and  $[[AND1:[0-9]+]], ${{[0-9]+}}, $[[MSK1]]
44; 32: lui  $[[T0:[0-9]+]], 32767
45; 32: ori  $[[MSK0:[0-9]+]], $[[T0]], 65535
46; 32: and  $[[AND0:[0-9]+]], ${{[0-9]+}}, $[[MSK0]]
47; 32: or   $[[OR:[0-9]+]], $[[AND0]], $[[AND1]]
48; 32: mtc1 $[[OR]], $f0
49
50; 32R2: ext  $[[EXT:[0-9]+]], ${{[0-9]+}}, 31, 1
51; 32R2: ins  $[[INS:[0-9]+]], $[[EXT]], 31, 1
52; 32R2: mtc1 $[[INS]], $f0
53
54  %call = tail call float @copysignf(float %f0, float %f1) nounwind readnone
55  ret float %call
56}
57
58declare float @copysignf(float, float) nounwind readnone
59
60