David Greene via llvm-dev
2020-Nov-13 14:49 UTC
[llvm-dev] Complex proposal v3 + roundtable agenda
Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> writes:> Some architectures have instructions that assist with complex > arithmetic. Without intrinsics it may be hard to use such > instructions especially because of the arithmetic simplifications. > Perhaps, depending on TTI, those intrinsics could be expanded into the > explicit arithmetic?Can you provide some examples of what you mean? -David
Krzysztof Parzyszek via llvm-dev
2020-Nov-13 15:11 UTC
[llvm-dev] Complex proposal v3 + roundtable agenda
Examples of complex instructions? Hexagon has a cmpy instruction for complex multiplication, although it works on int16-based values. There is a whole set of these instructions (with various saturation/rounding behaviors), but each one of them can multiply two complex numbers (where a complex number is represented as two 16-bit values in a 32-bit register). That's a fairly complex pattern to match, and it could be quite easily disturbed by various arithmetic simplifications. What I meant with the second part was that if we start with intrinsics, then on targets that don't support complex arithmetic, those intrinsics could be expanded into the explicit real-number-based arithmetic in instcombine. This could be communicated via a function in TargetTransformInfo. Instcombine already allows targets to handle their own intrinsics in it, so maybe this would still fall under that category. This could improve performance in the short term, while the knowledge of the intrinsics is gradually added to the rest of the code. -- Krzysztof Parzyszek kparzysz at quicinc.com AI tools development -----Original Message----- From: David Greene <greened at obbligato.org> Sent: Friday, November 13, 2020 8:49 AM To: Krzysztof Parzyszek <kparzysz at quicinc.com>; llvm-dev <llvm-dev at lists.llvm.org> Subject: [EXT] Re: [llvm-dev] Complex proposal v3 + roundtable agenda Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> writes:> Some architectures have instructions that assist with complex > arithmetic. Without intrinsics it may be hard to use such > instructions especially because of the arithmetic simplifications. > Perhaps, depending on TTI, those intrinsics could be expanded into the > explicit arithmetic?Can you provide some examples of what you mean? -David
Florian Hahn via llvm-dev
2020-Nov-13 20:07 UTC
[llvm-dev] Complex proposal v3 + roundtable agenda
> On Nov 13, 2020, at 15:11, Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Examples of complex instructions? Hexagon has a cmpy instruction for complex multiplication, although it works on int16-based values. There is a whole set of these instructions (with various saturation/rounding behaviors), but each one of them can multiply two complex numbers (where a complex number is represented as two 16-bit values in a 32-bit register). That's a fairly complex pattern to match, and it could be quite easily disturbed by various arithmetic simplifications. > > What I meant with the second part was that if we start with intrinsics, then on targets that don't support complex arithmetic, those intrinsics could be expanded into the explicit real-number-based arithmetic in instcombine. This could be communicated via a function in TargetTransformInfo. Instcombine already allows targets to handle their own intrinsics in it, so maybe this would still fall under that category. This could improve performance in the short term, while the knowledge of the intrinsics is gradually added to the rest of the code.That’s a good point! I think one challenge will be that the hardware instructions might be quite different from target to target. I was thinking that we could just introduce/use those intrinsics on targets where the can be lowered efficiently. Once we have support in the vectorizers, it might be beneficial to use the intrinsics even for targets that do not natively support them. I think for that cases, adding a pass that lowers them to regular IR instructions for targets that do not have dedicated instructions would be a great idea. I think we did something similar for the experimental reduction intrinsics. Cheers, Florian
David Greene via llvm-dev
2020-Nov-18 21:12 UTC
[llvm-dev] Complex proposal v3 + roundtable agenda
Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> writes:> Examples of complex instructions?Sorry, I was referring specifically to this statement:>> Without intrinsics it may be hard to use such instructions especially >> because of the arithmetic simplifications.I was asking the question in the context of intrinsics vs. a first-class complex type. Matching things like hardware support for complex multiply is doable with either mechanism. Your statement made it sound like intrinsics were needed to *avoid* simplifcations in order to match them to hardware instructions and that a first-class complex type (using "normal" LLVM arithmetic instructions) would not be matchable to some hardware instructions. I was curious about what those cases would be. -David