OSDN Git Service

Subzero: Fix floating-point constant pooling.
authorJim Stichnoth <stichnot@chromium.org>
Thu, 19 Mar 2015 20:51:56 +0000 (13:51 -0700)
committerJim Stichnoth <stichnot@chromium.org>
Thu, 19 Mar 2015 20:51:56 +0000 (13:51 -0700)
commit5bfe21578536c437ef17052038c5d85eaf1bd484
tree2d05ae678d86de908f895e9605ebf6d6e8da5070
parent8c980d0de6592be36fae4ec8ae603dde7212c46c
Subzero: Fix floating-point constant pooling.

This fixes a regression likely introduced in d2cb4361c732dcddc98659415f37be45982e20c3 .

The problem is that by using the default std::unordered_map comparison predicate std::equal_to, we get incorrect behavior when the key is float or double:

1. 0.0 and -0.0 appear equal, so they share a constant pool entry even though the bit patterns are different.  This is a correctness bug.

2. Each instance of NaN gets a separate constant pool entry, because NaN != NaN by C equality rules.  This is a performance bug.  (This problem doesn't show up with the native bitcode reader, because constants are already unique-ified in the PNaCl bitcode file.)

The solution is to use memcmp for floating-point key types.

Also, the abi-atomics.ll test is disabled for the MINIMAL build, to fix an oversight from a previous CL.

BUG= none
R=jfb@chromium.org

Review URL: https://codereview.chromium.org/1019233002
src/IceGlobalContext.cpp
tests_lit/llvm2ice_tests/abi-atomics.ll
tests_lit/llvm2ice_tests/fp_const_pool.ll [new file with mode: 0644]