]> granicus.if.org Git - llvm/commitdiff
Fixup patch for revision rL316070.
authorNikolai Bozhenov <nikolai.bozhenov@intel.com>
Wed, 18 Oct 2017 14:24:50 +0000 (14:24 +0000)
committerNikolai Bozhenov <nikolai.bozhenov@intel.com>
Wed, 18 Oct 2017 14:24:50 +0000 (14:24 +0000)
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 <artur.gainullin@intel.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316082 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp

index 55a7a353858fa8cd9d2a7365ccf0322e1e96135f..4f5d69d77aa98365d637d644c362e962c0d14586 100644 (file)
@@ -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