Use range metadata instead of introducing selects.
authorDan Gohman <dan433584@gmail.com>
Mon, 17 Mar 2014 19:57:04 +0000 (19:57 +0000)
committerDan Gohman <dan433584@gmail.com>
Mon, 17 Mar 2014 19:57:04 +0000 (19:57 +0000)
commit43873d4f73f85b434c0828fab5f956fd08ac3757
treef0c307871f0aa702e4e07c1aff80026299c4f0db
parent92fca73d521758012e0e425eac33bb77e888112e
Use range metadata instead of introducing selects.

When GlobalOpt has determined that a GlobalVariable only ever has two values,
it would convert the GlobalVariable to a boolean, and introduce SelectInsts
at every load, to choose between the two possible values. These SelectInsts
introduce overhead and other unpleasantness.

This patch makes GlobalOpt just add range metadata to loads from such
GlobalVariables instead. This enables the same main optimization (as seen in
test/Transforms/GlobalOpt/integer-bool.ll), without introducing selects.

The main downside is that it doesn't get the memory savings of shrinking such
GlobalVariables, but this is expected to be negligible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204076 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/GlobalOpt.cpp
test/Transforms/GlobalOpt/integer-bool.ll
test/Transforms/GlobalOpt/twostore-gv-range.ll [new file with mode: 0644]