HomePhabricator

[mlir][StandardToSPIRV] Fix signedness issue in bitwidth emulation.

Authored by hanchung on May 19 2020, 10:55 AM.

Description

[mlir][StandardToSPIRV] Fix signedness issue in bitwidth emulation.

Summary:
Previously, after applying the mask, a negative number would convert to a
positive number because the sign flag was forgotten. This patch adds two more
shift operations to do the sign extension. This assumes that we're using two's
complement.

This patch applies sign extension unconditionally when loading a unspported integer width, and it relies the pattern to do the casting because the signedness semantic is carried by operator itself.

Differential Revision: https://reviews.llvm.org/D79753

Details