OSDN Git Service

isBytewiseValue checks ConstantVector element by element
authorVitaly Buka <vitalybuka@google.com>
Fri, 12 Jul 2019 22:37:55 +0000 (22:37 +0000)
committerVitaly Buka <vitalybuka@google.com>
Fri, 12 Jul 2019 22:37:55 +0000 (22:37 +0000)
Summary: Vector of the same value with few undefs will sill be considered "Bytewise"

Reviewers: eugenis, pcc, jfb

Reviewed By: jfb

Subscribers: dexonsmith, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64031

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

lib/Analysis/ValueTracking.cpp
unittests/Analysis/ValueTrackingTest.cpp

index cf8fa9c..ad8034b 100644 (file)
@@ -3253,12 +3253,7 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
     return Val;
   }
 
-  if (isa<ConstantVector>(C)) {
-    Constant *Splat = cast<ConstantVector>(C)->getSplatValue();
-    return Splat ? isBytewiseValue(Splat, DL) : nullptr;
-  }
-
-  if (isa<ConstantArray>(C) || isa<ConstantStruct>(C)) {
+  if (isa<ConstantAggregate>(C)) {
     Value *Val = UndefInt8;
     for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
       if (!(Val = Merge(Val, isBytewiseValue(C->getOperand(I), DL))))
index f4316cc..96b41d9 100644 (file)
@@ -878,7 +878,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
         "<4 x i8> <i8 1, i8 1, i8 2, i8 1>",
     },
     {
-        "",
+        "i8 5",
         "<2 x i8> < i8 5, i8 undef >",
     },
     {