File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 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) {
15421542 return true ;
15431543 };
15441544
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+
15451556 switch (E->getOpcode ()) {
15461557 case BO_EQ:
1547- return this ->emitEQFixedPoint (E);
1558+ return MaybeCastToBool ( this ->emitEQFixedPoint (E) );
15481559 case BO_NE:
1549- return this ->emitNEFixedPoint (E);
1560+ return MaybeCastToBool ( this ->emitNEFixedPoint (E) );
15501561 case BO_LT:
1551- return this ->emitLTFixedPoint (E);
1562+ return MaybeCastToBool ( this ->emitLTFixedPoint (E) );
15521563 case BO_LE:
1553- return this ->emitLEFixedPoint (E);
1564+ return MaybeCastToBool ( this ->emitLEFixedPoint (E) );
15541565 case BO_GT:
1555- return this ->emitGTFixedPoint (E);
1566+ return MaybeCastToBool ( this ->emitGTFixedPoint (E) );
15561567 case BO_GE:
1557- return this ->emitGEFixedPoint (E);
1568+ return MaybeCastToBool ( this ->emitGEFixedPoint (E) );
15581569 case BO_Add:
15591570 return ConvertResult (this ->emitAddFixedPoint (E));
15601571 case BO_Sub:
Original file line number Diff line number Diff line change 11// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNPADDED
22// 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
33
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+
47// Fixed point against other fixed point
58_Bool b_eq_true = 2.5 hk == 2.5u hk ; // CHECK-DAG: @b_eq_true = {{.*}}global i8 1, align 1
69_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