Skip to content

Commit a4098bc

Browse files
committed
[ValueTracking] Add additional tests for llvm.powi. NFC.
1 parent a085402 commit a4098bc

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
3+
4+
define i1 @test_powi_even_exp(float %x) {
5+
; CHECK-LABEL: define i1 @test_powi_even_exp(
6+
; CHECK-SAME: float [[X:%.*]]) {
7+
; CHECK-NEXT: ret i1 false
8+
;
9+
%y = call float @llvm.powi.f32(float %x, i32 8)
10+
%cmp = fcmp olt float %y, 0.0
11+
ret i1 %cmp
12+
}
13+
14+
define i1 @test_powi_base(float nofpclass(ninf nnorm nsub nzero) %x, i32 %e) {
15+
; CHECK-LABEL: define i1 @test_powi_base(
16+
; CHECK-SAME: float nofpclass(ninf nzero nsub nnorm) [[X:%.*]], i32 [[E:%.*]]) {
17+
; CHECK-NEXT: ret i1 false
18+
;
19+
%y = call float @llvm.powi.f32(float %x, i32 %e)
20+
%cmp = fcmp olt float %y, 0.0
21+
ret i1 %cmp
22+
}
23+
24+
define i1 @test_powi_base_without_nsz(float nofpclass(ninf nnorm nsub) %x, i32 %e) {
25+
; CHECK-LABEL: define i1 @test_powi_base_without_nsz(
26+
; CHECK-SAME: float nofpclass(ninf nsub nnorm) [[X:%.*]], i32 [[E:%.*]]) {
27+
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.powi.f32.i32(float [[X]], i32 [[E]])
28+
; CHECK-NEXT: [[CMP:%.*]] = fcmp olt float [[Y]], 0.000000e+00
29+
; CHECK-NEXT: ret i1 [[CMP]]
30+
;
31+
%y = call float @llvm.powi.f32(float %x, i32 %e)
32+
%cmp = fcmp olt float %y, 0.0
33+
ret i1 %cmp
34+
}
35+
36+
define float @pr31702(float %x, i32 %n) {
37+
; CHECK-LABEL: define float @pr31702(
38+
; CHECK-SAME: float [[X:%.*]], i32 [[N:%.*]]) {
39+
; CHECK-NEXT: entry:
40+
; CHECK-NEXT: [[CALL1:%.*]] = call float @llvm.powi.f32.i32(float -0.000000e+00, i32 [[N]])
41+
; CHECK-NEXT: [[CALL2:%.*]] = call float @llvm.fabs.f32(float [[CALL1]])
42+
; CHECK-NEXT: ret float [[CALL2]]
43+
;
44+
entry:
45+
%call1 = call float @llvm.powi.f32(float -0.0, i32 %n)
46+
%call2 = call float @llvm.fabs.f32(float %call1)
47+
ret float %call2
48+
}
49+
50+
declare float @llvm.powi.f32(float, i32)
51+
declare float @llvm.fabs.f32(float)

0 commit comments

Comments
 (0)