mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
remove unnecessary call to math.floor
in bitcode
This commit is contained in:
parent
d202b77ae1
commit
f738d5a2bf
2 changed files with 4 additions and 1 deletions
|
@ -215,7 +215,9 @@ pub fn exportRound(comptime F: type, comptime T: type, comptime name: []const u8
|
|||
pub fn exportFloor(comptime F: type, comptime T: type, comptime name: []const u8) void {
|
||||
comptime var f = struct {
|
||||
fn func(input: F) callconv(.C) T {
|
||||
return @as(T, @intFromFloat((math.floor(input))));
|
||||
// intFromFloat just returns the integer part of the float.
|
||||
// This means it automatically floors. No need for an explicit call to floor.
|
||||
return @as(T, @intFromFloat(input));
|
||||
}
|
||||
}.func;
|
||||
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
|
||||
|
|
|
@ -1813,6 +1813,7 @@ fn ceiling() {
|
|||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn floor() {
|
||||
assert_evals_to!("Num.floor 1.9f64", 1, i64);
|
||||
assert_evals_to!("Num.floor -1.9f64", -1, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue