[llvm] r207500 - [ARM64]Fix a bug about incorrect operand order in an EXT instruction, which is introduced by r207485.

Hao Liu Hao.Liu at arm.com
Tue Apr 29 00:51:19 PDT 2014


Author: haoliu
Date: Tue Apr 29 02:51:19 2014
New Revision: 207500

URL: http://llvm.org/viewvc/llvm-project?rev=207500&view=rev
Log:
[ARM64]Fix a bug about incorrect operand order in an EXT instruction, which is introduced by r207485.

Added:
    llvm/trunk/test/CodeGen/ARM64/2014-04-29-EXT-undef-mask.ll
Modified:
    llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp

Modified: llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp?rev=207500&r1=207499&r2=207500&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp Tue Apr 29 02:51:19 2014
@@ -4001,13 +4001,19 @@ static bool isEXTMask(ArrayRef<int> M, E
   // value of the first element.
   // E.g. <-1, -1, 3, ...> is treated as <1, 2, 3, ...>.
   //      <-1, -1, 0, 1, ...> is treated as <IDX, IDX+1, 0, 1, ...>. IDX is
-  // equal to the ExpectedElt. For this case, ExpectedElt is (NumElts*2 - 2).
+  // equal to the ExpectedElt.
   Imm = (M[0] >= 0) ? static_cast<unsigned>(M[0]) : ExpectedElt.getZExtValue();
 
-  // Adjust the index value if the source operands will be swapped.
-  if (Imm >= NumElts) {
+  // If no beginning UNDEFs, do swap when M[0] >= NumElts.
+  if (M[0] >= 0 && Imm >= NumElts) {
     ReverseEXT = true;
     Imm -= NumElts;
+  } else if (M[0] < 0) {
+    // Only do swap when beginning UNDEFs more than the first real element,
+    if (*FirstRealElt < FirstRealElt - M.begin())
+      ReverseEXT = true;
+    if (Imm >= NumElts)
+      Imm -= NumElts;
   }
 
   return true;

Added: llvm/trunk/test/CodeGen/ARM64/2014-04-29-EXT-undef-mask.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM64/2014-04-29-EXT-undef-mask.ll?rev=207500&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM64/2014-04-29-EXT-undef-mask.ll (added)
+++ llvm/trunk/test/CodeGen/ARM64/2014-04-29-EXT-undef-mask.ll Tue Apr 29 02:51:19 2014
@@ -0,0 +1,23 @@
+; RUN: llc < %s -O0 -march=arm64 -arm64-neon-syntax=apple | FileCheck %s
+
+; The following 2 test cases test shufflevector with beginning UNDEF mask.
+define <8 x i16> @test_vext_undef_traverse(<8 x i16> %in) {
+;CHECK-LABEL: test_vext_undef_traverse:
+;CHECK: {{ext.16b.*v0, #4}}
+  %vext = shufflevector <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 0, i16 0>, <8 x i16> %in, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 6, i32 7, i32 8, i32 9>
+  ret <8 x i16> %vext
+}
+
+define <8 x i16> @test_vext_undef_traverse2(<8 x i16> %in) {
+;CHECK-LABEL: test_vext_undef_traverse2:
+;CHECK: {{ext.16b.*v0, #6}}
+  %vext = shufflevector <8 x i16> %in, <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef>, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 1, i32 2>
+  ret <8 x i16> %vext
+}
+
+define <8 x i8> @test_vext_undef_traverse3(<8 x i8> %in) {
+;CHECK-LABEL: test_vext_undef_traverse3:
+;CHECK: {{ext.8b.*v0, #6}}
+  %vext = shufflevector <8 x i8> %in, <8 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef>, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 2, i32 3, i32 4, i32 5>
+  ret <8 x i8> %vext
+}





More information about the llvm-commits mailing list