summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-23 22:10:33 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-23 22:10:33 +0000
commit2056d15bd917bb025c16cf7517c2eecc3d1df392 (patch)
tree95cd51c08707a2ac36762a78ecb1b6c3fcf8be88
parent27f58c2e66dc0c26d887f6552993a328201f0da0 (diff)
downloadbcm5719-llvm-2056d15bd917bb025c16cf7517c2eecc3d1df392.tar.gz
bcm5719-llvm-2056d15bd917bb025c16cf7517c2eecc3d1df392.zip
Also match negative offsets for addrmode3 and addrmode5.
Math is hard, and isScaledConstantInRange() always returned false for negative constants. It was doing unsigned division of negative numbers before casting back to signed. llvm-svn: 140425
-rw-r--r--llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp4
-rw-r--r--llvm/test/CodeGen/ARM/fpmem.ll18
2 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
index e05589eb5ba..66fc754dd01 100644
--- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -305,10 +305,10 @@ static bool isOpcWithIntImmediate(SDNode *N, unsigned Opc, unsigned& Imm) {
/// (N * Scale) where (N in [\arg RangeMin, \arg RangeMax).
///
/// \param ScaledConstant [out] - On success, the pre-scaled constant value.
-static bool isScaledConstantInRange(SDValue Node, unsigned Scale,
+static bool isScaledConstantInRange(SDValue Node, int Scale,
int RangeMin, int RangeMax,
int &ScaledConstant) {
- assert(Scale && "Invalid scale!");
+ assert(Scale > 0 && "Invalid scale!");
// Check that this is a constant.
const ConstantSDNode *C = dyn_cast<ConstantSDNode>(Node);
diff --git a/llvm/test/CodeGen/ARM/fpmem.ll b/llvm/test/CodeGen/ARM/fpmem.ll
index c3cff18c959..38339334b44 100644
--- a/llvm/test/CodeGen/ARM/fpmem.ll
+++ b/llvm/test/CodeGen/ARM/fpmem.ll
@@ -14,6 +14,24 @@ define float @f2(float* %v, float %u) {
ret float %tmp1
}
+define float @f2offset(float* %v, float %u) {
+; CHECK: f2offset:
+; CHECK: vldr.32{{.*}}, #4]
+ %addr = getelementptr float* %v, i32 1
+ %tmp = load float* %addr
+ %tmp1 = fadd float %tmp, %u
+ ret float %tmp1
+}
+
+define float @f2noffset(float* %v, float %u) {
+; CHECK: f2noffset:
+; CHECK: vldr.32{{.*}}, #-4]
+ %addr = getelementptr float* %v, i32 -1
+ %tmp = load float* %addr
+ %tmp1 = fadd float %tmp, %u
+ ret float %tmp1
+}
+
define void @f3(float %a, float %b, float* %v) {
; CHECK: f3:
; CHECK: vstr.32{{.*}}[
OpenPOWER on IntegriCloud