Commit r334318 exposed a problem in SolveQuadraticEquation: an add-rec was created with coefficients in i1, and division by 2 became equivalent to division by zero. See http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180611/561033.html.
This also fixes https://bugs.llvm.org/show_bug.cgi?id=38024.
Would be nice to clarify the bitwidth in which you evaluate q(n) for (b). It can't be BW since any value in [0,2^BW) will either lies in exactly one such interval or all such intervals, depending on how you slice it.