Page MenuHomePhabricator

Experimental complex intrinsics.
DraftPublic

Authored by jcranmer-intel on Mon, Nov 22, 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

Unit TestsFailed

TimeTest
110 msx64 debian > LLVM.CodeGen/AArch64::O0-pipeline.ll
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc --debugify-and-strip-all-safe=0 -mtriple=arm64-- -O0 -debug-pass=Structure < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/AArch64/O0-pipeline.ll -o /dev/null 2>&1 | grep -v "Verify generated machine code" | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/AArch64/O0-pipeline.ll
150 msx64 debian > LLVM.CodeGen/AArch64::O3-pipeline.ll
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc --debugify-and-strip-all-safe=0 -mtriple=arm64-- -O3 -debug-pass=Structure < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/AArch64/O3-pipeline.ll -o /dev/null 2>&1 | grep -v "Verify generated machine code" | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/AArch64/O3-pipeline.ll
100 msx64 debian > LLVM.CodeGen/AMDGPU::llc-pipeline.ll
Script: -- : 'RUN: at line 4'; rm -f /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/AMDGPU/llc-pipeline.s
40 msx64 debian > LLVM.CodeGen/ARM::O3-pipeline.ll
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc -mtriple=arm -O3 -debug-pass=Structure < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/ARM/O3-pipeline.ll -o /dev/null 2>&1 | grep -v "Verify generated machine code" | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/ARM/O3-pipeline.ll
70 msx64 debian > LLVM.CodeGen/PowerPC::O3-pipeline.ll
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc --debugify-and-strip-all-safe=0 -mtriple=powerpc64-- -O3 -debug-pass=Structure < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/PowerPC/O3-pipeline.ll -o /dev/null 2>&1 | grep -v "Verify generated machine code" | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/PowerPC/O3-pipeline.ll
View Full Test Results (6 Failed)

Event Timeline

jcranmer-intel created this revision.Mon, Nov 22, 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..Mon, Nov 22, 2:36 PM
jcranmer-intel edited the summary of this revision. (Show Details)
jcranmer-intel added subscribers: fhahn, NickGuy.
SjoerdMeijer added inline comments.Wed, Nov 24, 2:45 AM
llvm/include/llvm/CodeGen/ExpandComplex.h
3

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?