[mlir][Conversion/GPUCommon] Fix bug in conversion of `math` ops
authorChristopher Bate <cbate@nvidia.com>
Fri, 30 Jun 2023 22:04:08 +0000 (16:04 -0600)
committerChristopher Bate <cbate@nvidia.com>
Mon, 3 Jul 2023 19:26:51 +0000 (13:26 -0600)
commit14858cf05dc7cbc0f34629d693b0039c3d15c34f
tree3bbac9292454b7a4a842f45267b1f4a38ccfff3b
parent6a66673765b2bf45f412ab4261a72704805dd526
[mlir][Conversion/GPUCommon] Fix bug in conversion of `math` ops

The common GPU operation transformation that lowers `math` operations
to function calls in the `gpu-to-nvvm` and `gpu-to-rocdl` passes handles
`vector` types by applying the function to each scalar and returning a
new vector. However, there was a typo that results in incorrectly
accumulating the result vector, and the rewrite returns an `llvm.mlir.undef`
result instead of the correct vector. A patch is added and tests are
strengthened.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D154269
mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir