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