Run codegen dce pass for all targets at all optimization levels. Previously it's
authorEvan Cheng <evan.cheng@apple.com>
Sat, 6 Feb 2010 09:07:11 +0000 (09:07 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sat, 6 Feb 2010 09:07:11 +0000 (09:07 +0000)
only run for x86 with fastisel. I've found it being very effective in
eliminating some obvious dead code as result of formal parameter lowering
especially when tail call optimization eliminated the need for some of the loads
from fixed frame objects. It also shrinks a number of the tests. A couple of
tests no longer make sense and are now eliminated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95493 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
lib/CodeGen/DeadMachineInstructionElim.cpp
lib/CodeGen/LLVMTargetMachine.cpp
lib/CodeGen/LiveIntervalAnalysis.cpp
lib/Target/X86/X86TargetMachine.cpp
test/CodeGen/ARM/2009-10-30.ll
test/CodeGen/ARM/long_shift.ll
test/CodeGen/ARM/remat-2.ll [deleted file]
test/CodeGen/ARM/remat.ll
test/CodeGen/X86/2007-11-30-TestLoadFolding.ll [deleted file]
test/CodeGen/X86/2009-09-10-LoadFoldingBug.ll
test/CodeGen/X86/codegen-dce.ll [new file with mode: 0644]
test/CodeGen/X86/convert-2-addr-3-addr-inc64.ll
test/CodeGen/X86/ins_subreg_coalesce-3.ll
test/CodeGen/X86/sext-i1.ll
test/CodeGen/X86/sse3.ll
test/CodeGen/X86/tailcall2.ll
test/CodeGen/X86/twoaddr-delete.ll [deleted file]

index 9d7ec06ac972e7e3d574648825a3e2aae7ebdabb..a0544d07babb4e3c8094b0bf79e69350a0d2be4f 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "codegen-dce"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Pass.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
+STATISTIC(NumDeletes,          "Number of dead instructions deleted");
+
 namespace {
   class DeadMachineInstructionElim : public MachineFunctionPass {
     virtual bool runOnMachineFunction(MachineFunction &MF);
@@ -126,6 +130,7 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
         DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI);
         AnyChanges = true;
         MI->eraseFromParent();
+        ++NumDeletes;
         MIE = MBB->rend();
         // MII is now pointing to the next instruction to process,
         // so don't increment it.
index c03e4290cabdbab402b52ff4596f5d18c1cca246..40e015067f47e5522d37056782ce9cf7820f2056 100644 (file)
@@ -291,6 +291,12 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
   printAndVerify(PM, "After Instruction Selection",
                  /* allowDoubleDefs= */ true);
 
+
+  // Delete dead machine instructions regardless of optimization level.
+  PM.add(createDeadMachineInstructionElimPass());
+  printAndVerify(PM, "After codegen DCE pass",
+                 /* allowDoubleDefs= */ true);
+
   if (OptLevel != CodeGenOpt::None) {
     PM.add(createOptimizeExtsPass());
     if (!DisableMachineLICM)
index 8746bf908659c0cb6d66fc1e85b3d74d4e940a7d..c52156ad207ef1f821961bcf2d274b0b4600941d 100644 (file)
@@ -671,6 +671,9 @@ void LiveIntervals::computeIntervals() {
   for (MachineFunction::iterator MBBI = mf_->begin(), E = mf_->end();
        MBBI != E; ++MBBI) {
     MachineBasicBlock *MBB = MBBI;
+    if (MBB->empty())
+      continue;
+
     // Track the index of the current machine instr.
     SlotIndex MIIndex = getMBBStartIdx(MBB);
     DEBUG(dbgs() << MBB->getName() << ":\n");
index 2e7febcdbb3e2189200c2442125eb1744ed53c06..f835e295e6e08644271e6d819c7b0b950e07d5a5 100644 (file)
@@ -148,10 +148,6 @@ bool X86TargetMachine::addInstSelector(PassManagerBase &PM,
   // Install an instruction selector.
   PM.add(createX86ISelDag(*this, OptLevel));
 
-  // If we're using Fast-ISel, clean up the mess.
-  if (EnableFastISel)
-    PM.add(createDeadMachineInstructionElimPass());
-
   // Install a pass to insert x87 FP_REG_KILL instructions, as needed.
   PM.add(createX87FPRegKillInserterPass());
 
index 82563869bd96866ffec133f8ba888277e8538f55..90a5bd2a75798c2eb38d1da4b41bc4ace2cd59b8 100644 (file)
@@ -5,8 +5,8 @@
 define void @f(i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, ...) {
 entry:
 ;CHECK: sub    sp, sp, #4
-;CHECK: add    r0, sp, #8
-;CHECK: str    r0, [sp], #+4
+;CHECK: add    r{{[0-9]+}}, sp, #8
+;CHECK: str    r{{[0-9]+}}, [sp], #+4
 ;CHECK: bx     lr
        %ap = alloca i8*, align 4
        %ap1 = bitcast i8** %ap to i8*
index 688b7bc312c7b10b62b7f976867a82edebadc448..76332cc290ccf48664937fee7b06c8a40f49f2c7 100644 (file)
@@ -23,10 +23,10 @@ define i32 @f1(i64 %x, i64 %y) {
 define i32 @f2(i64 %x, i64 %y) {
 ; CHECK: f2
 ; CHECK:      mov     r0, r0, lsr r2
-; CHECK-NEXT: rsb     r3, r2, #32
+; CHECK-NEXT: rsb     r12, r2, #32
 ; CHECK-NEXT: sub     r2, r2, #32
 ; CHECK-NEXT: cmp     r2, #0
-; CHECK-NEXT: orr     r0, r0, r1, lsl r3
+; CHECK-NEXT: orr     r0, r0, r1, lsl r12
 ; CHECK-NEXT: movge   r0, r1, asr r2
        %a = ashr i64 %x, %y
        %b = trunc i64 %a to i32
@@ -36,10 +36,10 @@ define i32 @f2(i64 %x, i64 %y) {
 define i32 @f3(i64 %x, i64 %y) {
 ; CHECK: f3
 ; CHECK:      mov     r0, r0, lsr r2
-; CHECK-NEXT: rsb     r3, r2, #32
+; CHECK-NEXT: rsb     r12, r2, #32
 ; CHECK-NEXT: sub     r2, r2, #32
 ; CHECK-NEXT: cmp     r2, #0
-; CHECK-NEXT: orr     r0, r0, r1, lsl r3
+; CHECK-NEXT: orr     r0, r0, r1, lsl r12
 ; CHECK-NEXT: movge   r0, r1, lsr r2
        %a = lshr i64 %x, %y
        %b = trunc i64 %a to i32
diff --git a/test/CodeGen/ARM/remat-2.ll b/test/CodeGen/ARM/remat-2.ll
deleted file mode 100644 (file)
index 1a871d2..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-; RUN: llc < %s -march=arm -mattr=+v6,+vfp2 -stats -info-output-file - | grep "Number of re-materialization"
-
-define arm_apcscc i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
-entry:
-  br i1 undef, label %smvp.exit, label %bb.i3
-
-bb.i3:                                            ; preds = %bb.i3, %bb134
-  br i1 undef, label %smvp.exit, label %bb.i3
-
-smvp.exit:                                        ; preds = %bb.i3
-  %0 = fmul double undef, 2.400000e-03            ; <double> [#uses=2]
-  br i1 undef, label %bb138.preheader, label %bb159
-
-bb138.preheader:                                  ; preds = %smvp.exit
-  br label %bb138
-
-bb138:                                            ; preds = %bb138, %bb138.preheader
-  br i1 undef, label %bb138, label %bb145.loopexit
-
-bb142:                                            ; preds = %bb.nph218.bb.nph218.split_crit_edge, %phi0.exit
-  %1 = fmul double undef, -1.200000e-03           ; <double> [#uses=1]
-  %2 = fadd double undef, %1                      ; <double> [#uses=1]
-  %3 = fmul double %2, undef                      ; <double> [#uses=1]
-  %4 = fsub double 0.000000e+00, %3               ; <double> [#uses=1]
-  br i1 %14, label %phi1.exit, label %bb.i35
-
-bb.i35:                                           ; preds = %bb142
-  %5 = call arm_apcscc  double @sin(double %15) nounwind readonly ; <double> [#uses=1]
-  %6 = fmul double %5, 0x4031740AFA84AD8A         ; <double> [#uses=1]
-  %7 = fsub double 1.000000e+00, undef            ; <double> [#uses=1]
-  %8 = fdiv double %7, 6.000000e-01               ; <double> [#uses=1]
-  br label %phi1.exit
-
-phi1.exit:                                        ; preds = %bb.i35, %bb142
-  %.pn = phi double [ %6, %bb.i35 ], [ 0.000000e+00, %bb142 ] ; <double> [#uses=0]
-  %9 = phi double [ %8, %bb.i35 ], [ 0.000000e+00, %bb142 ] ; <double> [#uses=1]
-  %10 = fmul double undef, %9                     ; <double> [#uses=0]
-  br i1 %14, label %phi0.exit, label %bb.i
-
-bb.i:                                             ; preds = %phi1.exit
-  unreachable
-
-phi0.exit:                                        ; preds = %phi1.exit
-  %11 = fsub double %4, undef                     ; <double> [#uses=1]
-  %12 = fadd double 0.000000e+00, %11             ; <double> [#uses=1]
-  store double %12, double* undef, align 4
-  br label %bb142
-
-bb145.loopexit:                                   ; preds = %bb138
-  br i1 undef, label %bb.nph218.bb.nph218.split_crit_edge, label %bb159
-
-bb.nph218.bb.nph218.split_crit_edge:              ; preds = %bb145.loopexit
-  %13 = fmul double %0, 0x401921FB54442D18        ; <double> [#uses=1]
-  %14 = fcmp ugt double %0, 6.000000e-01          ; <i1> [#uses=2]
-  %15 = fdiv double %13, 6.000000e-01             ; <double> [#uses=1]
-  br label %bb142
-
-bb159:                                            ; preds = %bb145.loopexit, %smvp.exit, %bb134
-  unreachable
-
-bb166:                                            ; preds = %bb127
-  unreachable
-}
-
-declare arm_apcscc double @sin(double) nounwind readonly
index 9565c8bca6b049f8c8c04b5ade170aa9a6f58173..367f782e0ff4d1e3b5c6d8b71caab37ff102dd4b 100644 (file)
-; RUN: llc < %s -mtriple=arm-apple-darwin 
-; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 3
+; RUN: llc < %s -march=arm -mattr=+v6,+vfp2 -stats -info-output-file - | grep "Number of re-materialization"
 
-       %struct.CONTENTBOX = type { i32, i32, i32, i32, i32 }
-       %struct.LOCBOX = type { i32, i32, i32, i32 }
-       %struct.SIDEBOX = type { i32, i32 }
-       %struct.UNCOMBOX = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
-       %struct.cellbox = type { i8*, i32, i32, i32, [9 x i32], i32, i32, i32, i32, i32, i32, i32, double, double, double, double, double, i32, i32, %struct.CONTENTBOX*, %struct.UNCOMBOX*, [8 x %struct.tilebox*], %struct.SIDEBOX* }
-       %struct.termbox = type { %struct.termbox*, i32, i32, i32, i32, i32 }
-       %struct.tilebox = type { %struct.tilebox*, double, double, double, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.termbox*, %struct.LOCBOX* }
-@numcells = external global i32                ; <i32*> [#uses=1]
-@cellarray = external global %struct.cellbox**         ; <%struct.cellbox***> [#uses=1]
-@numBinsY = external global i32                ; <i32*> [#uses=1]
-
-define fastcc void @fixpenal() {
+define arm_apcscc i32 @main(i32 %argc, i8** nocapture %argv, double %d1, double %d2) nounwind {
 entry:
-       %tmp491 = load i32* @numcells, align 4          ; <i32> [#uses=1]
-       %tmp9 = load %struct.cellbox*** @cellarray, align 4             ; <%struct.cellbox**> [#uses=1]
-       %tmp77.i = load i32* @numBinsY, align 4         ; <i32> [#uses=2]
-       br label %bb490
-
-bb8:           ; preds = %bb490, %cond_false428
-  %foo3 = phi i1 [ 0, %bb490 ], [ 1, %cond_false428 ]
-       br i1 %foo3, label %cond_false58.i, label %cond_false.i
-
-cond_false.i:          ; preds = %bb8
-       ret void
-
-cond_false58.i:                ; preds = %bb8
-       %highBinX.0.i = select i1 false, i32 1, i32 0           ; <i32> [#uses=2]
-       br i1 %foo3, label %cond_next85.i, label %cond_false76.i
-
-cond_false76.i:                ; preds = %cond_false58.i
-       ret void
-
-cond_next85.i:         ; preds = %cond_false58.i
-       br i1 %foo3, label %cond_next105.i, label %cond_false98.i
-
-cond_false98.i:                ; preds = %cond_next85.i
-       ret void
-
-cond_next105.i:                ; preds = %cond_next85.i
-       %tmp108.i = icmp eq i32 1, %highBinX.0.i                ; <i1> [#uses=1]
-       %tmp115.i = icmp eq i32 1, %tmp77.i             ; <i1> [#uses=1]
-       %bothcond.i = and i1 %tmp115.i, %tmp108.i               ; <i1> [#uses=1]
-       %storemerge.i = select i1 %bothcond.i, i32 1, i32 0             ; <i32> [#uses=2]
-       br i1 %bothcond.i, label %whoOverlaps.exit, label %bb503.preheader.i
-
-bb503.preheader.i:             ; preds = %bb513.i, %cond_next105.i
-       %i.022.0.i = phi i32 [ %tmp512.i, %bb513.i ], [ 0, %cond_next105.i ]            ; <i32> [#uses=2]
-       %tmp165.i = getelementptr i32*** null, i32 %i.022.0.i           ; <i32***> [#uses=0]
-       br label %bb503.i
-
-bb137.i:               ; preds = %bb503.i
-       br i1 %tmp506.i, label %bb162.i, label %bb148.i
-
-bb148.i:               ; preds = %bb137.i
-       ret void
-
-bb162.i:               ; preds = %bb137.i
-       %tmp49435.i = load i32* null            ; <i32> [#uses=1]
-       br label %bb170.i
-
-bb170.i:               ; preds = %bb491.i, %bb162.i
-       %indvar.i = phi i32 [ %k.032.0.i, %bb491.i ], [ 0, %bb162.i ]           ; <i32> [#uses=2]
-       %k.032.0.i = add i32 %indvar.i, 1               ; <i32> [#uses=2]
-       %tmp173.i = getelementptr i32* null, i32 %k.032.0.i             ; <i32*> [#uses=1]
-       %tmp174.i = load i32* %tmp173.i         ; <i32> [#uses=4]
-       %tmp177.i = icmp eq i32 %tmp174.i, %cell.1              ; <i1> [#uses=1]
-       %tmp184.i = icmp sgt i32 %tmp174.i, %tmp491             ; <i1> [#uses=1]
-       %bothcond = or i1 %tmp177.i, %tmp184.i          ; <i1> [#uses=1]
-       br i1 %bothcond, label %bb491.i, label %cond_next188.i
-
-cond_next188.i:                ; preds = %bb170.i
-       %tmp191.i = getelementptr %struct.cellbox** %tmp9, i32 %tmp174.i                ; <%struct.cellbox**> [#uses=1]
-       %tmp192.i = load %struct.cellbox** %tmp191.i            ; <%struct.cellbox*> [#uses=1]
-       %tmp195.i = icmp eq i32 %tmp174.i, 0            ; <i1> [#uses=1]
-       br i1 %tmp195.i, label %bb491.i, label %cond_true198.i
-
-cond_true198.i:                ; preds = %cond_next188.i
-       %tmp210.i = getelementptr %struct.cellbox* %tmp192.i, i32 0, i32 3              ; <i32*> [#uses=0]
-       ret void
-
-bb491.i:               ; preds = %cond_next188.i, %bb170.i
-       %tmp490.i = add i32 %indvar.i, 2                ; <i32> [#uses=1]
-       %tmp496.i = icmp slt i32 %tmp49435.i, %tmp490.i         ; <i1> [#uses=1]
-       br i1 %tmp496.i, label %bb500.i, label %bb170.i
-
-bb500.i:               ; preds = %bb491.i
-       %indvar.next82.i = add i32 %j.0.i, 1            ; <i32> [#uses=1]
-       br label %bb503.i
-
-bb503.i:               ; preds = %bb500.i, %bb503.preheader.i
-       %j.0.i = phi i32 [ 0, %bb503.preheader.i ], [ %indvar.next82.i, %bb500.i ]              ; <i32> [#uses=2]
-       %tmp506.i = icmp sgt i32 %j.0.i, %tmp77.i               ; <i1> [#uses=1]
-       br i1 %tmp506.i, label %bb513.i, label %bb137.i
-
-bb513.i:               ; preds = %bb503.i
-       %tmp512.i = add i32 %i.022.0.i, 1               ; <i32> [#uses=2]
-       %tmp516.i = icmp sgt i32 %tmp512.i, %highBinX.0.i               ; <i1> [#uses=1]
-       br i1 %tmp516.i, label %whoOverlaps.exit, label %bb503.preheader.i
-
-whoOverlaps.exit:              ; preds = %bb513.i, %cond_next105.i
-  %foo = phi i1 [ 1, %bb513.i], [0, %cond_next105.i]
-       br i1 %foo, label %cond_false428, label %bb490
-
-cond_false428:         ; preds = %whoOverlaps.exit
-       br i1 %foo, label %bb497, label %bb8
-
-bb490:         ; preds = %whoOverlaps.exit, %entry
-       %binY.tmp.2 = phi i32 [ 0, %entry ], [ %storemerge.i, %whoOverlaps.exit ]               ; <i32> [#uses=1]
-       %cell.1 = phi i32 [ 1, %entry ], [ 0, %whoOverlaps.exit ]               ; <i32> [#uses=1]
-       %foo2 = phi i1 [ 1, %entry], [0, %whoOverlaps.exit]
-       br i1 %foo2, label %bb497, label %bb8
-
-bb497:         ; preds = %bb490, %cond_false428
-       %binY.tmp.3 = phi i32 [ %binY.tmp.2, %bb490 ], [ %storemerge.i, %cond_false428 ]                ; <i32> [#uses=0]
-       ret void
+  br i1 undef, label %smvp.exit, label %bb.i3
+
+bb.i3:                                            ; preds = %bb.i3, %bb134
+  br i1 undef, label %smvp.exit, label %bb.i3
+
+smvp.exit:                                        ; preds = %bb.i3
+  %0 = fmul double %d1, 2.400000e-03            ; <double> [#uses=2]
+  br i1 undef, label %bb138.preheader, label %bb159
+
+bb138.preheader:                                  ; preds = %smvp.exit
+  br label %bb138
+
+bb138:                                            ; preds = %bb138, %bb138.preheader
+  br i1 undef, label %bb138, label %bb145.loopexit
+
+bb142:                                            ; preds = %bb.nph218.bb.nph218.split_crit_edge, %phi0.exit
+  %1 = fmul double %d1, -1.200000e-03           ; <double> [#uses=1]
+  %2 = fadd double %d2, %1                      ; <double> [#uses=1]
+  %3 = fmul double %2, %d2                      ; <double> [#uses=1]
+  %4 = fsub double 0.000000e+00, %3               ; <double> [#uses=1]
+  br i1 %14, label %phi1.exit, label %bb.i35
+
+bb.i35:                                           ; preds = %bb142
+  %5 = call arm_apcscc  double @sin(double %15) nounwind readonly ; <double> [#uses=1]
+  %6 = fmul double %5, 0x4031740AFA84AD8A         ; <double> [#uses=1]
+  %7 = fsub double 1.000000e+00, undef            ; <double> [#uses=1]
+  %8 = fdiv double %7, 6.000000e-01               ; <double> [#uses=1]
+  br label %phi1.exit
+
+phi1.exit:                                        ; preds = %bb.i35, %bb142
+  %.pn = phi double [ %6, %bb.i35 ], [ 0.000000e+00, %bb142 ] ; <double> [#uses=0]
+  %9 = phi double [ %8, %bb.i35 ], [ 0.000000e+00, %bb142 ] ; <double> [#uses=1]
+  %10 = fmul double undef, %9                     ; <double> [#uses=0]
+  br i1 %14, label %phi0.exit, label %bb.i
+
+bb.i:                                             ; preds = %phi1.exit
+  unreachable
+
+phi0.exit:                                        ; preds = %phi1.exit
+  %11 = fsub double %4, undef                     ; <double> [#uses=1]
+  %12 = fadd double 0.000000e+00, %11             ; <double> [#uses=1]
+  store double %12, double* undef, align 4
+  br label %bb142
+
+bb145.loopexit:                                   ; preds = %bb138
+  br i1 undef, label %bb.nph218.bb.nph218.split_crit_edge, label %bb159
+
+bb.nph218.bb.nph218.split_crit_edge:              ; preds = %bb145.loopexit
+  %13 = fmul double %0, 0x401921FB54442D18        ; <double> [#uses=1]
+  %14 = fcmp ugt double %0, 6.000000e-01          ; <i1> [#uses=2]
+  %15 = fdiv double %13, 6.000000e-01             ; <double> [#uses=1]
+  br label %bb142
+
+bb159:                                            ; preds = %bb145.loopexit, %smvp.exit, %bb134
+  unreachable
+
+bb166:                                            ; preds = %bb127
+  unreachable
 }
+
+declare arm_apcscc double @sin(double) nounwind readonly
diff --git a/test/CodeGen/X86/2007-11-30-TestLoadFolding.ll b/test/CodeGen/X86/2007-11-30-TestLoadFolding.ll
deleted file mode 100644 (file)
index debb461..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-; RUN: llc < %s -march=x86 -stats |& \
-; RUN:   grep {1 .*folded into instructions}
-; RUN: llc < %s -march=x86 | grep cmp | count 4
-
-       %struct.quad_struct = type { i32, i32, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct* }
-
-define fastcc i32 @perimeter(%struct.quad_struct* %tree, i32 %size) {
-entry:
-       %tree.idx7.val = load %struct.quad_struct** null                ; <%struct.quad_struct*> [#uses=1]
-       %tmp8.i51 = icmp eq %struct.quad_struct* %tree.idx7.val, null           ; <i1> [#uses=2]
-       br i1 %tmp8.i51, label %cond_next, label %cond_next.i52
-
-cond_next.i52:         ; preds = %entry
-       ret i32 0
-
-cond_next:             ; preds = %entry
-       %tmp59 = load i32* null, align 4                ; <i32> [#uses=1]
-       %tmp70 = icmp eq i32 %tmp59, 2          ; <i1> [#uses=1]
-       br i1 %tmp70, label %cond_true.i35, label %bb80
-
-cond_true.i35:         ; preds = %cond_next
-       %tmp14.i.i37 = load %struct.quad_struct** null, align 4         ; <%struct.quad_struct*> [#uses=1]
-       %tmp3.i160 = load i32* null, align 4            ; <i32> [#uses=1]
-       %tmp4.i161 = icmp eq i32 %tmp3.i160, 2          ; <i1> [#uses=1]
-       br i1 %tmp4.i161, label %cond_true.i163, label %cond_false.i178
-
-cond_true.i163:                ; preds = %cond_true.i35
-       %tmp7.i162 = sdiv i32 %size, 4          ; <i32> [#uses=2]
-       %tmp13.i168 = tail call fastcc i32 @sum_adjacent( %struct.quad_struct* null, i32 3, i32 2, i32 %tmp7.i162 )             ; <i32> [#uses=1]
-       %tmp18.i11.i170 = getelementptr %struct.quad_struct* %tmp14.i.i37, i32 0, i32 4         ; <%struct.quad_struct**> [#uses=1]
-       %tmp19.i12.i171 = load %struct.quad_struct** %tmp18.i11.i170, align 4           ; <%struct.quad_struct*> [#uses=1]
-       %tmp21.i173 = tail call fastcc i32 @sum_adjacent( %struct.quad_struct* %tmp19.i12.i171, i32 3, i32 2, i32 %tmp7.i162 )          ; <i32> [#uses=1]
-       %tmp22.i174 = add i32 %tmp21.i173, %tmp13.i168          ; <i32> [#uses=1]
-       br i1 %tmp4.i161, label %cond_true.i141, label %cond_false.i156
-
-cond_false.i178:               ; preds = %cond_true.i35
-       ret i32 0
-
-cond_true.i141:                ; preds = %cond_true.i163
-       %tmp7.i140 = sdiv i32 %size, 4          ; <i32> [#uses=1]
-       %tmp21.i151 = tail call fastcc i32 @sum_adjacent( %struct.quad_struct* null, i32 3, i32 2, i32 %tmp7.i140 )             ; <i32> [#uses=0]
-       ret i32 0
-
-cond_false.i156:               ; preds = %cond_true.i163
-       %tmp22.i44 = add i32 0, %tmp22.i174             ; <i32> [#uses=0]
-       br i1 %tmp8.i51, label %bb22.i, label %cond_next.i
-
-bb80:          ; preds = %cond_next
-       ret i32 0
-
-cond_next.i:           ; preds = %cond_false.i156
-       ret i32 0
-
-bb22.i:                ; preds = %cond_false.i156
-       ret i32 0
-}
-
-declare fastcc i32 @sum_adjacent(%struct.quad_struct*, i32, i32, i32)
index 9e58872b73c8583c894bd65c968271440a211781..7b5e871246c1f95b315183477b477d8d1d545576 100644 (file)
@@ -13,7 +13,6 @@ define i32 @t(i32 %clientPort, i32 %pluginID, i32 %requestID, i32 %objectID, i64
 entry:
 ; CHECK: _t:
 ; CHECK: movl 16(%rbp),
-; CHECK: movl 16(%rbp), %edx
   %0 = zext i32 %argumentsLength to i64           ; <i64> [#uses=1]
   %1 = zext i32 %clientPort to i64                ; <i64> [#uses=1]
   %2 = inttoptr i64 %1 to %struct.ComplexType*    ; <%struct.ComplexType*> [#uses=1]
diff --git a/test/CodeGen/X86/codegen-dce.ll b/test/CodeGen/X86/codegen-dce.ll
new file mode 100644 (file)
index 0000000..d83efaf
--- /dev/null
@@ -0,0 +1,43 @@
+; RUN: llc < %s -march=x86 -stats |& grep {codegen-dce} | grep {Number of dead instructions deleted}
+
+       %struct.anon = type { [3 x double], double, %struct.node*, [64 x %struct.bnode*], [64 x %struct.bnode*] }
+       %struct.bnode = type { i16, double, [3 x double], i32, i32, [3 x double], [3 x double], [3 x double], double, %struct.bnode*, %struct.bnode* }
+       %struct.node = type { i16, double, [3 x double], i32, i32 }
+
+define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
+entry:
+       %0 = malloc %struct.anon                ; <%struct.anon*> [#uses=2]
+       %1 = getelementptr %struct.anon* %0, i32 0, i32 2               ; <%struct.node**> [#uses=1]
+       br label %bb14.i
+
+bb14.i:                ; preds = %bb14.i, %entry
+       %i8.0.reg2mem.0.i = phi i32 [ 0, %entry ], [ %2, %bb14.i ]              ; <i32> [#uses=1]
+       %2 = add i32 %i8.0.reg2mem.0.i, 1               ; <i32> [#uses=2]
+       %exitcond74.i = icmp eq i32 %2, 32              ; <i1> [#uses=1]
+       br i1 %exitcond74.i, label %bb32.i, label %bb14.i
+
+bb32.i:                ; preds = %bb32.i, %bb14.i
+       %tmp.0.reg2mem.0.i = phi i32 [ %indvar.next63.i, %bb32.i ], [ 0, %bb14.i ]              ; <i32> [#uses=1]
+       %indvar.next63.i = add i32 %tmp.0.reg2mem.0.i, 1                ; <i32> [#uses=2]
+       %exitcond64.i = icmp eq i32 %indvar.next63.i, 64                ; <i1> [#uses=1]
+       br i1 %exitcond64.i, label %bb47.loopexit.i, label %bb32.i
+
+bb.i.i:                ; preds = %bb47.loopexit.i
+       unreachable
+
+stepsystem.exit.i:             ; preds = %bb47.loopexit.i
+       store %struct.node* null, %struct.node** %1, align 4
+       br label %bb.i6.i
+
+bb.i6.i:               ; preds = %bb.i6.i, %stepsystem.exit.i
+       br i1 false, label %bb107.i.i, label %bb.i6.i
+
+bb107.i.i:             ; preds = %bb107.i.i, %bb.i6.i
+       %q_addr.0.i.i.in = phi %struct.bnode** [ null, %bb107.i.i ], [ %3, %bb.i6.i ]           ; <%struct.bnode**> [#uses=0]
+       br label %bb107.i.i
+
+bb47.loopexit.i:               ; preds = %bb32.i
+       %3 = getelementptr %struct.anon* %0, i32 0, i32 4, i32 0                ; <%struct.bnode**> [#uses=1]
+       %4 = icmp eq %struct.node* null, null           ; <i1> [#uses=1]
+       br i1 %4, label %stepsystem.exit.i, label %bb.i.i
+}
index 337f1b2a8e75fdaacc546fdafc45ff6e80d80ac9..8e38fe309f7c5e0b1a57c9f67eb5f9b4d01980e4 100644 (file)
@@ -1,19 +1,20 @@
 ; RUN: llc < %s -march=x86-64 -o %t -stats -info-output-file - | \
-; RUN:   grep {asm-printer} | grep {Number of machine instrs printed} | grep 5
+; RUN:   grep {asm-printer} | grep {Number of machine instrs printed} | grep 10
 ; RUN: grep {leal      1(\%rsi),} %t
 
-define fastcc zeroext i8 @fullGtU(i32 %i1, i32 %i2) nounwind optsize {
+define fastcc zeroext i8 @fullGtU(i32 %i1, i32 %i2, i8* %ptr) nounwind optsize {
 entry:
   %0 = add i32 %i2, 1           ; <i32> [#uses=1]
   %1 = sext i32 %0 to i64               ; <i64> [#uses=1]
-  %2 = getelementptr i8* null, i64 %1           ; <i8*> [#uses=1]
+  %2 = getelementptr i8* %ptr, i64 %1           ; <i8*> [#uses=1]
   %3 = load i8* %2, align 1             ; <i8> [#uses=1]
   %4 = icmp eq i8 0, %3         ; <i1> [#uses=1]
   br i1 %4, label %bb3, label %bb34
 
 bb3:            ; preds = %entry
   %5 = add i32 %i2, 4           ; <i32> [#uses=0]
-  ret i8 0
+  %6 = trunc i32 %5 to i8
+  ret i8 %6
 
 bb34:           ; preds = %entry
   ret i8 0
index e44308583297cecd8cc10e8454b106e98f6bfad3..627edc51c18d761a25e981974a48425e422951ee 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=x86-64 | grep mov | count 11
+; RUN: llc < %s -march=x86-64 | grep mov | count 5
 
        %struct.COMPOSITE = type { i8, i16, i16 }
        %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
index 4f88c7c9237d03e216eb18928876fa04a6d762f5..21c418d534e9168b9f5e2fd11df8255e80fdb64b 100644 (file)
@@ -44,9 +44,9 @@ entry:
 
 ; 64: t3:
 ; 64: cmpl $1
-; 64: sbbl
-; 64: cmpl
 ; 64: sbbq
+; 64: cmpq
+; 64: xorl
   %not.tobool = icmp eq i32 undef, 0              ; <i1> [#uses=2]
   %cond = sext i1 %not.tobool to i32              ; <i32> [#uses=1]
   %conv = sext i1 %not.tobool to i64              ; <i64> [#uses=1]
index 5550d263389acc91b7d8568ddeb938a93d7ace4f..b2af7c947d98125c4af9e755ae1b2c266a43c14a 100644 (file)
@@ -63,10 +63,10 @@ define <8 x i16> @t4(<8 x i16> %A, <8 x i16> %B) nounwind {
        ret <8 x i16> %tmp
 ; X64: t4:
 ; X64:         pextrw  $7, %xmm0, %eax
-; X64:         pshufhw $100, %xmm0, %xmm1
-; X64:         pinsrw  $1, %eax, %xmm1
+; X64:         pshufhw $100, %xmm0, %xmm2
+; X64:         pinsrw  $1, %eax, %xmm2
 ; X64:         pextrw  $1, %xmm0, %eax
-; X64:         movaps  %xmm1, %xmm0
+; X64:         movaps  %xmm2, %xmm0
 ; X64:         pinsrw  $4, %eax, %xmm0
 ; X64:         ret
 }
index 02bf0c00b43239dece2222e56938e88e3b11122f..80bab619c16f71bfebfa11695c9e424d0eb57aba 100644 (file)
@@ -147,6 +147,8 @@ define i32 @t11(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind ssp {
 
 ; 32: t11:
 ; 32-NOT: subl ${{[0-9]+}}, %esp
+; 32: jne
+; 32-NOT: movl
 ; 32-NOT: addl ${{[0-9]+}}, %esp
 ; 32: jmp {{_?}}foo5
 
diff --git a/test/CodeGen/X86/twoaddr-delete.ll b/test/CodeGen/X86/twoaddr-delete.ll
deleted file mode 100644 (file)
index 77e3c75..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-; RUN: llc < %s -march=x86 -stats |& grep {twoaddrinstr} | grep {Number of dead instructions deleted}
-
-       %struct.anon = type { [3 x double], double, %struct.node*, [64 x %struct.bnode*], [64 x %struct.bnode*] }
-       %struct.bnode = type { i16, double, [3 x double], i32, i32, [3 x double], [3 x double], [3 x double], double, %struct.bnode*, %struct.bnode* }
-       %struct.node = type { i16, double, [3 x double], i32, i32 }
-
-define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
-entry:
-       %0 = malloc %struct.anon                ; <%struct.anon*> [#uses=2]
-       %1 = getelementptr %struct.anon* %0, i32 0, i32 2               ; <%struct.node**> [#uses=1]
-       br label %bb14.i
-
-bb14.i:                ; preds = %bb14.i, %entry
-       %i8.0.reg2mem.0.i = phi i32 [ 0, %entry ], [ %2, %bb14.i ]              ; <i32> [#uses=1]
-       %2 = add i32 %i8.0.reg2mem.0.i, 1               ; <i32> [#uses=2]
-       %exitcond74.i = icmp eq i32 %2, 32              ; <i1> [#uses=1]
-       br i1 %exitcond74.i, label %bb32.i, label %bb14.i
-
-bb32.i:                ; preds = %bb32.i, %bb14.i
-       %tmp.0.reg2mem.0.i = phi i32 [ %indvar.next63.i, %bb32.i ], [ 0, %bb14.i ]              ; <i32> [#uses=1]
-       %indvar.next63.i = add i32 %tmp.0.reg2mem.0.i, 1                ; <i32> [#uses=2]
-       %exitcond64.i = icmp eq i32 %indvar.next63.i, 64                ; <i1> [#uses=1]
-       br i1 %exitcond64.i, label %bb47.loopexit.i, label %bb32.i
-
-bb.i.i:                ; preds = %bb47.loopexit.i
-       unreachable
-
-stepsystem.exit.i:             ; preds = %bb47.loopexit.i
-       store %struct.node* null, %struct.node** %1, align 4
-       br label %bb.i6.i
-
-bb.i6.i:               ; preds = %bb.i6.i, %stepsystem.exit.i
-       br i1 false, label %bb107.i.i, label %bb.i6.i
-
-bb107.i.i:             ; preds = %bb107.i.i, %bb.i6.i
-       %q_addr.0.i.i.in = phi %struct.bnode** [ null, %bb107.i.i ], [ %3, %bb.i6.i ]           ; <%struct.bnode**> [#uses=0]
-       br label %bb107.i.i
-
-bb47.loopexit.i:               ; preds = %bb32.i
-       %3 = getelementptr %struct.anon* %0, i32 0, i32 4, i32 0                ; <%struct.bnode**> [#uses=1]
-       %4 = icmp eq %struct.node* null, null           ; <i1> [#uses=1]
-       br i1 %4, label %stepsystem.exit.i, label %bb.i.i
-}