From 359cab3bb3b048b99800bac9bd95ab1d0c432bc2 Mon Sep 17 00:00:00 2001 From: Ana Pazos Date: Wed, 13 Jan 2016 00:03:35 +0000 Subject: [PATCH] Guard fabs to bfc convert with V6T2 flag Summary: BFC instructions are available in ARMv6T2 and above. Reviewers: t.p.northover Subscribers: aemerson Differential Revision: http://reviews.llvm.org/D16076 llvm-svn: 257546 --- llvm/lib/Target/ARM/ARMInstrVFP.td | 4 ++-- llvm/test/CodeGen/ARM/fabs-to-bfc.ll | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/ARM/fabs-to-bfc.ll diff --git a/llvm/lib/Target/ARM/ARMInstrVFP.td b/llvm/lib/Target/ARM/ARMInstrVFP.td index 050cd1a445ad..63e7940bb14e 100644 --- a/llvm/lib/Target/ARM/ARMInstrVFP.td +++ b/llvm/lib/Target/ARM/ARMInstrVFP.td @@ -930,10 +930,10 @@ def VMOVDRR : AVConv5I<0b11000100, 0b1011, // and could enable the conversion to float to be removed completely. def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)), (VMOVDRR GPR:$Rl, (BFC GPR:$Rh, (i32 0x7FFFFFFF)))>, - Requires<[IsARM]>; + Requires<[IsARM, HasV6T2]>; def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)), (VMOVDRR GPR:$Rl, (t2BFC GPR:$Rh, (i32 0x7FFFFFFF)))>, - Requires<[IsThumb2]>; + Requires<[IsThumb2, HasV6T2]>; def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)), (VMOVDRR GPR:$Rl, (EORri GPR:$Rh, (i32 0x80000000)))>, Requires<[IsARM]>; diff --git a/llvm/test/CodeGen/ARM/fabs-to-bfc.ll b/llvm/test/CodeGen/ARM/fabs-to-bfc.ll new file mode 100644 index 000000000000..1a2e04584a91 --- /dev/null +++ b/llvm/test/CodeGen/ARM/fabs-to-bfc.ll @@ -0,0 +1,14 @@ +; RUN: llc < %s -mtriple=armv5e-none-linux-gnueabi -mattr=+vfp2 | FileCheck %s -check-prefix=CHECK-VABS +; RUN: llc < %s -mtriple=armv7-none-linux-gnueabi -mattr=+vfp3 | FileCheck %s -check-prefix=CHECK-BFC + + +define double @test(double %tx) { +;CHECK-LABEL: test: + %call = tail call double @fabs(double %tx) + ret double %call +;CHECK-VABS: vabs.f64 +;CHECK-BFC: bfc +} + +declare double @fabs(double) readnone +