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

fix PR6193, only considering sign extensions *from i1* for this

xform.

llvm-svn: 95642
This commit is contained in:
Chris Lattner 2010-02-09 01:12:41 +00:00
parent 1ff7f162e2
commit 26b712379f
2 changed files with 21 additions and 5 deletions

View File

@ -1142,19 +1142,24 @@ static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
Value *C, Value *D) {
// If A is not a select of -1/0, this cannot match.
Value *Cond = 0;
if (!match(A, m_SExt(m_Value(Cond))))
if (!match(A, m_SExt(m_Value(Cond))) ||
!Cond->getType()->isInteger(1))
return 0;
// ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
if (match(D, m_Not(m_SExt(m_Specific(Cond)))))
if (match(D, m_Not(m_SExt(m_Specific(Cond)))) &&
Cond->getType()->isInteger(1))
return SelectInst::Create(Cond, C, B);
if (match(D, m_SExt(m_Not(m_Specific(Cond)))))
if (match(D, m_SExt(m_Not(m_Specific(Cond)))) &&
Cond->getType()->isInteger(1))
return SelectInst::Create(Cond, C, B);
// ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
if (match(B, m_Not(m_SExt(m_Specific(Cond)))))
if (match(B, m_Not(m_SExt(m_Specific(Cond)))) &&
Cond->getType()->isInteger(1))
return SelectInst::Create(Cond, C, D);
if (match(B, m_SExt(m_Not(m_Specific(Cond)))))
if (match(B, m_SExt(m_Not(m_Specific(Cond)))) &&
Cond->getType()->isInteger(1))
return SelectInst::Create(Cond, C, D);
return 0;
}

View File

@ -226,3 +226,14 @@ define void @test10a() {
ret void
}
; PR6193
define i32 @test11(i32 %aMaskWidth, i8 %aStride) nounwind {
entry:
%conv41 = sext i8 %aStride to i32
%neg = xor i32 %conv41, -1
%and42 = and i32 %aMaskWidth, %neg
%and47 = and i32 130, %conv41
%or = or i32 %and42, %and47
ret i32 %or
}