Skip to content

Commit aef2236

Browse files
committed
[InstCombine] Add pre-commit tests. NFC.
1 parent bd32aaa commit aef2236

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

llvm/test/Transforms/InstCombine/intrinsic-select.ll

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,72 @@ entry:
280280
%ret = icmp eq i64 %masked, 0
281281
ret i1 %ret
282282
}
283+
284+
define double @test_fabs_select1(double %a) {
285+
; CHECK-LABEL: @test_fabs_select1(
286+
; CHECK-NEXT: [[COND:%.*]] = fcmp uno double [[A:%.*]], 0.000000e+00
287+
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[COND]], double 0x7FF8000000000000, double [[A]]
288+
; CHECK-NEXT: [[FABS:%.*]] = call double @llvm.fabs.f64(double [[SEL1]])
289+
; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[COND]], double [[FABS]], double [[A]]
290+
; CHECK-NEXT: ret double [[SEL2]]
291+
;
292+
%cond = fcmp uno double %a, 0.000000e+00
293+
%sel1 = select i1 %cond, double 0x7FF8000000000000, double %a
294+
%fabs = call double @llvm.fabs.f64(double %sel1)
295+
%sel2 = select i1 %cond, double %fabs, double %a
296+
ret double %sel2
297+
}
298+
299+
define <2 x double> @test_fabs_select1_vec(<2 x double> %a) {
300+
; CHECK-LABEL: @test_fabs_select1_vec(
301+
; CHECK-NEXT: [[COND:%.*]] = fcmp uno <2 x double> [[A:%.*]], zeroinitializer
302+
; CHECK-NEXT: [[SEL2:%.*]] = select <2 x i1> [[COND]], <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> [[A]]
303+
; CHECK-NEXT: [[FABS:%.*]] = call <2 x double> @llvm.fabs.v2f64(<2 x double> [[SEL2]])
304+
; CHECK-NEXT: [[SEL3:%.*]] = select <2 x i1> [[COND]], <2 x double> [[FABS]], <2 x double> [[A]]
305+
; CHECK-NEXT: ret <2 x double> [[SEL3]]
306+
;
307+
%cond = fcmp uno <2 x double> %a, zeroinitializer
308+
%sel1 = select <2 x i1> %cond, <2 x double> splat(double 0x7FF8000000000000), <2 x double> %a
309+
%fabs = call <2 x double> @llvm.fabs.v2f64(<2 x double> %sel1)
310+
%sel2 = select <2 x i1> %cond, <2 x double> %fabs, <2 x double> %a
311+
ret <2 x double> %sel2
312+
}
313+
314+
define double @test_fabs_select2(double %a) {
315+
; CHECK-LABEL: @test_fabs_select2(
316+
; CHECK-NEXT: [[ABS1:%.*]] = call double @llvm.fabs.f64(double [[A:%.*]])
317+
; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[ABS1]], 0x7FF0000000000000
318+
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double -0.000000e+00, double [[ABS1]]
319+
; CHECK-NEXT: [[ABS2:%.*]] = call double @llvm.fabs.f64(double [[SEL]])
320+
; CHECK-NEXT: ret double [[ABS2]]
321+
;
322+
%abs1 = call double @llvm.fabs.f64(double %a)
323+
%cmp = fcmp oeq double %abs1, 0x7FF0000000000000
324+
%sel = select i1 %cmp, double -0.000000e+00, double %abs1
325+
%abs2 = call double @llvm.fabs.f64(double %sel)
326+
ret double %abs2
327+
}
328+
329+
; nsz flag should be dropped.
330+
331+
define double @test_fabs_select_fmf1(i1 %cond, double %a) {
332+
; CHECK-LABEL: @test_fabs_select_fmf1(
333+
; CHECK-NEXT: [[A1:%.*]] = select nnan ninf nsz i1 [[COND:%.*]], double 0.000000e+00, double [[A2:%.*]]
334+
; CHECK-NEXT: [[A:%.*]] = call double @llvm.fabs.f64(double [[A1]])
335+
; CHECK-NEXT: ret double [[A]]
336+
;
337+
%sel1 = select nnan ninf nsz i1 %cond, double 0.0, double %a
338+
%fabs = call double @llvm.fabs.f64(double %sel1)
339+
ret double %fabs
340+
}
341+
342+
define double @test_fabs_select_fmf2(i1 %cond, double %a) {
343+
; CHECK-LABEL: @test_fabs_select_fmf2(
344+
; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[COND:%.*]], double 0.000000e+00, double [[A:%.*]]
345+
; CHECK-NEXT: [[SEL1:%.*]] = call nnan ninf nsz double @llvm.fabs.f64(double [[SEL2]])
346+
; CHECK-NEXT: ret double [[SEL1]]
347+
;
348+
%sel1 = select i1 %cond, double 0.0, double %a
349+
%fabs = call nnan ninf nsz double @llvm.fabs.f64(double %sel1)
350+
ret double %fabs
351+
}

0 commit comments

Comments
 (0)