From: Nikolai Bozhenov Date: Wed, 18 Oct 2017 14:24:50 +0000 (+0000) Subject: Fixup patch for revision rL316070. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=429594f14d984c439ffcce83f636c515cfa3a9a8;p=llvm Fixup patch for revision rL316070. Added check that type of CmpConst and source type of trunc are equal for correct matching of the case when we can set widened C constant equal to CmpConstant. %cond = cmp iN %x, CmpConst %tr = trunc iN %x to iK %narrowsel = select i1 %cond, iK %t, iK C Patch by: Gainullin, Artur git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316082 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 55a7a353858..4f5d69d77aa 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -4365,7 +4365,8 @@ static Value *lookThroughCast(CmpInst *CmpI, Value *V1, Value *V2, break; case Instruction::Trunc: Constant *CmpConst; - if (match(CmpI->getOperand(1), m_Constant(CmpConst))) { + if (match(CmpI->getOperand(1), m_Constant(CmpConst)) && + CmpConst->getType() == SrcTy) { // Here we have the following case: // // %cond = cmp iN %x, CmpConst