From e2e89ef93604fefb1a145d26e12f43da7a5f24d2 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sun, 22 May 2016 15:41:53 +0000 Subject: [ValueTracking, InstCombine] extend isKnownToBeAPowerOfTwo() to handle vector splat constants We could try harder to handle non-splat vector constants too, but that seems much rarer to me. Note that the div test isn't resolved because there's a check for isIntegerTy() guarding that transform. Differential Revision: http://reviews.llvm.org/D20497 llvm-svn: 270369 --- llvm/lib/Analysis/ValueTracking.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Analysis/ValueTracking.cpp') diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 19fef59..3885347 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1500,9 +1500,10 @@ bool isKnownToBeAPowerOfTwo(Value *V, bool OrZero, unsigned Depth, if (Constant *C = dyn_cast(V)) { if (C->isNullValue()) return OrZero; - if (ConstantInt *CI = dyn_cast(C)) - return CI->getValue().isPowerOf2(); - // TODO: Handle vector constants. + + const APInt *ConstIntOrConstSplatInt; + if (match(C, m_APInt(ConstIntOrConstSplatInt))) + return ConstIntOrConstSplatInt->isPowerOf2(); } // 1 << X is clearly a power of two if the one is not shifted off the end. If -- cgit v1.1