This is an archive of the discontinued LLVM Phabricator instance.

Experimental complex intrinsics.
DraftPublic

Authored by jcranmer-intel on Nov 22 2021, 2:17 PM.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
None
Summary

(Apologies for email spam, I'm still trying to work out how to arcanist to upload a branch as a series of patches instead of one patch. In lieu of that, here's all the patches smushed together for now:)

[InstCombine] Pattern match expressions for naive complex multiply/divide.

These patterns are currently hidden via a command-line flag, since the complex
intrinsics are still experimental.

[Clang][CodeGen] Lower C _Complex multiplies and divides to intrinsics.

[CodeGen] Expand complex multiply and divide intrinsics for codegen.

For architectures without complex multiply or divide intrinsics (most of them),
a pass is needed to expand these intrinsics before codegen.

The tricky thing here is that where the intrinsics need to expand into a
compiler-rt helper function (e.g., __mulsc3), the ABI of complex floating point
types needs to be retrieved from the target. However, this target information
isn't fully validated for all targets, only x86 (where the i386 _Complex float
ABI is unsupported in this patch, due to its insanity).

[IRBuilder] Add methods to construct complex intrinsics to IRBuilder.

[IR] Add intrinsics to represent complex multiply and divide instructions.

This patch represents the first in a series of patches to bring a more
standardized version of complex values into LLVM. Representation of the complex
multiply and division instructions are added as intrinsics, and their precise
behavior is controlled via attributes and fast-math flags.

Diff Detail

Event Timeline

jcranmer-intel created this revision.Nov 22 2021, 2:17 PM

<still trying to figure out arcanist, apologies>

  • [InstCombine] Pattern match expressions for naive complex multiply/divide.
jcranmer-intel retitled this revision from [InstCombine] Pattern match expressions for naive complex multiply/divide. to Experimental complex intrinsics..Nov 22 2021, 2:36 PM
jcranmer-intel edited the summary of this revision. (Show Details)
jcranmer-intel added subscribers: fhahn, NickGuy.
SjoerdMeijer added inline comments.Nov 24 2021, 2:45 AM
llvm/include/llvm/CodeGen/ExpandComplex.h
4

We probably want the LLVM license here and also in the .cpp file :)

Can you explain more why the concept of complex number is the correct representation for the compiler? I get that they are taught in school - that everyone can understand what they are. But why should be compiler be optimizing around those concepts as opposed to the actual instructions that the target contains?

Matt added a subscriber: Matt.Jan 12 2022, 1:04 PM