-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRGen] support builtin signbit
- Loading branch information
1 parent
fca6e2c
commit 858bd29
Showing
6 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-cir %s -o - | FileCheck %s -check-prefix=CIR | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM | ||
|
||
void test_signbit_float(float val) { | ||
// CIR: test_signbit_float | ||
// LLVM: test_signbit_float | ||
__builtin_signbit(val); | ||
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.float -> !s32i | ||
// LLVM: [[TMP1:%.*]] = bitcast float %{{.+}} to i32 | ||
// LLVM: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0 | ||
// LLVM: %{{.+}} = zext i1 [[TMP2]] to i32 | ||
} | ||
|
||
void test_signbit_double(double val) { | ||
// CIR: test_signbit_double | ||
// LLVM: test_signbit_double | ||
__builtin_signbitf(val); | ||
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.float -> !s32i | ||
// LLVM: [[CONV:%.*]] = fptrunc double %{{.+}} to float | ||
// LLVM: [[TMP1:%.*]] = bitcast float [[CONV]] to i32 | ||
// LLVM: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0 | ||
// LLVM: %{{.+}} = zext i1 [[TMP2]] to i32 | ||
} | ||
void test_signbit_long_double(long double val) { | ||
// CIR: test_signbit_long_double | ||
// LLVM: test_signbit_long_double | ||
__builtin_signbitl(val); | ||
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.long_double<!cir.f80> -> !s32i | ||
// LLVM: [[TMP1:%.*]] = bitcast x86_fp80 %{{.+}} to i80 | ||
// LLVM: [[TMP2:%.*]] = icmp slt i80 [[TMP1]], 0 | ||
// LLVM: %{{.+}} = zext i1 [[TMP2]] to i32 | ||
} |