[llvm] r325378 - [AArch64] Fix BITCAST lowering crash

Evandro Menezes via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 12:00:57 PST 2018


Author: evandro
Date: Fri Feb 16 12:00:57 2018
New Revision: 325378

URL: http://llvm.org/viewvc/llvm-project?rev=325378&view=rev
Log:
[AArch64] Fix BITCAST lowering crash

The data type is assumed to be a vector, but sometimes it is not, leading
to an assertion.

Add simple test-case to verify this.

Differential revision: https://reviews.llvm.org/D42599

Added:
    llvm/trunk/test/CodeGen/AArch64/strqu.ll
Modified:
    llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp

Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=325378&r1=325377&r2=325378&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Fri Feb 16 12:00:57 2018
@@ -8776,7 +8776,8 @@ static SDValue performBitcastCombine(SDN
   // If the source type has twice the number of elements as our destination
   // type, we know this is an extract of the high or low half of the vector.
   EVT SVT = Source->getValueType(0);
-  if (SVT.getVectorNumElements() != VT.getVectorNumElements() * 2)
+  if (!SVT.isVector() ||
+      SVT.getVectorNumElements() != VT.getVectorNumElements() * 2)
     return SDValue();
 
   DEBUG(dbgs() << "aarch64-lower: bitcast extract_subvector simplification\n");

Added: llvm/trunk/test/CodeGen/AArch64/strqu.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/strqu.ll?rev=325378&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/strqu.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/strqu.ll Fri Feb 16 12:00:57 2018
@@ -0,0 +1,28 @@
+; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64-linux-gnu    | FileCheck --check-prefixes=CHECK,NOSPLIT %s
+; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64_be-linux-gnu | FileCheck --check-prefixes=CHECK,NOSPLIT %s
+; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64-linux-gnu    -mcpu=exynos-m1 | FileCheck --check-prefixes=CHECK,NOSPLIT %s
+; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64_be-linux-gnu -mcpu=exynos-m1 | FileCheck --check-prefixes=CHECK,SPLIT %s
+
+; CHECK-LABEL: test_split_f:
+; NOSPLIT: str q{{[0-9]+}}, [x{{[0-9]+}}]
+; SPLIT: st1 { v{{[0-9]+}}.2s }, [x{{[0-9]+}}]
+; SPLIT: st1 { v{{[0-9]+}}.2s }, [x{{[0-9]+}}]
+define void @test_split_f(<4 x float> %val, <4 x float>* %addr) {
+  store <4 x float> %val, <4 x float>* %addr, align 8
+  ret void
+}
+
+; CHECK-LABEL: test_split_d:
+; NOSPLIT: str q{{[0-9]+}}, [x{{[0-9]+}}]
+; SPLIT: st1 { v{{[0-9]+}}.2d }, [x{{[0-9]+}}]
+define void @test_split_d(<2 x double> %val, <2 x double>* %addr) {
+  store <2 x double> %val, <2 x double>* %addr, align 8
+  ret void
+}
+
+; CHECK-LABEL: test_split_128:
+; CHECK: str q{{[0-9]+}}, [x{{[0-9]+}}]
+define void @test_split_128(fp128 %val, fp128* %addr) {
+  store fp128 %val, fp128* %addr, align 8
+  ret void
+}




More information about the llvm-commits mailing list