Skip to content

update-threading.c: "Invalid sum" found #638

@luismgsilva

Description

@luismgsilva

original test case

The test case verifies that when compiled with optimization levels, the compiler optimizes the code correctly without producing any unwanted "Invalid sum" messages in the optimized tree dump.

Last year, the GCC options for this test case were updated from -fdump-tree-optimized to -fdump-tree-optimized-blocks-details in a patch.

  • -fdump-tree-optimized provides a high-level overview of the optimized code.
  • -fdump-tree-optimized-blocks-details provides a detailed view of the basic blocks within the optimized code

With this update, the test case now fails, showing two instances of "Invalid sum." The issue was already present but was not visible due to the lack of the blocks-details suffix in the previous GCC option.

Using -fdump-tree-optimized

$ module load arc-2023.09
$ arc-elf32-gcc \
        update-threading.c          \
        -mcpu=archs                 \
        -fdiagnostics-plain-output  \
        -O2                         \
        -fdump-tree-optimized       \
        -S                          \
        --specs=hl.specs            \
        -o update-threading.s
$ grep "Invalid sum" update-threading.c.254t.optimized

Using -fdump-tree-optimized-blocks-detailed

$ module load arc-2023.09
$ arc-elf32-gcc \
        update-threading.c                  \
        -mcpu=archs                         \
        -fdiagnostics-plain-output          \
        -O2                                 \
        -fdump-tree-optimized-blocks-details    \
        -S                                  \
        --specs=hl.specs                    \
        -o update-threading.s
$ grep "Invalid sum" update-threading.c.254t.optimized
;;   Invalid sum of incoming counts 708669600 (estimated locally), should be 0 (precise)
;;   Invalid sum of incoming counts 365072224 (estimated locally), should be 1073741824 (estimated locally)

The two "Invalid sum of incoming counts" messages reveal discrepancies in the compiler's block count estimations during the optimization process.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions