1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[IR] fix Constant::isElementWiseEqual() to allow for all undef elements compare

We could argue that match() should be more flexible here,
but I'm not sure what impact that would have on existing code.
This commit is contained in:
Sanjay Patel 2020-01-17 08:31:16 -05:00
parent 5e10616d04
commit b77facd730
2 changed files with 3 additions and 2 deletions

View File

@ -296,7 +296,8 @@ bool Constant::isElementWiseEqual(Value *Y) const {
Type *IntTy = VectorType::getInteger(cast<VectorType>(Ty));
Constant *C0 = ConstantExpr::getBitCast(const_cast<Constant *>(this), IntTy);
Constant *C1 = ConstantExpr::getBitCast(cast<Constant>(Y), IntTy);
return match(ConstantExpr::getICmp(ICmpInst::ICMP_EQ, C0, C1), m_One());
Constant *CmpEq = ConstantExpr::getICmp(ICmpInst::ICMP_EQ, C0, C1);
return isa<UndefValue>(CmpEq) || match(CmpEq, m_One());
}
bool Constant::containsUndefElement() const {

View File

@ -620,7 +620,7 @@ TEST(ConstantsTest, isElementWiseEqual) {
EXPECT_TRUE(CF1211->isElementWiseEqual(CF12U1));
EXPECT_TRUE(CF12U1->isElementWiseEqual(CF1211));
EXPECT_FALSE(CFUU1U->isElementWiseEqual(CF12U1)); // FIXME - all lanes compare as undef
EXPECT_TRUE(CFUU1U->isElementWiseEqual(CF12U1));
EXPECT_FALSE(CF12U2->isElementWiseEqual(CF12U1));
EXPECT_FALSE(CF12U1->isElementWiseEqual(CF12U2));