Forum > FPC development

FPC-LLVM installer ?

<< < (6/7) > >>

Fred vS:

--- Quote from: Jonas Maebe on November 02, 2022, 08:29:33 pm ----O4 enables fast math. Without fast math, FPC uses special LLVM intrinsics for floating point math that respect floating point exceptions. These prevent constant propagation and generally cannot be optimised well by LLVM. With fast math, FPC uses the regular LLVM floating point operations and then LLVM can perform constant propagation. It probably calculates most of the loop's contents at compile-time in that case.

--- End quote ---

OK but what about the huge difference if using the same procedure but with var parameter vs const parameter with fpc-llvm (see code) ?

Jonas Maebe:

--- Quote from: Fred vS on November 02, 2022, 08:33:43 pm ---
--- Quote from: Jonas Maebe on November 02, 2022, 08:29:33 pm ----O4 enables fast math. Without fast math, FPC uses special LLVM intrinsics for floating point math that respect floating point exceptions. These prevent constant propagation and generally cannot be optimised well by LLVM. With fast math, FPC uses the regular LLVM floating point operations and then LLVM can perform constant propagation. It probably calculates most of the loop's contents at compile-time in that case.

--- End quote ---

OK but what about the huge difference if using the same procedure but with var parameter vs const parameter with fpc-llvm (see code) ?

--- End quote ---
Maybe it cannot prove that none of the dynamic array parameters change during the loop when you use var. Memory alias analysis is very hard.

Fred vS:

--- Quote from: Jonas Maebe on November 02, 2022, 08:41:51 pm ---
--- Quote from: Fred vS on November 02, 2022, 08:33:43 pm ---
--- Quote from: Jonas Maebe on November 02, 2022, 08:29:33 pm ----O4 enables fast math. Without fast math, FPC uses special LLVM intrinsics for floating point math that respect floating point exceptions. These prevent constant propagation and generally cannot be optimised well by LLVM. With fast math, FPC uses the regular LLVM floating point operations and then LLVM can perform constant propagation. It probably calculates most of the loop's contents at compile-time in that case.

--- End quote ---

OK but what about the huge difference if using the same procedure but with var parameter vs const parameter with fpc-llvm (see code) ?

--- End quote ---
Maybe it cannot prove that none of the dynamic array parameters change during the loop when you use var. Memory alias analysis is very hard.

--- End quote ---

Yes, maybe ( but what is sure is that it encourages me to use "const" vs "var" or even simpler no "const" or "var" at all ( like in code procedure CalculArrays4(arr0,arr1,arr2,arr3:aos) because if the result is real, 10 x faster is WoW )

But surely I miss something, so forgive me.  :-[

Jonas Maebe:

--- Quote from: Fred vS on November 02, 2022, 08:50:31 pm ---
--- Quote from: Jonas Maebe on November 02, 2022, 08:41:51 pm ---
--- Quote from: Fred vS on November 02, 2022, 08:33:43 pm ---
--- Quote from: Jonas Maebe on November 02, 2022, 08:29:33 pm ----O4 enables fast math. Without fast math, FPC uses special LLVM intrinsics for floating point math that respect floating point exceptions. These prevent constant propagation and generally cannot be optimised well by LLVM. With fast math, FPC uses the regular LLVM floating point operations and then LLVM can perform constant propagation. It probably calculates most of the loop's contents at compile-time in that case.

--- End quote ---

OK but what about the huge difference if using the same procedure but with var parameter vs const parameter with fpc-llvm (see code) ?

--- End quote ---
Maybe it cannot prove that none of the dynamic array parameters change during the loop when you use var. Memory alias analysis is very hard.

--- End quote ---

Yes, maybe ( but what is sure is that it encourages me to use "const" vs "var" or even simpler no "const" or "var" at all ( like in code procedure CalculArrays4(arr0,arr1,arr2,arr3:aos) because if the result is real, 10 faster is WoW )

--- End quote ---
In a real-world program the differences won't be that big. It's only in artificial programs where the output can be completely calculated at compile time from the input, or where the compiler can prove that the calculated values are not even used.

Fred vS:

--- Quote from: Jonas Maebe on November 02, 2022, 08:51:57 pm ---
--- Quote from: Fred vS on November 02, 2022, 08:50:31 pm ---
--- Quote from: Jonas Maebe on November 02, 2022, 08:41:51 pm ---
--- Quote from: Fred vS on November 02, 2022, 08:33:43 pm ---
--- Quote from: Jonas Maebe on November 02, 2022, 08:29:33 pm ----O4 enables fast math. Without fast math, FPC uses special LLVM intrinsics for floating point math that respect floating point exceptions. These prevent constant propagation and generally cannot be optimised well by LLVM. With fast math, FPC uses the regular LLVM floating point operations and then LLVM can perform constant propagation. It probably calculates most of the loop's contents at compile-time in that case.

--- End quote ---

OK but what about the huge difference if using the same procedure but with var parameter vs const parameter with fpc-llvm (see code) ?

--- End quote ---
Maybe it cannot prove that none of the dynamic array parameters change during the loop when you use var. Memory alias analysis is very hard.

--- End quote ---

Yes, maybe ( but what is sure is that it encourages me to use "const" vs "var" or even simpler no "const" or "var" at all ( like in code procedure CalculArrays4(arr0,arr1,arr2,arr3:aos) because if the result is real, 10 faster is WoW )

--- End quote ---
In a real-world program the differences won't be that big. It's only in artificial programs where the output can be completely calculated at compile time from the input, or where the compiler can prove that the calculated values are not even used.

--- End quote ---

What is sure is that in the real world fpc-llvm works very well (even gives vertigo on some test).
Well done Jonas.  ;)

Fre;D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version