This is an archive of the discontinued LLVM Phabricator instance.

[APFloat] Remove dead store in the move constructor of IEEEFloat
Needs ReviewPublic

Authored by vgao on Aug 20 2018, 4:23 PM.

Details

Summary

In the move constructor, field semantics is first set to &semBogus, which is a static constant.
It is then set to rhs.semantics, killing the first store. This dead store is not removed in -O3.

freeSignificand() is called between the two stores, and it does read from the field semantics. However with semantics set to &semBogus, this operation always evaluates to nothing.

This diff adds a helper function (moveFields) that copies the fields without calling freeSignificand().
By doing this we save a store (and potentially a call to freeSignicand()) in IEEEFloat(IEEEFloat &&), and do not lose any performance in operator =(IEEEFloat &&), since moveFields is inlined in both callsites.

Diff Detail

Event Timeline

vgao created this revision.Aug 20 2018, 4:23 PM
vgao edited the summary of this revision. (Show Details)Aug 20 2018, 4:24 PM