In commutative instructions, always put the lower-numbered operand first.
This shaves off 1 byte of entropy from all these instructions, reducing
compressed size of the output file.
+.It Fl f Ns Cm arithmetic-exceptions
+Turn on arithmetic exception tests in the compiler. In constant expressions
+which trigger exceptions like division by zero, overflow, underflow, etc,
+the following flag will produce diagnostics for what triggered that
+exception.
.El
.Sh OPTIMIZATIONS
.Bl -tag -width Ds
sfloat_cast_t ca;
sfloat_cast_t cb;
+ if (!OPTS_FLAG(ARITHMETIC_EXCEPTIONS))
+ return false;
+
s.roundingmode = SFLOAT_ROUND_NEAREST_EVEN;
s.tiny = SFLOAT_TBEFORE;
s.exceptionflags = 0;
SORT_OPERANDS = false
+ #Turn on arithmetic exception tests in the compiler. In constant expressions
+ #which trigger exceptions like division by zero, overflow, underflow, etc,
+ #the following flag will produce diagnostics for what triggered that
+ #exception.
+ ARITHMETIC_EXCEPTIONS = false
[warnings]
#Generate a warning about variables which are declared but never
GMQCC_DEFINE_FLAG(UNSAFE_VARARGS)
GMQCC_DEFINE_FLAG(TYPELESS_STORES)
GMQCC_DEFINE_FLAG(SORT_OPERANDS)
+ GMQCC_DEFINE_FLAG(ARITHMETIC_EXCEPTIONS)
#endif
/* warning flags */
--- /dev/null
+const float huge = 340282346638528859811704183484516925440; // FLT_MAX
+
+#ifdef DIVBYZERO
+const float a = 1.0 / 0.0;
+#endif
+
+#ifdef OVERFLOW
+const float a = huge * huge;
+#endif
+
+#ifdef UNDERFLOW
+const float a = 1 / huge;
+#endif
--- /dev/null
+I: arithexcept.qc
+D: arithmetic exceptions (divide by zero)
+T: -fail
+C: -std=fteqcc -farithmetic-exceptions -DDIVBYZERO
--- /dev/null
+I: arithexcept.qc
+D: arithmetic exceptions (overflow)
+T: -fail
+C: -std=ftqcc -farithmetic-exceptions -DOVERFLOW
--- /dev/null
+I: arithexcept.qc
+D: arithmetic exceptions (underflow)
+T: -fail
+C: -std=ftqcc -farithmetic-exceptions -DUNDERFLOW
--- /dev/null
+void main() {
+ const float a = 1.0 / 3.0;
+ const float b = 0.3333333333333;
+
+ if (a == b) {
+ // Should trigger warning
+ }
+}
--- /dev/null
+I: inexact.qc
+D: inexact comparisons
+T: -fail
+C: -std=gmqcc -Winexact-compares -Wall -Werror