{"id":16719326,"url":"https://github.com/erikd/gcc-aarch64-optimization-bug","last_synced_at":"2025-03-15T11:13:17.012Z","repository":{"id":24230214,"uuid":"27622757","full_name":"erikd/gcc-aarch64-optimization-bug","owner":"erikd","description":"Code to demonstrate a GCC Aarch64 optimization bug","archived":false,"fork":false,"pushed_at":"2014-12-06T22:18:06.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T01:43:32.770Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erikd.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-06T04:54:51.000Z","updated_at":"2014-12-06T22:18:08.000Z","dependencies_parsed_at":"2022-08-22T14:31:21.047Z","dependency_job_id":null,"html_url":"https://github.com/erikd/gcc-aarch64-optimization-bug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikd%2Fgcc-aarch64-optimization-bug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikd%2Fgcc-aarch64-optimization-bug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikd%2Fgcc-aarch64-optimization-bug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikd%2Fgcc-aarch64-optimization-bug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erikd","download_url":"https://codeload.github.com/erikd/gcc-aarch64-optimization-bug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719399,"owners_count":20336607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T21:41:25.531Z","updated_at":"2025-03-15T11:13:16.992Z","avatar_url":"https://github.com/erikd.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gcc-aarch-optimization-bug\n\nThis repo contains code (from [libsndfile][libsndfile]) to show a GCC on Aarch64\ncompiler bug that is present in gcc version 4.9.2 (Debian/Linaro 4.9.2-5). The\nbug seems to be some sort of incorrect interaction between the inliner and the\n`-fschedule-insns` compiler flag.\n\nThe repo contains:\n\n* ag_enc.c : The file displaying the problem.\n* aglib.h : A header file.\n* dyn_comp_test.c : The driver program.\n* Makefile\n\n# The Problem\n\nThe probelm is that the file `ag_enc.c` compiled with GCC 4.9.2 from Debian,\nwith optimisation flags of `-O1` returns the correct result, while if it is\ncompiled with `-O1 -fschedule-insns` it returns an incorrect result.\n\nOn a Debian Aarch64 system you can just run:\n\n    CC=gcc-4.9 make clean check\n\nwhich will compile the test program with the two different sets of compiler\nflags, one which passes one which fails.\nOn my system (a QEMU user space chroot) the result (with some lines trimmed)\nlooks like:\n\n    rm -f ag_enc.o\n    OPT_FLAGS=\"-O\" make dyn_comp_test \u0026\u0026 ./dyn_comp_test\n    make[1]: Entering directory '/home/erikd/Git/gcc-aarch64-optimization-bug'\n    gcc-4.9 -O -Isrc -std=c99 -Wcast-align -Wcast-qual -Wshadow .....\n    gcc-4.9 -O -Isrc -std=c99 -Wcast-align -Wcast-qual -Wshadow .....\n    gcc-4.9 dyn_comp_test.o ag_enc.o -lm -o dyn_comp_test\n    make[1]: Leaving directory '/home/erikd/Git/gcc-aarch64-optimization-bug'\n\n    Checksum value 0x1c1c : Correct!\n\n    rm -f ag_enc.o\n    OPT_FLAGS=\"-O -fschedule-insns\" make dyn_comp_test \u0026\u0026 ./dyn_comp_test\n    make[1]: Entering directory '/home/erikd/Git/gcc-aarch64-optimization-bug'\n    gcc-4.9 -O -fschedule-insns -Isrc -std=c99 -Wcast-align -Wcast-qual .....\n    gcc-4.9 dyn_comp_test.o ag_enc.o -lm -o dyn_comp_test\n    make[1]: Leaving directory '/home/erikd/Git/gcc-aarch64-optimization-bug'\n\n    Checksum value 0x0fb9 : Error, should be 0x1c1c!\n\n\nWith gcc-4.8 on Aarch64 or gcc of any version of any other architecture, the\nprogram will pass with both sets of compiler flags. Eg on Aarch64:\n\n    CC=gcc-4.8 make clean check\n\nI've also test this with Debian's gcc-snapshot (`gcc version 5.0.0 20141118\n(experimental) [trunk revision 217719] (Debian 20141118-1)`) and it does not\ndisplay the problem either.\n\n[libsndfile]: https://github.com/erikd/libsndfile/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikd%2Fgcc-aarch64-optimization-bug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferikd%2Fgcc-aarch64-optimization-bug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikd%2Fgcc-aarch64-optimization-bug/lists"}