File tree 2 files changed +20
-6
lines changed 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -1542,19 +1542,30 @@ bool Compiler<Emitter>::VisitFixedPointBinOp(const BinaryOperator *E) {
1542
1542
return true ;
1543
1543
};
1544
1544
1545
+ auto MaybeCastToBool = [&](bool Result) {
1546
+ if (!Result)
1547
+ return false ;
1548
+ PrimType T = classifyPrim (E);
1549
+ if (DiscardResult)
1550
+ return this ->emitPop (T, E);
1551
+ if (T != PT_Bool)
1552
+ return this ->emitCast (PT_Bool, T, E);
1553
+ return true ;
1554
+ };
1555
+
1545
1556
switch (E->getOpcode ()) {
1546
1557
case BO_EQ:
1547
- return this ->emitEQFixedPoint (E);
1558
+ return MaybeCastToBool ( this ->emitEQFixedPoint (E) );
1548
1559
case BO_NE:
1549
- return this ->emitNEFixedPoint (E);
1560
+ return MaybeCastToBool ( this ->emitNEFixedPoint (E) );
1550
1561
case BO_LT:
1551
- return this ->emitLTFixedPoint (E);
1562
+ return MaybeCastToBool ( this ->emitLTFixedPoint (E) );
1552
1563
case BO_LE:
1553
- return this ->emitLEFixedPoint (E);
1564
+ return MaybeCastToBool ( this ->emitLEFixedPoint (E) );
1554
1565
case BO_GT:
1555
- return this ->emitGTFixedPoint (E);
1566
+ return MaybeCastToBool ( this ->emitGTFixedPoint (E) );
1556
1567
case BO_GE:
1557
- return this ->emitGEFixedPoint (E);
1568
+ return MaybeCastToBool ( this ->emitGEFixedPoint (E) );
1558
1569
case BO_Add:
1559
1570
return ConvertResult (this ->emitAddFixedPoint (E));
1560
1571
case BO_Sub:
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNPADDED
2
2
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,PADDED
3
3
4
+ // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,UNPADDED
5
+ // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,PADDED
6
+
4
7
// Fixed point against other fixed point
5
8
_Bool b_eq_true = 2.5 hk == 2.5u hk ; // CHECK-DAG: @b_eq_true = {{.*}}global i8 1, align 1
6
9
_Bool b_eq_false = 2.5 hk == 2.4u hk ; // CHECK-DAG: @b_eq_false = {{.*}}global i8 0, align 1
You can’t perform that action at this time.
0 commit comments