[PATCH] D37198: [InlineCost] add visitSelectInst()
Chandler Carruth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 22:15:57 PDT 2017
chandlerc added inline comments.
================
Comment at: lib/Analysis/InlineCost.cpp:1201
+ // Select True, X, Y => X
+ if (CondC->isAllOnesValue() && TrueC) {
+ SimplifiedValues[&SI] = TrueC;
----------------
haicheng wrote:
> chandlerc wrote:
> > No need to separately test for true and false once you know the condition is a constant. Just check `isNullValue()`. It's either false, or true. =]
> The vector constant condition can be <i1 true, i1 false>. It is neither AllOnesValue or NullValue.
Ah, I see.
But if you have a constant condition, even if a vector with a mixture of true and false elements, you can fully simulate the select (and we should). The test should be "is it a constant". Once we know that it is, we should be able to get at each element and test whether that element is a null value or not. And then the scalar case will just be the same as a 1-element vector.
Repository:
rL LLVM
https://reviews.llvm.org/D37198
More information about the llvm-commits
mailing list