[llvm] e88eb64 - [Hexagon] Fix buildVector32 for v4i8 constants

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 4 11:24:18 PST 2022


Author: Tasmia Rahman
Date: 2022-01-04T11:19:15-08:00
New Revision: e88eb6443fe08e36f64bc5c795f80d4fe204ab83

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

LOG: [Hexagon] Fix buildVector32 for v4i8 constants

The code for constructing a 32-bit constant from 4 8-bit constants has
a typo and uses one of the constants twice

Added: 
    llvm/test/CodeGen/Hexagon/generate-const-buildvector32.ll

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 699a818c887b..9aac770a4380 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -2440,8 +2440,8 @@ HexagonTargetLowering::buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl,
     if (AllConst) {
       int32_t V = (Consts[0]->getZExtValue() & 0xFF) |
                   (Consts[1]->getZExtValue() & 0xFF) << 8 |
-                  (Consts[1]->getZExtValue() & 0xFF) << 16 |
-                  Consts[2]->getZExtValue() << 24;
+                  (Consts[2]->getZExtValue() & 0xFF) << 16 |
+                  Consts[3]->getZExtValue() << 24;
       return DAG.getBitcast(MVT::v4i8, DAG.getConstant(V, dl, MVT::i32));
     }
 

diff  --git a/llvm/test/CodeGen/Hexagon/generate-const-buildvector32.ll b/llvm/test/CodeGen/Hexagon/generate-const-buildvector32.ll
new file mode 100644
index 000000000000..645efc2932ca
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/generate-const-buildvector32.ll
@@ -0,0 +1,11 @@
+; RUN: llc -march=hexagon -mtriple=hexagon < %s | FileCheck %s
+
+; CHECK: r{{[0-9]+}} = ##673059850
+
+define dso_local i32 @main() #0 {
+entry:
+  %a = alloca <4 x i8>, align 4
+  store <4 x i8> <i8 10, i8 20, i8 30, i8 40>, <4 x i8>* %a, align 4
+  ret i32 0
+}
+


        


More information about the llvm-commits mailing list