[JumpThreading] Look through freeze in getPredicateAt() fold
authorNikita Popov <npopov@redhat.com>
Wed, 18 May 2022 09:26:56 +0000 (11:26 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 18 May 2022 10:09:59 +0000 (12:09 +0200)
commitc9e7049754ac94a952de8ac6962c36f844e43b3c
treeae7eb8c95534dd7055581c656d3450ca89939069
parente2926501d886ce8c1cd08db1d3a02c314c2f412d
[JumpThreading] Look through freeze in getPredicateAt() fold

This code is valid for any icmp, so we can safely look through a
freeze when trying to find one.

A caveat here is that replaceFoldableUses() may not end up replacing
any uses in this case. It might make sense to use the freeze as the
context instruction (rather than the terminator) if there is a
freeze, to ensure that it always gets folded. This would require
some changes to how replaceFoldedUses() works though, as it
currently assumes that the value is valid at the end of the block.
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/test/Transforms/JumpThreading/freeze.ll
llvm/test/Transforms/JumpThreading/select-unfold-freeze.ll