[ARM] Fix crash when targetting CPU without NEON
authorJames Molloy <james.molloy@arm.com>
Mon, 17 Aug 2015 19:37:12 +0000 (19:37 +0000)
committerJames Molloy <james.molloy@arm.com>
Mon, 17 Aug 2015 19:37:12 +0000 (19:37 +0000)
We emulate a scalar vmin/vmax with NEON instructions as they don't exist in the VFP ISA. So only mark these as legal when NEON is available.

Found here: https://code.google.com/p/chromium/issues/detail?id=521671

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245231 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/neon_minmax.ll

index 5bc78c73cfe2ddd4e95f14b645a9386d33700136..fe8da7ffc806d2719eef8794178751d475e90fcf 100644 (file)
@@ -950,11 +950,11 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
     }
   }
 
-  if (Subtarget->hasVFP3()) {
+  if (Subtarget->hasNEON()) {
+    // vmin and vmax aren't available in a scalar form, so we use
+    // a NEON instruction with an undef lane instead.
     setOperationAction(ISD::FMINNAN, MVT::f32, Legal);
     setOperationAction(ISD::FMAXNAN, MVT::f32, Legal);
-  }
-  if (Subtarget->hasNEON()) {
     setOperationAction(ISD::FMINNAN, MVT::v2f32, Legal);
     setOperationAction(ISD::FMAXNAN, MVT::v2f32, Legal);
     setOperationAction(ISD::FMINNAN, MVT::v4f32, Legal);
index 84e4b303c16dec085e7b85c54e1f90298086f749..883522a829a538ed789844f44a723230f52d30de 100644 (file)
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=arm-eabi -mcpu=swift %s -o - | FileCheck %s
+; RUN: llc -mtriple=arm-eabi -mcpu=cortex-a8 -mattr=-neon %s -o -
 
 define float @fmin_ole(float %x) nounwind {
 ;CHECK-LABEL: fmin_ole: