[llvm-branch-commits] [llvm] baf931a - [Hexagon] Reconsider getMask fix, return original mask, convert later

Krzysztof Parzyszek via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 12 11:34:42 PST 2020


Author: Krzysztof Parzyszek
Date: 2020-12-12T13:27:22-06:00
New Revision: baf931a8427dc29532aa42460604f23bf9a39708

URL: https://github.com/llvm/llvm-project/commit/baf931a8427dc29532aa42460604f23bf9a39708
DIFF: https://github.com/llvm/llvm-project/commit/baf931a8427dc29532aa42460604f23bf9a39708.diff

LOG: [Hexagon] Reconsider getMask fix, return original mask, convert later

The getPayload/getMask/getPassThrough functions should return values
that could be composed into a masked load/store without any additional
type casts. The previous fix violated that.
Instead, convert scalar mask to a vector right before rescaling.

Added: 
    

Modified: 
    llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index fb716ef5bbc2..4c0c202be4be 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -416,8 +416,7 @@ auto AlignVectors::getMask(Value *Val) const -> Value * {
     int ElemCount = VecTy->getElementCount().getFixedValue();
     return HVC.getFullValue(HVC.getBoolTy(ElemCount));
   }
-  // For scalars, return a vector <1 x i1>.
-  return HVC.getFullValue(HVC.getBoolTy(1));
+  return HVC.getFullValue(HVC.getBoolTy());
 }
 
 auto AlignVectors::getPassThrough(Value *Val) const -> Value * {
@@ -811,14 +810,24 @@ auto AlignVectors::realignGroup(const MoveGroup &Move) const -> bool {
     // Stores.
     ByteSpan ASpanV, ASpanM;
 
+    // Return a vector value corresponding to the input value Val:
+    // either <1 x Val> for scalar Val, or Val itself for vector Val.
+    auto MakeVec = [](IRBuilder<> &Builder, Value *Val) -> Value * {
+      Type *Ty = Val->getType();
+      if (Ty->isVectorTy())
+        return Val;
+      auto *VecTy = VectorType::get(Ty, 1, /*Scalable*/ false);
+      return Builder.CreateBitCast(Val, VecTy);
+    };
+
     for (int i = -1; i != NumSectors; ++i) {
       ByteSpan Section = VSpan.section(i * ScLen, ScLen).normalize();
       Value *AccumV = UndefValue::get(SecTy);
       Value *AccumM = HVC.getNullValue(SecTy);
       for (ByteSpan::Block &S : Section) {
         Value *Pay = getPayload(S.Seg.Val);
-        Value *Mask = HVC.rescale(Builder, getMask(S.Seg.Val), Pay->getType(),
-                                  HVC.getByteTy());
+        Value *Mask = HVC.rescale(Builder, MakeVec(Builder, getMask(S.Seg.Val)),
+                                  Pay->getType(), HVC.getByteTy());
         AccumM = HVC.insertb(Builder, AccumM, HVC.vbytes(Builder, Mask),
                              S.Seg.Start, S.Seg.Size, S.Pos);
         AccumV = HVC.insertb(Builder, AccumV, HVC.vbytes(Builder, Pay),


        


More information about the llvm-branch-commits mailing list