[llvm] r220486 - Do not emit intermediate register for zero FP immediate
Renato Golin
renato.golin at linaro.org
Thu Oct 23 08:31:51 PDT 2014
Author: rengolin
Date: Thu Oct 23 10:31:50 2014
New Revision: 220486
URL: http://llvm.org/viewvc/llvm-project?rev=220486&view=rev
Log:
Do not emit intermediate register for zero FP immediate
This updates check for double precision zero floating point constant to allow
use of instruction with immediate value rather than temporary register.
Currently "a == 0.0", where "a" is of "double" type generates:
vmov.i32 d16, #0x0
vcmpe.f64 d0, d16
With this change it becomes:
vcmpe.f64 d0, #0
Patch by Sergey Dmitrouk.
Added:
llvm/trunk/test/CodeGen/ARM/fpcmp-f64-neon-opt.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=220486&r1=220485&r2=220486&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Oct 23 10:31:50 2014
@@ -3245,6 +3245,18 @@ static bool isFloatingPointZero(SDValue
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CP->getConstVal()))
return CFP->getValueAPF().isPosZero();
}
+ } else if (Op->getOpcode() == ISD::BITCAST &&
+ Op->getValueType(0) == MVT::f64) {
+ // Handle (ISD::BITCAST (ARMISD::VMOVIMM (ISD::TargetConstant 0)) MVT::f64)
+ // created by LowerConstantFP().
+ SDValue BitcastOp = Op->getOperand(0);
+ if (BitcastOp->getOpcode() == ARMISD::VMOVIMM) {
+ SDValue MoveOp = BitcastOp->getOperand(0);
+ if (MoveOp->getOpcode() == ISD::TargetConstant &&
+ cast<ConstantSDNode>(MoveOp)->getZExtValue() == 0) {
+ return true;
+ }
+ }
}
return false;
}
Added: llvm/trunk/test/CodeGen/ARM/fpcmp-f64-neon-opt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fpcmp-f64-neon-opt.ll?rev=220486&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fpcmp-f64-neon-opt.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/fpcmp-f64-neon-opt.ll Thu Oct 23 10:31:50 2014
@@ -0,0 +1,12 @@
+; RUN: llc -mtriple=linux-arm-gnueabihf -mattr=+neon %s -o - | FileCheck %s
+
+; Check that no intermediate integer register is used.
+define i32 @no-intermediate-register-for-zero-imm(double %x) #0 {
+entry:
+; CHECK-LABEL: no-intermediate-register-for-zero-imm
+; CHECK-NOT: vmov
+; CHECK: vcmp
+ %cmp = fcmp une double %x, 0.000000e+00
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
More information about the llvm-commits
mailing list