[InstCombine] canonicalize funnel shift constant shift amount to be modulo bitwidth
authorSanjay Patel <spatel@rotateright.com>
Thu, 14 Mar 2019 19:22:08 +0000 (19:22 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 14 Mar 2019 19:22:08 +0000 (19:22 +0000)
commitde1d5d3675992a60c95b17d70ea817468883c485
tree705e488bdb810e0a0cba00b3a36906e11285c1dd
parent6e86216531e2c53f171aaf8b911327ab616c6c0d
[InstCombine] canonicalize funnel shift constant shift amount to be modulo bitwidth

The shift argument is defined to be modulo the bitwidth, so if that argument
is a constant, we can always reduce the constant to its minimal form to allow
better CSE and other follow-on transforms.

We need to be careful to ignore constant expressions here, or we will likely
infinite loop. I'm adding a general vector constant query for that case.

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

llvm-svn: 356192
llvm/include/llvm/IR/Constant.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/fsh.ll