[PATCH] D141560: [RISCV][CodeGen] Add codegen pattern for FLI instruction in experimental zfa extension

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 23:38:54 PDT 2023


craig.topper added a comment.

In D141560#4201276 <https://reviews.llvm.org/D141560#4201276>, @joshua-arch1 wrote:

> In D141560#4198257 <https://reviews.llvm.org/D141560#4198257>, @craig.topper wrote:
>
>> In D141560#4198252 <https://reviews.llvm.org/D141560#4198252>, @joshua-arch1 wrote:
>>
>>> In D141560#4198233 <https://reviews.llvm.org/D141560#4198233>, @craig.topper wrote:
>>>
>>>> In D141560#4198220 <https://reviews.llvm.org/D141560#4198220>, @joshua-arch1 wrote:
>>>>
>>>>> Anyone knows how to generate FLI from C-code? If I compile the following program, I cannot get FlI. ConstantFP will be converted to Constant in DAG.
>>>>>
>>>>>   void foo_double64 ()
>>>>>   {
>>>>>     volatile double a;
>>>>>     a = 0.0625;
>>>>>   }
>>>>
>>>> You just need to use it to do some floating point arithmetic
>>>>
>>>>   void foo_double64 (double x)
>>>>   {
>>>>     volatile double a;
>>>>     a = x + 0.0625;
>>>>   }
>>>>
>>>> or return a floating point value
>>>>
>>>>   double foo_double64 ()
>>>>   {
>>>>     return 0.0625;
>>>>   }
>>>
>>> Is that because we cannot directly store a ConstantFP in DAG?
>>
>> The change is done in DAGCombiner::replaceStoreOfFPConstant. I think the idea is that FP constants are usually harder to create in registers than integer constants. Also CPUs  usually have more integer resources than FP resources. It doesn't look like it can be disabled currently. I think all of the constants FLI handles can be done in 1 or 2 integer instructions so I'm not very concerned about this. It was more than that I might be concerned.
>
> Will one FLI instruction have less cycles and perform better than two integer instructions?

Maybe, but it will probably be microarchitecture dependent.

Delaying a store by an extra cycle doesn't seem like a big deal. Other instructions don't directly depend on a store except later loads. The compiler would often be able to see the load is to the same location as the store and forward the data without the load.

If we're storing the same value in a loop we should be hoisting the 2 integer instructions out of the loop. So they wouldn't be executed many times.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141560/new/

https://reviews.llvm.org/D141560



More information about the llvm-commits mailing list