OSDN Git Service

[InstSimplify] delete shift-of-zero guard ops around funnel shifts
authorSanjay Patel <spatel@rotateright.com>
Thu, 15 Nov 2018 14:53:37 +0000 (14:53 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 15 Nov 2018 14:53:37 +0000 (14:53 +0000)
commitfc0780a8a945b192222786e9b7f0540b6a140aa7
tree098938c86b8cb0a7661748848d6c787c7813d7f1
parent643206597fa281803bfdbaf8281c75d842936ba2
[InstSimplify] delete shift-of-zero guard ops around funnel shifts

This is a problem seen in common rotate idioms as noted in:
https://bugs.llvm.org/show_bug.cgi?id=34924

Note that we are not canonicalizing standard IR (shifts and logic) to the intrinsics yet.
(Although I've written this before...) I think this is the last step before we enable
that transform. Ie, we could regress code by doing that transform without this
simplification in place.

In PR34924, I questioned whether this is a valid transform for target-independent IR,
but I convinced myself this is ok. If we're speculating a funnel shift by turning cmp+br
into select, then SimplifyCFG has already determined that the transform is justified.
It's possible that SimplifyCFG is not taking into account profile or other metadata,
but if that's true, then it's a bug independent of funnel shifts.

Also, we do have CGP code to restore a guard like this around an intrinsic if it can't
be lowered cheaply. But that isn't necessary for funnel shift because the default
expansion in SelectionDAGBuilder includes this same cmp+select.

Differential Revision: https://reviews.llvm.org/D54552

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346960 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/call.ll