[PATCH] D39556: [ConstantFold] Support vector index when factoring out GEP index into preceding dimensions
Haicheng Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 19 18:32:53 PST 2017
haicheng added inline comments.
================
Comment at: lib/IR/ConstantFold.cpp:2214
+ bool Unknown =
+ !isa<ConstantInt>(Idxs[0]) && (!isa<ConstantDataVector>(Idxs[0]));
for (unsigned i = 1, e = Idxs.size(); i != e;
----------------
mssimpso wrote:
> You should be able to just use `!isa<Constant>(Idxs[0])` for these kinds of checks I think. All GEP indices are required to be integers or integer vectors.
I think `Unknown` is set to true if we don't know the indices are inbound or not. Since we only check the bound for `ConstantInt ` and `ConstantDataVector`, I just white list these two. It is true that the constant index can only be constant integer and constant integer vector, but wild constant expression (e.g. ptrtoint) is also allowed. If I change the code to !`isa<Constant>`, many test cases fail.
Repository:
rL LLVM
https://reviews.llvm.org/D39556
More information about the llvm-commits
mailing list