Page MenuHomePhabricator

[ConstantFolding] Add constant folding for smul.fix and smul.fix.sat

Authored by bjope on Jun 16 2019, 8:23 AM.



This patch teaches ConstantFolding to constant fold
both scalar and vector variants of llvm.smul.fix and

As described in the LangRef rounding is unspecified for
these instrinsics. If the result cannot be represented
exactly the default behavior in ConstantFolding is to
round down towards negative infinity. If a target has a
preferred rounding that is different some kind of target
hook would be needed (same strategy as used by the
SelectionDAG legalizer).

Diff Detail


Event Timeline

bjope created this revision.Jun 16 2019, 8:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2019, 8:23 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
leonardchan accepted this revision.Jun 18 2019, 2:55 PM
This revision is now accepted and ready to land.Jun 18 2019, 2:55 PM
This revision was automatically updated to reflect the committed changes.
nikic added inline comments.Jun 19 2019, 9:43 AM

As a possible follow-up cleanup, this can be merged into the fshl/fshr code below. The smul_fix case could bail out if C0, C1 or C2 are null (or handle them, if there is interest to support undef operands).