summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-11-16 10:49:25 +0000
committerJames Molloy <james.molloy@arm.com>2015-11-16 10:49:25 +0000
commit2018091e8741b00ddcb0df2351174d26ecb0fbaf (patch)
tree249fa71d770add7d9759ff8c727f89058db3ddde /llvm/lib/Target
parent978060ce2f70a9fb8f7c0d4203d5172980f9c8ea (diff)
downloadbcm5719-llvm-2018091e8741b00ddcb0df2351174d26ecb0fbaf.tar.gz
bcm5719-llvm-2018091e8741b00ddcb0df2351174d26ecb0fbaf.zip
Properly check if a CMPZ node is in fact comparing against zero
This was left implicit and never ever checked, which means we could have a CMPZ against some non-zero value and we were carrying on with BFI conversion regardless. Caught by Oliver Stannard using csmith; regression test added. llvm-svn: 253195
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 51f8d562fe1..3c99675a473 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -10398,6 +10398,12 @@ SDValue ARMTargetLowering::PerformCMOVToBFICombine(SDNode *CMOV, SelectionDAG &D
auto CC = CCNode->getAPIntValue().getLimitedValue();
SDValue CmpZ = CMOV->getOperand(4);
+ // The compare must be against zero.
+ SDValue Zero = CmpZ->getOperand(1);
+ if (!isa<ConstantSDNode>(Zero.getNode()) ||
+ !cast<ConstantSDNode>(Zero.getNode())->isNullValue())
+ return SDValue();
+
assert(CmpZ->getOpcode() == ARMISD::CMPZ);
SDValue And = CmpZ->getOperand(0);
if (And->getOpcode() != ISD::AND)
OpenPOWER on IntegriCloud