[llvm-commits] [llvm] r140425 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp test/CodeGen/ARM/fpmem.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Sep 23 15:10:33 PDT 2011


Author: stoklund
Date: Fri Sep 23 17:10:33 2011
New Revision: 140425

URL: http://llvm.org/viewvc/llvm-project?rev=140425&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
    llvm/trunk/test/CodeGen/ARM/fpmem.ll

Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=140425&r1=140424&r2=140425&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Fri Sep 23 17:10:33 2011
@@ -305,10 +305,10 @@
 /// (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);

Modified: llvm/trunk/test/CodeGen/ARM/fpmem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fpmem.ll?rev=140425&r1=140424&r2=140425&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fpmem.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/fpmem.ll Fri Sep 23 17:10:33 2011
@@ -14,6 +14,24 @@
         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{{.*}}[





More information about the llvm-commits mailing list