Make FastEmit_ri_ try a bit harder to succeed for supported operations; FastEmit_i...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 29 Apr 2011 23:34:52 +0000 (23:34 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 29 Apr 2011 23:34:52 +0000 (23:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130560 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/FastISel.cpp
test/CodeGen/ARM/fast-isel.ll

index 63e869960bf6075f13e5f999e687de190eff64af..3af948288daff533d886504a2280d16591f50544 100644 (file)
@@ -1032,8 +1032,13 @@ unsigned FastISel::FastEmit_ri_(MVT VT, unsigned Opcode,
   if (ResultReg != 0)
     return ResultReg;
   unsigned MaterialReg = FastEmit_i(ImmType, ImmType, ISD::Constant, Imm);
-  if (MaterialReg == 0)
-    return 0;
+  if (MaterialReg == 0) {
+    // This is a bit ugly/slow, but failing here means falling out of
+    // fast-isel, which would be very slow.
+    const IntegerType *ITy = IntegerType::get(FuncInfo.Fn->getContext(),
+                                              VT.getSizeInBits());
+    MaterialReg = getRegForValue(ConstantInt::get(ITy, Imm));
+  }
   return FastEmit_rr(VT, VT, Opcode,
                      Op0, Op0IsKill,
                      MaterialReg, /*Kill=*/true);
index 81be59785955d62627be06469dbd37653993006b..6aad92fbc6a436b61f5fc0a3f730ede50b4d749c 100644 (file)
@@ -38,14 +38,22 @@ define void @test2(i32 %tmp, i32* %ptr) nounwind {
 ; ARM: test2:
 
 b1:
-  %b = add i32 %tmp, 4096
-  store i32 %b, i32* %ptr
+  %a = add i32 %tmp, 4096
+  store i32 %a, i32* %ptr
   br label %b2
 
 ; THUMB: add.w {{.*}} #4096
 ; ARM: add {{.*}} #1, #20
 
 b2:
+  %b = add i32 %tmp, 4095
+  store i32 %b, i32* %ptr
+  br label %b3
+; THUMB: addw {{.*}} #4095
+; ARM: movw {{.*}} #4095
+; ARM: add
+
+b3:
   %c = or i32 %tmp, 4
   store i32 %c, i32* %ptr
   ret void