Skip to content

Commit 8f257ca

Browse files
committed
[CIR][CIRGen]: Change SignBitOp result type to !cir.bool
1 parent 888f00c commit 8f257ca

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
414414
}
415415

416416
cir::SignBitOp createSignBit(mlir::Location loc, mlir::Value val) {
417-
auto resTy = cir::IntType::get(getContext(), 32, true);
417+
auto resTy = cir::BoolType::get(getContext());
418418
return create<cir::SignBitOp>(loc, resTy, val);
419419
}
420420

clang/include/clang/CIR/Dialect/IR/CIROps.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -5278,7 +5278,7 @@ def SignBitOp : CIR_Op<"signbit", [Pure]> {
52785278
and zero (false) if the number is positive or zero.
52795279
}];
52805280
let arguments = (ins CIR_AnyFloat:$input);
5281-
let results = (outs SInt32:$res);
5281+
let results = (outs CIR_BoolType:$res);
52825282
let assemblyFormat = [{
52835283
$input attr-dict `:` type($input) `->` qualified(type($res))
52845284
}];

clang/test/CIR/CodeGen/builtin-signbit.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55

66
void test_signbit_float(float val) {
77
// CIR-LABEL: test_signbit_float
8-
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.float -> !s32i
8+
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.float -> !cir.bool
99
// LLVM-LABEL: test_signbit_float
1010
// LLVM: [[TMP1:%.*]] = bitcast float %{{.+}} to i32
1111
// LLVM: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
1212
// LLVM: %{{.+}} = zext i1 [[TMP2]] to i32
13-
__builtin_signbit(val);
13+
if (__builtin_signbit(val)) {};
1414
}
1515

1616
void test_signbit_double(double val) {
1717
// CIR-LABEL: test_signbit_double
18-
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.float -> !s32i
18+
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.float -> !cir.bool
1919
// LLVM-LABEL: test_signbit_double
2020
// LLVM: [[CONV:%.*]] = fptrunc double %{{.+}} to float
2121
// LLVM: [[TMP1:%.*]] = bitcast float [[CONV]] to i32
2222
// LLVM: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
2323
// LLVM: %{{.+}} = zext i1 [[TMP2]] to i32
24-
__builtin_signbitf(val);
24+
if (__builtin_signbitf(val)) {}
2525
}
2626

2727
void test_signbit_long_double(long double val) {
2828
// CIR: test_signbit_long_double
2929
// LLVM: test_signbit_long_double
30-
__builtin_signbitl(val);
31-
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.long_double<!cir.f80> -> !s32i
30+
if (__builtin_signbitl(val)) {}
31+
// CIR: %{{.+}} = cir.signbit %{{.+}} : !cir.long_double<!cir.f80> -> !cir.bool
3232
// LLVM: [[TMP1:%.*]] = bitcast x86_fp80 %{{.+}} to i80
3333
// LLVM: [[TMP2:%.*]] = icmp slt i80 [[TMP1]], 0
3434
// LLVM: %{{.+}} = zext i1 [[TMP2]] to i32

0 commit comments

Comments
 (0)