[llvm] e107374 - [Hexagon] Explicitly use integer types when rescaling a mask

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 30 10:18:28 PST 2021


Author: Krzysztof Parzyszek
Date: 2021-12-30T10:14:00-08:00
New Revision: e107374e40a20de84a0fd9b2a6b828d53056b3d5

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

LOG: [Hexagon] Explicitly use integer types when rescaling a mask

Added: 
    llvm/test/CodeGen/Hexagon/autohvx/vector-align-rescale-nonint.ll

Modified: 
    llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
    llvm/test/CodeGen/Hexagon/autohvx/calling-conv.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index 21386a91c7b3..755ad96e58c4 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -1181,12 +1181,15 @@ auto HexagonVectorCombine::rescale(IRBuilder<> &Builder, Value *Mask,
   int ToCount = (FromCount * FromSize) / ToSize;
   assert((FromCount * FromSize) % ToSize == 0);
 
+  auto *FromITy = IntegerType::get(F.getContext(), FromSize * 8);
+  auto *ToITy = IntegerType::get(F.getContext(), ToSize * 8);
+
   // Mask <N x i1> -> sext to <N x FromTy> -> bitcast to <M x ToTy> ->
   // -> trunc to <M x i1>.
   Value *Ext = Builder.CreateSExt(
-      Mask, VectorType::get(FromSTy, FromCount, /*Scalable*/ false));
+      Mask, VectorType::get(FromITy, FromCount, /*Scalable*/ false));
   Value *Cast = Builder.CreateBitCast(
-      Ext, VectorType::get(ToSTy, ToCount, /*Scalable*/ false));
+      Ext, VectorType::get(ToITy, ToCount, /*Scalable*/ false));
   return Builder.CreateTrunc(
       Cast, VectorType::get(getBoolTy(), ToCount, /*Scalable*/ false));
 }

diff  --git a/llvm/test/CodeGen/Hexagon/autohvx/calling-conv.ll b/llvm/test/CodeGen/Hexagon/autohvx/calling-conv.ll
index 6ebe077ae120..884eb6e7ac75 100644
--- a/llvm/test/CodeGen/Hexagon/autohvx/calling-conv.ll
+++ b/llvm/test/CodeGen/Hexagon/autohvx/calling-conv.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -march=hexagon -hexagon-vector-combine=false < %s | FileCheck %s
+; RUN: llc -march=hexagon < %s | FileCheck %s
 
 define void @f0(<128 x i8> %a0, <128 x i8>* %a1) #0 {
 ; CHECK-LABEL: f0:

diff  --git a/llvm/test/CodeGen/Hexagon/autohvx/vector-align-rescale-nonint.ll b/llvm/test/CodeGen/Hexagon/autohvx/vector-align-rescale-nonint.ll
new file mode 100644
index 000000000000..157207d5ad9d
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/autohvx/vector-align-rescale-nonint.ll
@@ -0,0 +1,28 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+
+; Check that this doesn't crash.
+; CHECK: vmem
+
+target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
+target triple = "hexagon"
+
+define dllexport void @f0(float* %a0, <32 x float> %a1, <32 x float> %a2) local_unnamed_addr #0 {
+b0:
+  %v0 = add nuw nsw i32 0, 64
+  %v1 = getelementptr inbounds float, float* %a0, i32 %v0
+  %v2 = bitcast float* %v1 to <32 x float>*
+  %v3 = add nuw nsw i32 0, 96
+  %v4 = getelementptr inbounds float, float* %a0, i32 %v3
+  %v5 = bitcast float* %v4 to <32 x float>*
+  br label %b1
+
+b1:                                               ; preds = %b1, %b0
+  br i1 undef, label %b2, label %b1
+
+b2:                                               ; preds = %b1
+  store <32 x float> %a1, <32 x float>* %v2, align 4
+  store <32 x float> %a2, <32 x float>* %v5, align 4
+  ret void
+}
+
+attributes #0 = { "target-features"="+hvxv69,+hvx-length128b,+hvx-qfloat" }


        


More information about the llvm-commits mailing list