<div dir="ltr">Hi all, <div><br></div><div>This is a bug I reported a few weeks ago. It just bit us in production code so I thought I'd raise it on the mailing list for some extra visibility: <a href="https://llvm.org/bugs/show_bug.cgi?id=24512">https://llvm.org/bugs/show_bug.cgi?id=24512</a> </div><div><br></div><div>The issue is that on x86 without avx, there's no native way to convert a vector of uint32 to a vector of float. So llvm emulates it with a sequence of floating point math and bit tricks (lowerUINT_TO_FP_vXi32 in X86ISelLowering.cpp). Unfortunately the method used is numerically unstable, so if unsafe-fp-math is on and reassociation is deemed profitable, it turns into code that just throws away the bottom bits of the input. So, for example, casting a vector of ones to float gives you a vector of zeros.</div><div><br></div><div>I know unsafe-fp-math is a license to do a lot of shady stuff, but breaking uitofp entirely doesn't seem like fair game :)</div><div><br></div><div>We have a workaround downstream (<a href="https://github.com/halide/Halide/commit/5e976ba50f68873b43e97c427c68421fddc5c01d">https://github.com/halide/Halide/commit/5e976ba50f68873b43e97c427c68421fddc5c01d</a>), so there's no urgency, but someone else is probably going to hit this too so I thought I'd re-raise the issue.</div><div><br></div><div>Thanks, </div><div><br></div><div>- Andrew</div><div><br></div></div>