Index: lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- lib/Target/AArch64/AArch64ISelLowering.cpp +++ lib/Target/AArch64/AArch64ISelLowering.cpp @@ -3433,6 +3433,9 @@ AttributeSet::FunctionIndex, Attribute::NoImplicitFloat)) return SDValue(); + if (!Subtarget->hasNEON()) + return SDValue(); + // While there is no integer popcount instruction, it can // be more efficiently lowered to the following sequence that uses // AdvSIMD registers/instructions as long as the copies to/from Index: test/CodeGen/AArch64/arm64-popcnt.ll =================================================================== --- test/CodeGen/AArch64/arm64-popcnt.ll +++ test/CodeGen/AArch64/arm64-popcnt.ll @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=arm64 -aarch64-neon-syntax=apple | FileCheck %s +; RUN: llc < %s -march=aarch64 -mattr -neon -aarch64-neon-syntax=apple | FileCheck -check-prefix=CHECK-NONEON %s define i32 @cnt32_advsimd(i32 %x) nounwind readnone { %cnt = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -8,6 +9,7 @@ ; CHECK: uaddlv.8b h0, v0 ; CHECK: fmov w0, s0 ; CHECK: ret +; CHECK-NONEON-NOT: 8b } define i64 @cnt64_advsimd(i64 %x) nounwind readnone { @@ -18,6 +20,7 @@ ; CHECK: uaddlv.8b h0, v0 ; CHECK: fmov w0, s0 ; CHECK: ret +; CHECK-NONEON-NOT: 8b } ; Do not use AdvSIMD when -mno-implicit-float is specified.