@@ -10,25 +10,23 @@ target triple = "wasm32-unknown-unknown"
10
10
11
11
define void @store (half %x , ptr %p ) nounwind {
12
12
; ALL-LABEL: store:
13
- ; ALL: .functype store (f32 , i32) -> ()
13
+ ; ALL: .functype store (i32 , i32) -> ()
14
14
; ALL-NEXT: # %bb.0:
15
- ; ALL-NEXT: local.get $push2=, 1
16
- ; ALL-NEXT: local.get $push1=, 0
17
- ; ALL-NEXT: call $push0=, __truncsfhf2, $pop1
18
- ; ALL-NEXT: i32.store16 0($pop2), $pop0
15
+ ; ALL-NEXT: local.get $push1=, 1
16
+ ; ALL-NEXT: local.get $push0=, 0
17
+ ; ALL-NEXT: i32.store16 0($pop1), $pop0
19
18
; ALL-NEXT: return
20
19
store half %x , ptr %p
21
20
ret void
22
21
}
23
22
24
23
define half @return (ptr %p ) nounwind {
25
24
; ALL-LABEL: return:
26
- ; ALL: .functype return (i32) -> (f32 )
25
+ ; ALL: .functype return (i32) -> (i32 )
27
26
; ALL-NEXT: # %bb.0:
28
- ; ALL-NEXT: local.get $push2=, 0
29
- ; ALL-NEXT: i32.load16_u $push0=, 0($pop2)
30
- ; ALL-NEXT: call $push1=, __extendhfsf2, $pop0
31
- ; ALL-NEXT: return $pop1
27
+ ; ALL-NEXT: local.get $push1=, 0
28
+ ; ALL-NEXT: i32.load16_u $push0=, 0($pop1)
29
+ ; ALL-NEXT: return $pop0
32
30
%r = load half , ptr %p
33
31
ret half %r
34
32
}
@@ -80,50 +78,28 @@ define dso_local float @loadf(ptr nocapture readonly %a) local_unnamed_addr noun
80
78
}
81
79
82
80
define dso_local void @stored (ptr nocapture %a , double %b ) local_unnamed_addr nounwind {
83
- ; DEFISEL-LABEL: stored:
84
- ; DEFISEL: .functype stored (i32, f64) -> ()
85
- ; DEFISEL-NEXT: # %bb.0:
86
- ; DEFISEL-NEXT: local.get $push2=, 0
87
- ; DEFISEL-NEXT: local.get $push1=, 1
88
- ; DEFISEL-NEXT: call $push0=, __truncdfhf2, $pop1
89
- ; DEFISEL-NEXT: i32.store16 0($pop2), $pop0
90
- ; DEFISEL-NEXT: return
91
- ;
92
- ; FASTISEL-LABEL: stored:
93
- ; FASTISEL: .functype stored (i32, f64) -> ()
94
- ; FASTISEL-NEXT: # %bb.0:
95
- ; FASTISEL-NEXT: local.get $push4=, 0
96
- ; FASTISEL-NEXT: local.get $push3=, 1
97
- ; FASTISEL-NEXT: call $push2=, __truncdfhf2, $pop3
98
- ; FASTISEL-NEXT: i32.const $push1=, 65535
99
- ; FASTISEL-NEXT: i32.and $push0=, $pop2, $pop1
100
- ; FASTISEL-NEXT: i32.store16 0($pop4), $pop0
101
- ; FASTISEL-NEXT: return
81
+ ; ALL-LABEL: stored:
82
+ ; ALL: .functype stored (i32, f64) -> ()
83
+ ; ALL-NEXT: # %bb.0:
84
+ ; ALL-NEXT: local.get $push2=, 0
85
+ ; ALL-NEXT: local.get $push1=, 1
86
+ ; ALL-NEXT: call $push0=, __truncdfhf2, $pop1
87
+ ; ALL-NEXT: i32.store16 0($pop2), $pop0
88
+ ; ALL-NEXT: return
102
89
%x = tail call i16 @llvm.convert.to.fp16.f64 (double %b )
103
90
store i16 %x , ptr %a , align 2
104
91
ret void
105
92
}
106
93
107
94
define dso_local void @storef (ptr nocapture %a , float %b ) local_unnamed_addr nounwind {
108
- ; DEFISEL-LABEL: storef:
109
- ; DEFISEL: .functype storef (i32, f32) -> ()
110
- ; DEFISEL-NEXT: # %bb.0:
111
- ; DEFISEL-NEXT: local.get $push2=, 0
112
- ; DEFISEL-NEXT: local.get $push1=, 1
113
- ; DEFISEL-NEXT: call $push0=, __truncsfhf2, $pop1
114
- ; DEFISEL-NEXT: i32.store16 0($pop2), $pop0
115
- ; DEFISEL-NEXT: return
116
- ;
117
- ; FASTISEL-LABEL: storef:
118
- ; FASTISEL: .functype storef (i32, f32) -> ()
119
- ; FASTISEL-NEXT: # %bb.0:
120
- ; FASTISEL-NEXT: local.get $push4=, 0
121
- ; FASTISEL-NEXT: local.get $push3=, 1
122
- ; FASTISEL-NEXT: call $push2=, __truncsfhf2, $pop3
123
- ; FASTISEL-NEXT: i32.const $push1=, 65535
124
- ; FASTISEL-NEXT: i32.and $push0=, $pop2, $pop1
125
- ; FASTISEL-NEXT: i32.store16 0($pop4), $pop0
126
- ; FASTISEL-NEXT: return
95
+ ; ALL-LABEL: storef:
96
+ ; ALL: .functype storef (i32, f32) -> ()
97
+ ; ALL-NEXT: # %bb.0:
98
+ ; ALL-NEXT: local.get $push2=, 0
99
+ ; ALL-NEXT: local.get $push1=, 1
100
+ ; ALL-NEXT: call $push0=, __truncsfhf2, $pop1
101
+ ; ALL-NEXT: i32.store16 0($pop2), $pop0
102
+ ; ALL-NEXT: return
127
103
%x = tail call i16 @llvm.convert.to.fp16.f32 (float %b )
128
104
store i16 %x , ptr %a , align 2
129
105
ret void
@@ -170,33 +146,20 @@ define void @test_bitcast_to_half(ptr %addr, i16 %in) nounwind {
170
146
171
147
define half @from_bits (i16 %x ) nounwind {
172
148
; ALL-LABEL: from_bits:
173
- ; ALL: .functype from_bits (i32) -> (f32 )
149
+ ; ALL: .functype from_bits (i32) -> (i32 )
174
150
; ALL-NEXT: # %bb.0:
175
- ; ALL-NEXT: local.get $push1=, 0
176
- ; ALL-NEXT: call $push0=, __extendhfsf2, $pop1
151
+ ; ALL-NEXT: local.get $push0=, 0
177
152
; ALL-NEXT: return $pop0
178
153
%res = bitcast i16 %x to half
179
154
ret half %res
180
155
}
181
156
182
157
define i16 @to_bits (half %x ) nounwind {
183
- ; DEFISEL-LABEL: to_bits:
184
- ; DEFISEL: .functype to_bits (f32) -> (i32)
185
- ; DEFISEL-NEXT: # %bb.0:
186
- ; DEFISEL-NEXT: local.get $push3=, 0
187
- ; DEFISEL-NEXT: call $push1=, __truncsfhf2, $pop3
188
- ; DEFISEL-NEXT: i32.const $push0=, 65535
189
- ; DEFISEL-NEXT: i32.and $push2=, $pop1, $pop0
190
- ; DEFISEL-NEXT: return $pop2
191
- ;
192
- ; FASTISEL-LABEL: to_bits:
193
- ; FASTISEL: .functype to_bits (f32) -> (i32)
194
- ; FASTISEL-NEXT: # %bb.0:
195
- ; FASTISEL-NEXT: local.get $push3=, 0
196
- ; FASTISEL-NEXT: call $push2=, __truncsfhf2, $pop3
197
- ; FASTISEL-NEXT: i32.const $push1=, 65535
198
- ; FASTISEL-NEXT: i32.and $push0=, $pop2, $pop1
199
- ; FASTISEL-NEXT: return $pop0
158
+ ; ALL-LABEL: to_bits:
159
+ ; ALL: .functype to_bits (i32) -> (i32)
160
+ ; ALL-NEXT: # %bb.0:
161
+ ; ALL-NEXT: local.get $push0=, 0
162
+ ; ALL-NEXT: return $pop0
200
163
%res = bitcast half %x to i16
201
164
ret i16 %res
202
165
}
@@ -559,27 +522,35 @@ define float @test_sitofp_fadd_i32(i32 %a, ptr %b) nounwind {
559
522
; DEFISEL-LABEL: test_sitofp_fadd_i32:
560
523
; DEFISEL: .functype test_sitofp_fadd_i32 (i32, i32) -> (f32)
561
524
; DEFISEL-NEXT: # %bb.0:
562
- ; DEFISEL-NEXT: local.get $push6=, 1
563
- ; DEFISEL-NEXT: i32.load16_u $push1=, 0($pop6)
525
+ ; DEFISEL-NEXT: local.get $push8=, 1
526
+ ; DEFISEL-NEXT: i32.load16_u $push7=, 0($pop8)
527
+ ; DEFISEL-NEXT: local.set 1, $pop7
528
+ ; DEFISEL-NEXT: local.get $push9=, 0
529
+ ; DEFISEL-NEXT: f32.convert_i32_s $push0=, $pop9
530
+ ; DEFISEL-NEXT: call $push1=, __truncsfhf2, $pop0
564
531
; DEFISEL-NEXT: call $push2=, __extendhfsf2, $pop1
565
- ; DEFISEL-NEXT: local.get $push7 =, 0
566
- ; DEFISEL-NEXT: f32.convert_i32_s $push0 =, $pop7
567
- ; DEFISEL-NEXT: call $push3 =, __truncsfhf2 , $pop0
568
- ; DEFISEL-NEXT: call $push4 =, __extendhfsf2 , $pop3
569
- ; DEFISEL-NEXT: f32.add $push5 =, $pop2 , $pop4
570
- ; DEFISEL-NEXT: return $pop5
532
+ ; DEFISEL-NEXT: local.get $push10 =, 1
533
+ ; DEFISEL-NEXT: call $push3 =, __extendhfsf2, $pop10
534
+ ; DEFISEL-NEXT: f32.add $push4 =, $pop2 , $pop3
535
+ ; DEFISEL-NEXT: call $push5 =, __truncsfhf2 , $pop4
536
+ ; DEFISEL-NEXT: call $push6 =, __extendhfsf2 , $pop5
537
+ ; DEFISEL-NEXT: return $pop6
571
538
;
572
539
; FASTISEL-LABEL: test_sitofp_fadd_i32:
573
540
; FASTISEL: .functype test_sitofp_fadd_i32 (i32, i32) -> (f32)
574
541
; FASTISEL-NEXT: # %bb.0:
575
- ; FASTISEL-NEXT: local.get $push6=, 1
576
- ; FASTISEL-NEXT: i32.load16_u $push2=, 0($pop6)
542
+ ; FASTISEL-NEXT: local.get $push8=, 1
543
+ ; FASTISEL-NEXT: i32.load16_u $push7=, 0($pop8)
544
+ ; FASTISEL-NEXT: local.set 1, $pop7
545
+ ; FASTISEL-NEXT: local.get $push9=, 0
546
+ ; FASTISEL-NEXT: f32.convert_i32_s $push1=, $pop9
547
+ ; FASTISEL-NEXT: call $push2=, __truncsfhf2, $pop1
577
548
; FASTISEL-NEXT: call $push3=, __extendhfsf2, $pop2
578
- ; FASTISEL-NEXT: local.get $push7 =, 0
579
- ; FASTISEL-NEXT: f32.convert_i32_s $push1 =, $pop7
580
- ; FASTISEL-NEXT: call $push4 =, __truncsfhf2 , $pop1
581
- ; FASTISEL-NEXT: call $push5 =, __extendhfsf2 , $pop4
582
- ; FASTISEL-NEXT: f32.add $push0=, $pop3 , $pop5
549
+ ; FASTISEL-NEXT: local.get $push10 =, 1
550
+ ; FASTISEL-NEXT: call $push4 =, __extendhfsf2, $pop10
551
+ ; FASTISEL-NEXT: f32.add $push5 =, $pop3 , $pop4
552
+ ; FASTISEL-NEXT: call $push6 =, __truncsfhf2 , $pop5
553
+ ; FASTISEL-NEXT: call $push0=, __extendhfsf2 , $pop6
583
554
; FASTISEL-NEXT: return $pop0
584
555
%tmp0 = load half , ptr %b
585
556
%tmp1 = sitofp i32 %a to half
@@ -590,17 +561,20 @@ define float @test_sitofp_fadd_i32(i32 %a, ptr %b) nounwind {
590
561
591
562
define half @chained_fp_ops (half %x ) {
592
563
; ALL-LABEL: chained_fp_ops:
593
- ; ALL: .functype chained_fp_ops (f32) -> (f32)
564
+ ; ALL: .functype chained_fp_ops (i32) -> (i32)
565
+ ; ALL-NEXT: .local f32
594
566
; ALL-NEXT: # %bb.0: # %start
595
- ; ALL-NEXT: local.get $push6=, 0
596
- ; ALL-NEXT: call $push0=, __truncsfhf2, $pop6
597
- ; ALL-NEXT: call $push5=, __extendhfsf2, $pop0
598
- ; ALL-NEXT: local.tee $push4=, 0, $pop5
599
- ; ALL-NEXT: local.get $push7=, 0
600
- ; ALL-NEXT: f32.add $push1=, $pop4, $pop7
601
- ; ALL-NEXT: f32.const $push2=, 0x1p-1
602
- ; ALL-NEXT: f32.mul $push3=, $pop1, $pop2
603
- ; ALL-NEXT: return $pop3
567
+ ; ALL-NEXT: local.get $push8=, 0
568
+ ; ALL-NEXT: call $push7=, __extendhfsf2, $pop8
569
+ ; ALL-NEXT: local.tee $push6=, 1, $pop7
570
+ ; ALL-NEXT: local.get $push9=, 1
571
+ ; ALL-NEXT: f32.add $push0=, $pop6, $pop9
572
+ ; ALL-NEXT: call $push2=, __truncsfhf2, $pop0
573
+ ; ALL-NEXT: call $push3=, __extendhfsf2, $pop2
574
+ ; ALL-NEXT: f32.const $push1=, 0x1p-1
575
+ ; ALL-NEXT: f32.mul $push4=, $pop3, $pop1
576
+ ; ALL-NEXT: call $push5=, __truncsfhf2, $pop4
577
+ ; ALL-NEXT: return $pop5
604
578
start:
605
579
%y = fmul half %x , 0xH4000
606
580
%z = fdiv half %y , 0xH4000
@@ -609,16 +583,15 @@ start:
609
583
610
584
define half @test_select_cc (half ) nounwind {
611
585
; ALL-LABEL: test_select_cc:
612
- ; ALL: .functype test_select_cc (f32 ) -> (f32 )
586
+ ; ALL: .functype test_select_cc (i32 ) -> (i32 )
613
587
; ALL-NEXT: # %bb.0:
614
- ; ALL-NEXT: f32.const $push4=, 0x1p0
588
+ ; ALL-NEXT: i32.const $push4=, 15360
589
+ ; ALL-NEXT: i32.const $push3=, 0
590
+ ; ALL-NEXT: local.get $push6=, 0
591
+ ; ALL-NEXT: call $push1=, __extendhfsf2, $pop6
615
592
; ALL-NEXT: f32.const $push0=, 0x0p0
616
- ; ALL-NEXT: local.get $push7=, 0
617
- ; ALL-NEXT: call $push1=, __truncsfhf2, $pop7
618
- ; ALL-NEXT: call $push2=, __extendhfsf2, $pop1
619
- ; ALL-NEXT: f32.const $push6=, 0x0p0
620
- ; ALL-NEXT: f32.ne $push3=, $pop2, $pop6
621
- ; ALL-NEXT: f32.select $push5=, $pop4, $pop0, $pop3
593
+ ; ALL-NEXT: f32.ne $push2=, $pop1, $pop0
594
+ ; ALL-NEXT: i32.select $push5=, $pop4, $pop3, $pop2
622
595
; ALL-NEXT: return $pop5
623
596
%2 = fcmp une half %0 , 0xH0000
624
597
%3 = uitofp i1 %2 to half
@@ -627,27 +600,28 @@ define half @test_select_cc(half) nounwind {
627
600
628
601
define half @fabs (half %x ) nounwind {
629
602
; ALL-LABEL: fabs:
630
- ; ALL: .functype fabs (f32 ) -> (f32 )
603
+ ; ALL: .functype fabs (i32 ) -> (i32 )
631
604
; ALL-NEXT: # %bb.0:
632
- ; ALL-NEXT: local.get $push3=, 0
633
- ; ALL-NEXT: call $push0=, __truncsfhf2, $pop3
634
- ; ALL-NEXT: call $push1=, __extendhfsf2, $pop0
635
- ; ALL-NEXT: f32.abs $push2=, $pop1
636
- ; ALL-NEXT: return $pop2
605
+ ; ALL-NEXT: local.get $push2=, 0
606
+ ; ALL-NEXT: i32.const $push0=, 32767
607
+ ; ALL-NEXT: i32.and $push1=, $pop2, $pop0
608
+ ; ALL-NEXT: return $pop1
637
609
%a = call half @llvm.fabs.f16 (half %x )
638
610
ret half %a
639
611
}
640
612
641
613
define half @fcopysign (half %x , half %y ) nounwind {
642
614
; ALL-LABEL: fcopysign:
643
- ; ALL: .functype fcopysign (f32, f32 ) -> (f32 )
615
+ ; ALL: .functype fcopysign (i32, i32 ) -> (i32 )
644
616
; ALL-NEXT: # %bb.0:
645
- ; ALL-NEXT: local.get $push3=, 0
646
- ; ALL-NEXT: call $push0=, __truncsfhf2, $pop3
647
- ; ALL-NEXT: call $push1=, __extendhfsf2, $pop0
648
- ; ALL-NEXT: local.get $push4=, 1
649
- ; ALL-NEXT: f32.copysign $push2=, $pop1, $pop4
650
- ; ALL-NEXT: return $pop2
617
+ ; ALL-NEXT: local.get $push5=, 0
618
+ ; ALL-NEXT: i32.const $push2=, 32767
619
+ ; ALL-NEXT: i32.and $push3=, $pop5, $pop2
620
+ ; ALL-NEXT: local.get $push6=, 1
621
+ ; ALL-NEXT: i32.const $push0=, -32768
622
+ ; ALL-NEXT: i32.and $push1=, $pop6, $pop0
623
+ ; ALL-NEXT: i32.or $push4=, $pop3, $pop1
624
+ ; ALL-NEXT: return $pop4
651
625
%a = call half @llvm.copysign.f16 (half %x , half %y )
652
626
ret half %a
653
627
}
0 commit comments