{"action":"created","issue":{"url":"https://api.github.com/repos/weidai11/cryptopp/issues/176","repository_url":"https://api.github.com/repos/weidai11/cryptopp","labels_url":"https://api.github.com/repos/weidai11/cryptopp/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/weidai11/cryptopp/issues/176/comments","events_url":"https://api.github.com/repos/weidai11/cryptopp/issues/176/events","html_url":"https://github.com/weidai11/cryptopp/issues/176","id":158524331,"number":176,"title":"cryptest.exe reports wrong CPU features for Core2 duo","user":{"login":"noloader","id":3538226,"avatar_url":"https://avatars.githubusercontent.com/u/3538226?v=3","gravatar_id":"","url":"https://api.github.com/users/noloader","html_url":"https://github.com/noloader","followers_url":"https://api.github.com/users/noloader/followers","following_url":"https://api.github.com/users/noloader/following{/other_user}","gists_url":"https://api.github.com/users/noloader/gists{/gist_id}","starred_url":"https://api.github.com/users/noloader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noloader/subscriptions","organizations_url":"https://api.github.com/users/noloader/orgs","repos_url":"https://api.github.com/users/noloader/repos","events_url":"https://api.github.com/users/noloader/events{/privacy}","received_events_url":"https://api.github.com/users/noloader/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/weidai11/cryptopp/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/weidai11/cryptopp/labels/gcc-4","name":"gcc-4","color":"207de5"},{"url":"https://api.github.com/repos/weidai11/cryptopp/labels/linux","name":"linux","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-04T21:12:11Z","updated_at":"2016-06-05T21:41:17Z","closed_at":null,"body":"cryptest.exe reports the following for an older Core2 duo processor \r\n\r\n```\r\nhasMMX == 1, hasISSE == 1, hasSSE2 == 1, hasSSSE3 == 0, hasSSE4 == 1, hasAESNI == 0,\r\nhasRDRAND == 0, hasRDSEED == 0, hasCLMUL == 0, isP4 == 0, hasPadlockRNG == 0,\r\ncacheLineSize == 64, AESNI_INTRINSICS == 1\r\n```\r\nThe machine has SSE2, SSE3, SSSE3, and SSE4.1 (but not 4.2):\r\n\r\n```\r\n$ g++ -march=native -dM -E - </dev/null | grep SSE\r\n#define __SSE4_1__ 1\r\n#define __SSE2_MATH__ 1\r\n#define __SSE_MATH__ 1\r\n#define __SSE2__ 1\r\n#define __SSSE3__ 1\r\n#define __SSE__ 1\r\n#define __SSE3__ 1\r\n```\r\n\r\nAfter building everything with `-g2 -O2 -march=native`, deleting `cpu.o`, and then rebuilding it with `-g3 -O0 -march=native`:\r\n\r\n```\r\nBreakpoint 1, CryptoPP::DetectX86Features () at cpu.cpp:223\r\n223\t\tif (!CpuId(0, cpuid))\r\n(gdb) n\r\n225\t\tif (!CpuId(1, cpuid1))\r\n(gdb) \r\n228\t\tg_hasMMX = (cpuid1[3] & (1 << 23)) != 0;\r\n(gdb) \r\n229\t\tif ((cpuid1[3] & (1 << 26)) != 0)\r\n(gdb) \r\n230\t\t\tg_hasSSE2 = TrySSE2();\r\n(gdb) \r\n231\t\tg_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));\r\n(gdb) \r\n232\t\tg_hasSSE4 = g_hasSSE2 && ((cpuid1[2] & (1<<19)) && (cpuid1[2] & (1<<20)));\r\n(gdb) \r\n233\t\tg_hasAESNI = g_hasSSE2 && (cpuid1[2] & (1<<25));\r\n(gdb) \r\n234\t\tg_hasCLMUL = g_hasSSE2 && (cpuid1[2] & (1<<1));\r\n(gdb) \r\n236\t\tif ((cpuid1[3] & (1 << 25)) != 0)\r\n(gdb) p g_hasSSE2\r\n$1 = true\r\n(gdb) p g_hasSSSE3\r\n$2 = true\r\n(gdb) p g_hasSSE4\r\n$3 = false\r\n(gdb) p g_hasAESNI\r\n$4 = false\r\n(gdb) p g_hasCLMUL\r\n$5 = false\r\n```\r\n\r\nThen set watchpoints looking for changes:\r\n\r\n```\r\n(gdb) watch g_hasSSSE3\r\nHardware watchpoint 2: g_hasSSSE3\r\n(gdb) watch g_hasSSE4\r\nHardware watchpoint 3: g_hasSSE4\r\n(gdb) c\r\nContinuing.\r\n...\r\nAll tests passed!\r\n\r\nTest ended at Sat Jun  4 17:23:31 2016\r\nSeed used was: 1465075409      \r\n[Inferior 1 (process 3539) exited normally]\r\n```\r\n\r\nTouching `cpu.h` and rebuilding all dependents produces the same result for optimized code.\r\n\r\nGCC version is `gcc (Debian 4.9.2-10) 4.9.2`.\r\n\r\nIt appears the optimizer is removing necessary code again. Making the variables of interest `volatile` does not help.\r\n"},"comment":{"url":"https://api.github.com/repos/weidai11/cryptopp/issues/comments/223839517","html_url":"https://github.com/weidai11/cryptopp/issues/176#issuecomment-223839517","issue_url":"https://api.github.com/repos/weidai11/cryptopp/issues/176","id":223839517,"user":{"login":"noloader","id":3538226,"avatar_url":"https://avatars.githubusercontent.com/u/3538226?v=3","gravatar_id":"","url":"https://api.github.com/users/noloader","html_url":"https://github.com/noloader","followers_url":"https://api.github.com/users/noloader/followers","following_url":"https://api.github.com/users/noloader/following{/other_user}","gists_url":"https://api.github.com/users/noloader/gists{/gist_id}","starred_url":"https://api.github.com/users/noloader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noloader/subscriptions","organizations_url":"https://api.github.com/users/noloader/orgs","repos_url":"https://api.github.com/users/noloader/repos","events_url":"https://api.github.com/users/noloader/events{/privacy}","received_events_url":"https://api.github.com/users/noloader/received_events","type":"User","site_admin":false},"created_at":"2016-06-05T21:41:17Z","updated_at":"2016-06-05T21:41:17Z","body":"The reporting issue was a transposition of `hasSSSE3` and `hasSSE4`. it was cleared with [Commit 5d9607613aba13a0](https://github.com/weidai11/cryptopp/commit/5d9607613aba13a0d19f574736ef7c3741a94c5d). However, I believe we are still seeing unwanted optimizations since the variable is not read after writing.\r\n\r\n"}}
{"actor":{"display_login":"noloader"}}