[PATCH] D51938: [InstCombine] Fix incorrect usage of getPrimitiveSizeInBits when we should be using the element size for vectors

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 11 10:58:42 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL341971: [InstCombine] Fix incorrect usage of getPrimitiveSizeInBits when we should be… (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51938?vs=164916&id=164932#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51938

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
  llvm/trunk/test/Transforms/InstCombine/mul.ll


Index: llvm/trunk/test/Transforms/InstCombine/mul.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/mul.ll
+++ llvm/trunk/test/Transforms/InstCombine/mul.ll
@@ -409,7 +409,7 @@
 
 define <2 x i32> @test32vec(<2 x i32> %X) {
 ; CHECK-LABEL: @test32vec(
-; CHECK-NEXT:    [[MUL:%.*]] = shl nsw <2 x i32> [[X:%.*]], <i32 31, i32 31>
+; CHECK-NEXT:    [[MUL:%.*]] = shl <2 x i32> [[X:%.*]], <i32 31, i32 31>
 ; CHECK-NEXT:    ret <2 x i32> [[MUL]]
 ;
   %mul = mul nsw <2 x i32> %X, <i32 -2147483648, i32 -2147483648>
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -171,14 +171,13 @@
     if (match(&I, m_Mul(m_Value(NewOp), m_Constant(C1)))) {
       // Replace X*(2^C) with X << C, where C is either a scalar or a vector.
       if (Constant *NewCst = getLogBase2(NewOp->getType(), C1)) {
-        unsigned Width = NewCst->getType()->getPrimitiveSizeInBits();
         BinaryOperator *Shl = BinaryOperator::CreateShl(NewOp, NewCst);
 
         if (I.hasNoUnsignedWrap())
           Shl->setHasNoUnsignedWrap();
         if (I.hasNoSignedWrap()) {
           const APInt *V;
-          if (match(NewCst, m_APInt(V)) && *V != Width - 1)
+          if (match(NewCst, m_APInt(V)) && *V != V->getBitWidth() - 1)
             Shl->setHasNoSignedWrap();
         }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51938.164932.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180911/f628f2f3/attachment.bin>


More information about the llvm-commits mailing list