-
Notifications
You must be signed in to change notification settings - Fork 105
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_isinf_sign
- Loading branch information
1 parent
eacaabb
commit 650c796
Showing
3 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll | ||
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
|
||
int test_float_isinf_sign(float x) { | ||
// CIR-LABEL: test_float_isinf_sign | ||
// CIR: %[[TMP0:.*]] = cir.load %{{.*}} : !cir.ptr<!cir.float>, !cir.float | ||
// CIR: %[[TMP1:.*]] = cir.fabs %[[TMP0]] : !cir.float | ||
// CIR: %[[IS_INF:.*]] = cir.is_fp_class %[[TMP1]], 516 : (!cir.float) -> !cir.bool | ||
// CIR: %[[IS_NEG:.*]] = cir.signbit %[[TMP0]] : !cir.float -> !cir.bool | ||
// CIR: %[[C_0:.*]] = cir.const #cir.int<0> : !s32i | ||
// CIR: %[[C_1:.*]] = cir.const #cir.int<1> : !s32i | ||
// CIR: %[[C_m1:.*]] = cir.const #cir.int<-1> : !s32i | ||
// CIR: %[[TMP4:.*]] = cir.select if %[[IS_NEG]] then %[[C_m1]] else %[[C_1]] : (!cir.bool, !s32i, !s32i) -> !s32i | ||
// CIR: %[[RET:.*]] = cir.select if %[[IS_INF]] then %[[TMP4]] else %[[C_0]] : (!cir.bool, !s32i, !s32i) -> !s32i | ||
// CIR: cir.store %[[RET]], %{{.*}} : !s32i, !cir.ptr<!s32i> | ||
|
||
// LLVM-LABEL: test_float_isinf_sign | ||
// LLVM: %[[TMP0:.*]] = load float, ptr %{{.*}} | ||
// LLVM: %[[TMP1:.*]] = call float @llvm.fabs.f32(float %[[TMP0]]) | ||
// LLVM: %[[IS_INF:.*]] = call i1 @llvm.is.fpclass.f32(float %[[TMP1]], i32 516) | ||
// LLVM: %[[IS_INF_I8:.*]] = zext i1 %[[IS_INF]] to i8 | ||
// LLVM: %[[TMP1:.*]] = bitcast float %[[TMP0]] to i32 | ||
// LLVM: %[[IS_NEG:.*]] = icmp slt i32 %[[TMP1]], 0 | ||
// LLVM: %[[IS_NEG_I8:.*]] = zext i1 %[[IS_NEG]] to i8 | ||
// LLVM: %[[IS_NEG_I1:.*]] = trunc i8 %[[IS_NEG_I8]] to i1 | ||
// LLVM: %[[TMP2:.*]] = select i1 %[[IS_NEG_I1]], i32 -1, i32 1 | ||
// LLVM: %[[IS_INF_I1:.*]] = trunc i8 %[[IS_INF_I8]] to i1 | ||
// LLVM: %[[RET:.*]] = select i1 %[[IS_INF_I1]], i32 %[[TMP2]], i32 0 | ||
// LLVM: store i32 %[[RET]], ptr %{{.*}}, align 4 | ||
return __builtin_isinf_sign(x); | ||
} |