Skip to content

Commit b6e889d

Browse files
Prefer @llvm.ceil.* intrinsics (#8897)
llvm/llvm-project#171288 removed the SDAG lowering for ceil/ceilf calls. This was causing some errors for us when using webassembly: Internal Error at third_party/halide/halide/src/WasmExecutor.cpp:2368 Condition failed: instance: Error initializing module: invalid import "env.ceilf" Explicitly using the intrinsics is still covered by webassembly and given the commenting out of these intrinsics mentions that they were not used due to needing to support LLVM <3.3, I think we can safely enable these now.
1 parent 52ec2d3 commit b6e889d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/runtime/posix_math.ll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,17 @@ define weak_odr half @floor_f16(half %x) nounwind uwtable readnone alwaysinline
101101
ret half %y
102102
}
103103

104-
; These are llvm 3.3 only
105-
; declare float @llvm.ceil.f32(float) nounwind readnone
106-
; declare double @llvm.ceil.f64(double) nounwind readnone
107-
declare float @ceilf(float) nounwind readnone
108-
declare double @ceil(double) nounwind readnone
104+
declare float @llvm.ceil.f32(float) nounwind readnone
105+
declare double @llvm.ceil.f64(double) nounwind readnone
109106
declare half @llvm.ceil.f16(half) nounwind readnone
110107

111108
define weak_odr float @ceil_f32(float %x) nounwind uwtable readnone alwaysinline {
112-
%y = tail call float @ceilf(float %x) nounwind readnone
109+
%y = tail call float @llvm.ceil.f32(float %x) nounwind readnone
113110
ret float %y
114111
}
115112

116113
define weak_odr double @ceil_f64(double %x) nounwind uwtable readnone alwaysinline {
117-
%y = tail call double @ceil(double %x) nounwind readnone
114+
%y = tail call double @llvm.ceil.f64(double %x) nounwind readnone
118115
ret double %y
119116
}
120117

0 commit comments

Comments
 (0)