[SimplifyIndVar] Constant fold IV users
authorHongbin Zheng <etherzhhb@gmail.com>
Wed, 27 Sep 2017 03:11:46 +0000 (03:11 +0000)
committerHongbin Zheng <etherzhhb@gmail.com>
Wed, 27 Sep 2017 03:11:46 +0000 (03:11 +0000)
commitd1b7b2efba67fcedcc803b2bf7dda808b9a5c401
tree97ce25fd46f47439ddec103a08336485ddfcc350
parent1d23cb4e7e8dbdff6fd5d8b365b14964254ca243
[SimplifyIndVar] Constant fold IV users

This patch tries to transform cases like:

for (unsigned i = 0; i < N; i += 2) {
  bool c0 = (i & 0x1) == 0;
  bool c1 = ((i + 1) & 0x1) == 1;
}
To

for (unsigned i = 0; i < N; i += 2) {
  bool c0 = true;
  bool c1 = true;
}

This commit also update test/Transforms/IndVarSimplify/replace-srem-by-urem.ll to prevent constant folding.

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

llvm-svn: 314266
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
llvm/test/Transforms/IndVarSimplify/constant-fold.ll [new file with mode: 0644]
llvm/test/Transforms/IndVarSimplify/replace-srem-by-urem.ll