[mlir][spirv] Fix math.ctlz for full zero bit cases
authorLei Zhang <antiagainst@google.com>
Tue, 14 Jun 2022 23:39:20 +0000 (19:39 -0400)
committerLei Zhang <antiagainst@google.com>
Tue, 14 Jun 2022 23:39:27 +0000 (19:39 -0400)
commitb4dff404f37afa1fcad4a96c05462928eb0b89b1
tree65a59e8e9a64efb5ceb64a345d768b01b08cb5de
parentfacb96584eebd87eaedc99b3e44dac86ae1bab29
[mlir][spirv] Fix math.ctlz for full zero bit cases

If the integer has all zero bits, GLSL FindUMsb would return -1.
So theoretically (31 - FindUMsb) should still give use the correct
result.  However, Adreno GPUshave issues with this:
https://buildkite.com/iree/iree-test-android/builds/6482#01815f05-3926-466f-822a-1e20299e5461
This looks like a driver bug. So handle the corner case explicity
to workaround it.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D127747
mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
mlir/test/Conversion/MathToSPIRV/math-to-glsl-spirv.mlir