SDK 8.2.1: Move constant folding of has checks with API functions to the -p optimization level

This line in the changelog of SDK 8.2.1 is confusing me:

  • Move constant folding of has checks with API functions to the -p optimization level.

For one, "-p" is a parameter of the compiler, but it's the project info, so I guess what they mean is the "p" optimization "mode"

However even then I found it strange that the constant folding is included in the performance optimizations and not the code space optimizations. Or maybe I misunderstand what constant folding means? Ok, probably it's one of the strange optimizations that actually improve both the performance and the code size.

However I am a bit baffled by this change. In all of my apps (especially datafields) I use optimization level 3z. So if I understand what this change means that it won't do constant folding now? Will I have to check all my apps and compare them with 3z vs 3p ?

  • That's fine, but I do have 3z

    I understand that, but I was specifically addressing the following statement:

    Except that they removed an existing feature from more than half of the apps: apps that use z or don't use optimization.

    They did not remove this feature from apps that don't use optimization, assuming the feature never worked unless optimization was enabled.

    The larger point is that at least a few devs don't think it's a good feature and this change will help devs who are unaware of the feature in the first place.

  • I went through compiling with just "3", "3p", and "3z" for both an FR235 and Fenix 7X, and saved the resulting "bin" directory from each:

    bin-F7X-3/
    bin-F7X-3p/
    bin-F7X-3z/
    bin-FR235-3/
    bin-FR235-3p/
    bin-FR235-3z/

    When I do a "diff -r" comparing the FR235 directories against each other there are zero differences. All files are identical. Same for the F7X directories. I have various "has" sprinkled throughout, which I can't show thanks to the forum code block "blocked code" feature.

    If there is folding I think I would see at least one difference. What is it that I should expect to see?

  • It looks like all the optimizations only effect newer devices, because they are based on a new firmware that knows newly added opcodes.

  • I turned logging on and I found this in the "config.txt" file:

    Optimization Level = [OPTIMIZATION_EMPTY_FUNCTION_REMOVAL,

    OPTIMIZATION_API_ANNOTATIONS,

    OPTIMIZATION_STATIC_BRANCH_ELIMINATION,

    OPTIMIZATION_STATIC_MODULE_ELIMINATION,

    OPTIMIZATION_CONSTANT_FOLDING,

    OPTIMIZATION_LEXICAL_ONLY_CONSTANTS]

    I'd have to experiment to see if this is device dependent, or generic to optimization level 3.