Index: lib/Target/PowerPC/PPCTargetMachine.cpp =================================================================== --- lib/Target/PowerPC/PPCTargetMachine.cpp +++ lib/Target/PowerPC/PPCTargetMachine.cpp @@ -315,7 +315,7 @@ if (UsePrefetching) addPass(createLoopDataPrefetchPass()); - if (TM->getOptLevel() == CodeGenOpt::Aggressive && EnableGEPOpt) { + if (TM->getOptLevel() >= CodeGenOpt::Default && EnableGEPOpt) { // Call SeparateConstOffsetFromGEP pass to extract constants within indices // and lower a GEP with multiple indices to either arithmetic operations or // multiple GEPs with single index. Index: test/CodeGen/PowerPC/2007-09-07-LoadStoreIdxForms.ll =================================================================== --- test/CodeGen/PowerPC/2007-09-07-LoadStoreIdxForms.ll +++ test/CodeGen/PowerPC/2007-09-07-LoadStoreIdxForms.ll @@ -1,4 +1,5 @@ -; RUN: llc < %s -march=ppc64 | FileCheck %s +; RUN: llc < %s -march=ppc64 -O1 | FileCheck %s +; RUN: llc < %s -march=ppc64 | FileCheck --check-prefix=CHECK-OPT %s %struct.__db_region = type { %struct.__mutex_t, [4 x i8], %struct.anon, i32, [1 x i32] } %struct.__mutex_t = type { i32 } @@ -15,6 +16,24 @@ ; CHECK: @foo ; CHECK: lwzx ; CHECK: blr +; CHECK-OPT: @foo +; CHECK-OPT: lwz +; CHECK-OPT: blr } +define signext i32 @test(i32* noalias nocapture readonly %b, i32 signext %n) { +entry: + %idxprom = sext i32 %n to i64 + %arrayidx = getelementptr inbounds i32, i32* %b, i64 %idxprom + %0 = load i32, i32* %arrayidx, align 4 + %mul = mul nsw i32 %0, 7 + ret i32 %mul + +; CHECK-OPT: @test +; CHECK-OPT: lwzx +; CHECK-OPT: blr + +} + + declare i32 @bork(...) Index: test/CodeGen/PowerPC/ctrloops.ll =================================================================== --- test/CodeGen/PowerPC/ctrloops.ll +++ test/CodeGen/PowerPC/ctrloops.ll @@ -76,23 +76,22 @@ @tls_var = external thread_local global i8 -define i32 @test4() { +define i32 @test4(i32 %inp) { entry: br label %for.body for.body: ; preds = %for.body, %entry - %phi = phi i32 [ %dec, %for.body ], [ undef, %entry ] + %phi = phi i32 [ %dec, %for.body ], [ %inp, %entry ] %load = ptrtoint i8* @tls_var to i32 + %val = add i32 %load, %phi %dec = add i32 %phi, -1 %cmp = icmp sgt i32 %phi, 1 br i1 %cmp, label %for.body, label %return return: ; preds = %for.body - ret i32 %load + ret i32 %val ; CHECK-LABEL: @test4 -; CHECK-NOT: mtctr -; CHECK: addi {{[0-9]+}} -; CHECK: cmpwi -; CHECK-NOT: bdnz -; CHECK: bgt +; CHECK: mtctr +; CHECK: bdnz +; CHECK: __tls_get_addr } Index: test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll =================================================================== --- test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll +++ test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll @@ -2,9 +2,9 @@ target datalayout = "E-m:e-i64:64-n32:64" target triple = "powerpc64-bgq-linux" -define linkonce_odr double @test1() { +define linkonce_odr double @test1(ppc_fp128 %input) { entry: - %conv6.i.i = fptosi ppc_fp128 undef to i64 + %conv6.i.i = fptosi ppc_fp128 %input to i64 %conv.i = sitofp i64 %conv6.i.i to double ret double %conv.i Index: test/CodeGen/PowerPC/lbzux.ll =================================================================== --- test/CodeGen/PowerPC/lbzux.ll +++ test/CodeGen/PowerPC/lbzux.ll @@ -2,7 +2,7 @@ target triple = "powerpc64-unknown-linux-gnu" ; RUN: llc -disable-ppc-unaligned < %s | FileCheck %s -define fastcc void @allocateSpace(i1 %cond1, i1 %cond2) nounwind { +define fastcc void @allocateSpace(i1 %cond1, i1 %cond2, i32 %offset) nounwind { entry: %0 = load i8*, i8** undef, align 8 br i1 undef, label %return, label %lor.lhs.false @@ -19,14 +19,13 @@ while.cond: ; preds = %while.body, %if.then15 %idxprom17 = sext i32 0 to i64 %arrayidx18 = getelementptr inbounds i8, i8* %0, i64 %idxprom17 - %or = or i32 undef, undef br i1 %cond1, label %if.end71, label %while.body while.body: ; preds = %while.cond br i1 %cond2, label %while.cond, label %if.then45 if.then45: ; preds = %while.body - %idxprom48139 = zext i32 %or to i64 + %idxprom48139 = zext i32 %offset to i64 %arrayidx49 = getelementptr inbounds i8, i8* %0, i64 %idxprom48139 %1 = bitcast i8* %arrayidx49 to i16* %2 = bitcast i8* %arrayidx18 to i16* Index: test/CodeGen/PowerPC/lsr-postinc-pos.ll =================================================================== --- test/CodeGen/PowerPC/lsr-postinc-pos.ll +++ test/CodeGen/PowerPC/lsr-postinc-pos.ll @@ -3,27 +3,27 @@ ; The icmp is a post-inc use, and the increment is in %bb11, but the ; scevgep needs to be inserted in %bb so that it is dominated by %t. -; CHECK: %t = load i8*, i8** undef +; CHECK: %t = load i8*, i8** %inp ; CHECK: %scevgep = getelementptr i8, i8* %t, i32 %lsr.iv.next -; CHECK: %c1 = icmp ult i8* %scevgep, undef +; CHECK: %c1 = icmp ult i8* %scevgep, %inp2 target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f128:64:128-n32" target triple = "powerpc-apple-darwin9" -define void @foo() nounwind { +define void @foo(i8** %inp, i8* %inp2) nounwind { entry: br label %bb11 bb11: %i = phi i32 [ 0, %entry ], [ %i.next, %bb ] ; [#uses=3] %ii = shl i32 %i, 2 ; [#uses=1] - %c0 = icmp eq i32 %i, undef ; [#uses=1] + %c0 = icmp eq i32 %i, 0 ; [#uses=1] br i1 %c0, label %bb13, label %bb bb: - %t = load i8*, i8** undef, align 16 ; [#uses=1] + %t = load i8*, i8** %inp, align 16 ; [#uses=1] %p = getelementptr i8, i8* %t, i32 %ii ; [#uses=1] - %c1 = icmp ult i8* %p, undef ; [#uses=1] + %c1 = icmp ult i8* %p, %inp2 ; [#uses=1] %i.next = add i32 %i, 1 ; [#uses=1] br i1 %c1, label %bb11, label %bb13 Index: test/CodeGen/PowerPC/optcmp.ll =================================================================== --- test/CodeGen/PowerPC/optcmp.ll +++ test/CodeGen/PowerPC/optcmp.ll @@ -72,13 +72,13 @@ entry: %sub = sub nsw i64 %b, %a store i64 %sub, i64* %c, align 8 - %cmp = icmp eq i64 %a, %b + %cmp = icmp slt i64 %a, %b %cond = select i1 %cmp, i64 %a, i64 %b ret i64 %cond ; CHECK: @foold ; CHECK: subf. [[REG:[0-9]+]], 3, 4 -; CHECK: isel 3, 3, 4, 2 +; CHECK: isel 3, 3, 4, 1 ; CHECK: std [[REG]], 0(5) } @@ -86,13 +86,13 @@ entry: %sub = sub nsw i64 %a, %b store i64 %sub, i64* %c, align 8 - %cmp = icmp eq i64 %a, %b + %cmp = icmp slt i64 %a, %b %cond = select i1 %cmp, i64 %a, i64 %b ret i64 %cond ; CHECK: @foold2 ; CHECK: subf. [[REG:[0-9]+]], 4, 3 -; CHECK: isel 3, 3, 4, 2 +; CHECK: isel 3, 3, 4, 0 ; CHECK: std [[REG]], 0(5) } Index: test/CodeGen/PowerPC/ppc64-calls.ll =================================================================== --- test/CodeGen/PowerPC/ppc64-calls.ll +++ test/CodeGen/PowerPC/ppc64-calls.ll @@ -2,7 +2,8 @@ target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64" target triple = "powerpc64-unknown-linux-gnu" -define void @foo() nounwind readnone noinline { + +define void @foo() nounwind noinline { ret void } Index: test/CodeGen/PowerPC/preincprep-invoke.ll =================================================================== --- test/CodeGen/PowerPC/preincprep-invoke.ll +++ test/CodeGen/PowerPC/preincprep-invoke.ll @@ -11,12 +11,12 @@ declare i32 @__gxx_personality_v0(...) -define void @_Z11GetPasswordP13CStdOutStreamb() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { +define void @_Z11GetPasswordP13CStdOutStreamb(i1 %cond, i8 %arg1, i8* %arg2) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: br label %for.cond.i.i for.cond.i.i: ; preds = %for.cond.i.i, %entry - br i1 undef, label %_ZN11CStringBaseIcEC2EPKc.exit.critedge, label %for.cond.i.i + br i1 %cond, label %_ZN11CStringBaseIcEC2EPKc.exit.critedge, label %for.cond.i.i _ZN11CStringBaseIcEC2EPKc.exit.critedge: ; preds = %for.cond.i.i invoke void @_ZN13CStdOutStreamlsEPKc() @@ -37,11 +37,13 @@ %indvars.iv.i.i26 = phi i64 [ %indvars.iv.next.i.i29, %for.cond.i.i30 ], [ 0, %invoke.cont4 ] %arrayidx.i.i27 = getelementptr inbounds i8, i8* %call7, i64 %indvars.iv.i.i26 %0 = load i8, i8* %arrayidx.i.i27, align 1 + %1 = add i8 %0, %arg1 + store i8 %1, i8* %arg2, align 1 %indvars.iv.next.i.i29 = add nuw nsw i64 %indvars.iv.i.i26, 1 br label %for.cond.i.i30 lpad: ; preds = %invoke.cont4, %invoke.cont, %_ZN11CStringBaseIcEC2EPKc.exit.critedge - %1 = landingpad { i8*, i32 } + %2 = landingpad { i8*, i32 } cleanup resume { i8*, i32 } undef } Index: test/CodeGen/PowerPC/stwux.ll =================================================================== --- test/CodeGen/PowerPC/stwux.ll +++ test/CodeGen/PowerPC/stwux.ll @@ -4,7 +4,7 @@ @multvec_i = external unnamed_addr global [100 x i32], align 4 -define fastcc void @subs_STMultiExceptIntern() nounwind { +define fastcc void @subs_STMultiExceptIntern(i32 %input) nounwind { entry: br i1 undef, label %while.body.lr.ph, label %return @@ -16,10 +16,11 @@ br i1 undef, label %if.end12, label %if.then if.then: ; preds = %while.body + %0 = add i32 %input, 1 br label %if.end12 if.end12: ; preds = %if.then, %while.body - %i.1 = phi i32 [ %i.0240, %while.body ], [ undef, %if.then ] + %i.1 = phi i32 [ %i.0240, %while.body ], [ %0, %if.then ] br i1 undef, label %while.body, label %while.end while.end: ; preds = %if.end12 Index: test/CodeGen/PowerPC/subreg-postra-2.ll =================================================================== --- test/CodeGen/PowerPC/subreg-postra-2.ll +++ test/CodeGen/PowerPC/subreg-postra-2.ll @@ -3,158 +3,30 @@ target triple = "powerpc64-unknown-linux-gnu" ; Function Attrs: nounwind -define void @jbd2_journal_commit_transaction() #0 { +define void @jbd2_journal_commit_transaction(i32 %input1, i32* %input2, i32* %input3, i8** %input4) #0 { entry: - br i1 undef, label %do.body, label %if.then5 - -if.then5: ; preds = %entry - unreachable - -do.body: ; preds = %entry - br i1 undef, label %do.body.i, label %trace_jbd2_start_commit.exit - -do.body.i: ; preds = %do.body - unreachable - -trace_jbd2_start_commit.exit: ; preds = %do.body - br i1 undef, label %do.body.i1116, label %trace_jbd2_commit_locking.exit - -do.body.i1116: ; preds = %trace_jbd2_start_commit.exit - unreachable - -trace_jbd2_commit_locking.exit: ; preds = %trace_jbd2_start_commit.exit - br i1 undef, label %while.end, label %while.body.lr.ph - -while.body.lr.ph: ; preds = %trace_jbd2_commit_locking.exit - unreachable - -while.end: ; preds = %trace_jbd2_commit_locking.exit - br i1 undef, label %spin_unlock.exit1146, label %if.then.i.i.i.i1144 - -if.then.i.i.i.i1144: ; preds = %while.end - unreachable - -spin_unlock.exit1146: ; preds = %while.end - br i1 undef, label %spin_unlock.exit1154, label %if.then.i.i.i.i1152 - -if.then.i.i.i.i1152: ; preds = %spin_unlock.exit1146 - unreachable - -spin_unlock.exit1154: ; preds = %spin_unlock.exit1146 - br i1 undef, label %do.body.i1159, label %trace_jbd2_commit_flushing.exit - -do.body.i1159: ; preds = %spin_unlock.exit1154 - br i1 undef, label %if.end.i1166, label %do.body5.i1165 - -do.body5.i1165: ; preds = %do.body.i1159 - unreachable - -if.end.i1166: ; preds = %do.body.i1159 - unreachable - -trace_jbd2_commit_flushing.exit: ; preds = %spin_unlock.exit1154 - br i1 undef, label %for.end.i, label %for.body.lr.ph.i - -for.body.lr.ph.i: ; preds = %trace_jbd2_commit_flushing.exit - unreachable - -for.end.i: ; preds = %trace_jbd2_commit_flushing.exit - br i1 undef, label %journal_submit_data_buffers.exit, label %if.then.i.i.i.i31.i - -if.then.i.i.i.i31.i: ; preds = %for.end.i - br label %journal_submit_data_buffers.exit - -journal_submit_data_buffers.exit: ; preds = %if.then.i.i.i.i31.i, %for.end.i - br i1 undef, label %if.end103, label %if.then102 - -if.then102: ; preds = %journal_submit_data_buffers.exit - unreachable - -if.end103: ; preds = %journal_submit_data_buffers.exit - br i1 undef, label %do.body.i1182, label %trace_jbd2_commit_logging.exit - -do.body.i1182: ; preds = %if.end103 - br i1 undef, label %if.end.i1189, label %do.body5.i1188 - -do.body5.i1188: ; preds = %do.body5.i1188, %do.body.i1182 - br i1 undef, label %if.end.i1189, label %do.body5.i1188 - -if.end.i1189: ; preds = %do.body5.i1188, %do.body.i1182 - unreachable - -trace_jbd2_commit_logging.exit: ; preds = %if.end103 - br label %while.cond129.outer1451 - -while.cond129.outer1451: ; preds = %start_journal_io, %trace_jbd2_commit_logging.exit - br label %while.cond129 - -while.cond129: ; preds = %if.then135, %while.cond129.outer1451 - br i1 undef, label %while.end246, label %if.then135 - -if.then135: ; preds = %while.cond129 - br i1 undef, label %start_journal_io, label %while.cond129 - -start_journal_io: ; preds = %if.then135 - br label %while.cond129.outer1451 - -while.end246: ; preds = %while.cond129 - br i1 undef, label %for.end.i1287, label %for.body.i1277 - -for.body.i1277: ; preds = %while.end246 - unreachable - -for.end.i1287: ; preds = %while.end246 - br i1 undef, label %journal_finish_inode_data_buffers.exit, label %if.then.i.i.i.i84.i - -if.then.i.i.i.i84.i: ; preds = %for.end.i1287 - unreachable - -journal_finish_inode_data_buffers.exit: ; preds = %for.end.i1287 - br i1 undef, label %if.end256, label %if.then249 - -if.then249: ; preds = %journal_finish_inode_data_buffers.exit - unreachable - -if.end256: ; preds = %journal_finish_inode_data_buffers.exit - br label %while.body318 - -while.body318: ; preds = %wait_on_buffer.exit, %if.end256 - br i1 undef, label %wait_on_buffer.exit, label %if.then.i1296 - -if.then.i1296: ; preds = %while.body318 - br label %wait_on_buffer.exit - -wait_on_buffer.exit: ; preds = %if.then.i1296, %while.body318 - br i1 undef, label %do.body378, label %while.body318 - -do.body378: ; preds = %wait_on_buffer.exit - br i1 undef, label %while.end418, label %while.body392.lr.ph - -while.body392.lr.ph: ; preds = %do.body378 br label %while.body392 while.body392: ; preds = %wait_on_buffer.exit1319, %while.body392.lr.ph - %0 = load i8*, i8** undef, align 8 + %0 = load i8*, i8** %input4, align 8 %add.ptr399 = getelementptr inbounds i8, i8* %0, i64 -72 %b_state.i.i1314 = bitcast i8* %add.ptr399 to i64* - %tobool.i1316 = icmp eq i64 undef, 0 - br i1 %tobool.i1316, label %wait_on_buffer.exit1319, label %if.then.i1317 - -if.then.i1317: ; preds = %while.body392 - unreachable + %ivar = add i32 %input1, 1 + %tobool.i1316 = icmp eq i32 %input1, 0 + br i1 %tobool.i1316, label %wait_on_buffer.exit1319, label %while.end418 wait_on_buffer.exit1319: ; preds = %while.body392 %1 = load volatile i64, i64* %b_state.i.i1314, align 8 %conv.i.i1322 = and i64 %1, 1 %lnot404 = icmp eq i64 %conv.i.i1322, 0 - %.err.4 = select i1 %lnot404, i32 -5, i32 undef + %.err.4 = select i1 %lnot404, i32 -5, i32 %input1 %2 = call i64 asm sideeffect "1:.long 0x7c0000a8 $| ((($0) & 0x1f) << 21) $| (((0) & 0x1f) << 16) $| ((($3) & 0x1f) << 11) $| (((0) & 0x1) << 0) \0Aandc $0,$0,$2\0Astdcx. $0,0,$3\0Abne- 1b\0A", "=&r,=*m,r,r,*m,~{cc},~{memory}"(i64* %b_state.i.i1314, i64 262144, i64* %b_state.i.i1314, i64* %b_state.i.i1314) #0 - store i8* %0, i8** undef, align 8 - %cmp.i1312 = icmp eq i32* undef, undef + store i8* %0, i8** %input4, align 8 + %cmp.i1312 = icmp eq i32* %input2, %input3 br i1 %cmp.i1312, label %while.end418, label %while.body392 while.end418: ; preds = %wait_on_buffer.exit1319, %do.body378 - %err.4.lcssa = phi i32 [ undef, %do.body378 ], [ %.err.4, %wait_on_buffer.exit1319 ] + %err.4.lcssa = phi i32 [ %ivar, %while.body392 ], [ %.err.4, %wait_on_buffer.exit1319 ] %tobool419 = icmp eq i32 %err.4.lcssa, 0 br i1 %tobool419, label %if.end421, label %if.then420 @@ -169,6 +41,7 @@ if.end421: ; preds = %while.end418 unreachable + } attributes #0 = { nounwind } Index: test/CodeGen/PowerPC/svr4-redzone.ll =================================================================== --- test/CodeGen/PowerPC/svr4-redzone.ll +++ test/CodeGen/PowerPC/svr4-redzone.ll @@ -2,10 +2,10 @@ ; RUN: llc -mtriple="powerpc64-unknown-linux-gnu" < %s | FileCheck %s --check-prefix=PPC64 ; PR15332 -define void @regalloc() nounwind { +define i32 @regalloc() nounwind { entry: %0 = add i32 1, 2 - ret void + ret i32 %0 } ; PPC32-LABEL: regalloc: ; PPC32-NOT: stwu 1, -{{[0-9]+}}(1) @@ -15,10 +15,10 @@ ; PPC64-NOT: stdu 1, -{{[0-9]+}}(1) ; PPC64: blr -define void @smallstack() nounwind { +define i8* @smallstack() nounwind { entry: %0 = alloca i8, i32 4 - ret void + ret i8* %0 } ; PPC32-LABEL: smallstack: ; PPC32: stwu 1, -16(1) @@ -27,10 +27,10 @@ ; PPC64-NOT: stdu 1, -{{[0-9]+}}(1) ; PPC64: blr -define void @bigstack() nounwind { +define i8* @bigstack() nounwind { entry: %0 = alloca i8, i32 230 - ret void + ret i8* %0 } ; PPC32-LABEL: bigstack: ; PPC32: stwu 1, -240(1) Index: test/CodeGen/PowerPC/tls_get_addr_stackframe.ll =================================================================== --- test/CodeGen/PowerPC/tls_get_addr_stackframe.ll +++ test/CodeGen/PowerPC/tls_get_addr_stackframe.ll @@ -9,24 +9,19 @@ @tls_var = external thread_local global %struct1.2.41*, align 8 -define void @foo_test() { +define i32 @foo_test() { %1 = load %struct1.2.41*, %struct1.2.41** @tls_var, align 8 - br i1 undef, label %foo.exit, label %2 -;