This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Add support for fast math mode
ClosedPublic

Authored by antiagainst on Sep 9 2022, 11:44 AM.

Details

Summary

This commit introduces a new option to SPIRVConversionOptions
to allow enabling fast math mode. With it, various patterns
would assume no NaN/infinity for floating point values and
avoid guards to check them. This is particularly useful for
CodeGen towards WebGPU environment, where fast math is assumed.

Along the way, fixed the conversion for arith.minf/maxf to
handle the NaN cases properly for Shader cases.

Part of https://github.com/llvm/llvm-project/issues/57584.

Diff Detail

Event Timeline

antiagainst created this revision.Sep 9 2022, 11:44 AM
antiagainst requested review of this revision.Sep 9 2022, 11:44 AM
ThomasRaoux accepted this revision.Sep 9 2022, 11:58 AM
ThomasRaoux added inline comments.
mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp
934

nit: that's not really a cmp? Is there a better name?

This revision is now accepted and ready to land.Sep 9 2022, 11:58 AM
hanchung accepted this revision.Sep 9 2022, 12:05 PM
antiagainst marked an inline comment as done.

Address comments

mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp
934

Good point. Changed.

This revision was landed with ongoing or failed builds.Sep 9 2022, 1:27 PM
This revision was automatically updated to reflect the committed changes.