[llvm] r322301 - [Hexagon] Cast elements to correct type when creating constant vector

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 10:03:23 PST 2018


Author: kparzysz
Date: Thu Jan 11 10:03:23 2018
New Revision: 322301

URL: http://llvm.org/viewvc/llvm-project?rev=322301&view=rev
Log:
[Hexagon] Cast elements to correct type when creating constant vector

Added:
    llvm/trunk/test/CodeGen/Hexagon/autohvx/isel-const-vector.ll
Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp

Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp?rev=322301&r1=322300&r2=322301&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp Thu Jan 11 10:03:23 2018
@@ -2509,9 +2509,10 @@ HexagonTargetLowering::getBuildVectorCon
       Consts[i] = ConstantInt::get(IntTy, 0);
       continue;
     }
+    // Make sure to always cast to IntTy.
     if (auto *CN = dyn_cast<ConstantSDNode>(V.getNode())) {
       const ConstantInt *CI = CN->getConstantIntValue();
-      Consts[i] = const_cast<ConstantInt*>(CI);
+      Consts[i] = ConstantInt::get(IntTy, CI->getValue().getSExtValue());
     } else if (auto *CN = dyn_cast<ConstantFPSDNode>(V.getNode())) {
       const ConstantFP *CF = CN->getConstantFPValue();
       APInt A = CF->getValueAPF().bitcastToAPInt();

Added: llvm/trunk/test/CodeGen/Hexagon/autohvx/isel-const-vector.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/autohvx/isel-const-vector.ll?rev=322301&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/autohvx/isel-const-vector.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/autohvx/isel-const-vector.ll Thu Jan 11 10:03:23 2018
@@ -0,0 +1,12 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+
+; Check that the elements of the constants have correct type.
+; CHECK: .half 31
+
+define void @fred(<32 x i16>* %p) #0 {
+  store <32 x i16> <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15, i16 16, i16 17, i16 18, i16 19, i16 20, i16 21, i16 22, i16 23, i16 24, i16 25, i16 26, i16 27, i16 28, i16 29, i16 30, i16 31>, <32 x i16>* %p, align 64
+  ret void
+}
+
+attributes #0 = { nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" }
+




More information about the llvm-commits mailing list