[JumpThreading] Preserve profile metadata during select unfolding
authorMax Kazantsev <mkazantsev@azul.com>
Mon, 9 Jan 2023 09:04:00 +0000 (16:04 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Mon, 9 Jan 2023 09:14:58 +0000 (16:14 +0700)
commit957952dbf2f34ed552e8e1f8c35eed17eee2ea38
treeeb2523a9d54433d603674af85cb97f17566d08c8
parentde3f0f7fa0c7b902dde840913db7e773a02c4173
[JumpThreading] Preserve profile metadata during select unfolding

Jump threading can replace select and unconditional branch with
conditional branch, but when doing so loses profile information.

This destructive transform can eventually lead to a performance
degradation due to folding of branches in
shouldFoldCondBranchesToCommonDestination as branch probabilities
are no longer known.

Patch by Roman Paukner!

Differential Revision: https://reviews.llvm.org/D138132
Reviewed By: mkazantsev
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/test/Transforms/JumpThreading/select.ll