Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3666,10 +3666,15 @@ Tmp2.getOperand(0), Tmp2.getOperand(1), Node->getOperand(2)); } else { - // We test only the i1 bit. Skip the AND if UNDEF. - Tmp3 = (Tmp2.isUndef()) ? Tmp2 : - DAG.getNode(ISD::AND, dl, Tmp2.getValueType(), Tmp2, - DAG.getConstant(1, dl, Tmp2.getValueType())); + // We test only the i1 bit. Skip the AND if UNDEF or another AND. + if (Tmp2.isUndef() || + (Tmp2.getOpcode() == ISD::AND && + isa(Tmp2.getOperand(1)) && + dyn_cast(Tmp2.getOperand(1))->getZExtValue() == 1)) + Tmp3 = Tmp2; + else + Tmp3 = DAG.getNode(ISD::AND, dl, Tmp2.getValueType(), Tmp2, + DAG.getConstant(1, dl, Tmp2.getValueType())); Tmp1 = DAG.getNode(ISD::BR_CC, dl, MVT::Other, Tmp1, DAG.getCondCode(ISD::SETNE), Tmp3, DAG.getConstant(0, dl, Tmp3.getValueType()), Index: lib/Target/ARM/ARMISelLowering.cpp =================================================================== --- lib/Target/ARM/ARMISelLowering.cpp +++ lib/Target/ARM/ARMISelLowering.cpp @@ -221,6 +221,7 @@ RegInfo = Subtarget->getRegisterInfo(); Itins = Subtarget->getInstrItineraryData(); + setBooleanContents(ZeroOrOneBooleanContent); setBooleanVectorContents(ZeroOrNegativeOneBooleanContent); if (!Subtarget->isTargetDarwin() && !Subtarget->isTargetIOS() && Index: test/CodeGen/ARM/cse-call.ll =================================================================== --- test/CodeGen/ARM/cse-call.ll +++ test/CodeGen/ARM/cse-call.ll @@ -2,9 +2,6 @@ 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:32:64-v128:32:128-a0:0:32-n32-S32" target triple = "armv6-apple-ios0.0.0" -; Don't CSE a cmp across a call that clobbers CPSR. -; -; CHECK: cmp ; CHECK: S_trimzeros ; CHECK: cmp ; CHECK: strlen @@ -15,16 +12,16 @@ declare i32 @strlen(i8* nocapture) nounwind readonly declare void @S_trimzeros(...) -define i8* @F_floatmul(i8* %f1, i8* %f2) nounwind ssp { +define i8* @F_floatmul(i8* %f1, i8* %f2, i1 %cond) nounwind ssp { entry: - br i1 undef, label %while.end42, label %while.body37 + br i1 %cond, label %while.end42, label %while.body37 while.body37: ; preds = %while.body37, %entry br i1 false, label %while.end42, label %while.body37 while.end42: ; preds = %while.body37, %entry - %. = select i1 undef, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man1, i32 0, i32 0), i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man2, i32 0, i32 0) - %.92 = select i1 undef, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man2, i32 0, i32 0), i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man1, i32 0, i32 0) + %. = select i1 %cond, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man1, i32 0, i32 0), i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man2, i32 0, i32 0) + %.92 = select i1 %cond, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man2, i32 0, i32 0), i8* getelementptr inbounds ([200 x i8], [200 x i8]* @F_floatmul.man1, i32 0, i32 0) tail call void bitcast (void (...)* @S_trimzeros to void (i8*)*)(i8* %.92) nounwind %call47 = tail call i32 @strlen(i8* %.) nounwind unreachable Index: test/CodeGen/ARM/i1.ll =================================================================== --- /dev/null +++ test/CodeGen/ARM/i1.ll @@ -0,0 +1,18 @@ +; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s + +define i32 @test1(i1 %c, i32 %x) { +; CHECK-LABEL: test1: +; CHECK: mov r0, #0 +; CHECK-NEXT: cmp r0, #0 +; CHECK-NEXT: movne r0, #0 +; CHECK-NEXT: moveq r0, #1 +; CHECK-NEXT: mov pc, lr +entry: + br i1 undef, label %t, label %f + +t: + ret i32 1 + +f: + ret i32 0 +} Index: test/CodeGen/ARM/sub-cmp-peephole.ll =================================================================== --- test/CodeGen/ARM/sub-cmp-peephole.ll +++ test/CodeGen/ARM/sub-cmp-peephole.ll @@ -73,11 +73,11 @@ ; CHECK: bc_raise ; CHECK: rsbeq ; CHECK: cmp -define i32 @bc_raise() nounwind ssp { +define i32 @bc_raise(i1 %cond) nounwind ssp { entry: - %val.2.i = select i1 undef, i32 0, i32 undef + %val.2.i = select i1 %cond, i32 0, i32 undef %sub.i = sub nsw i32 0, %val.2.i - %retval.0.i = select i1 undef, i32 %val.2.i, i32 %sub.i + %retval.0.i = select i1 %cond, i32 %val.2.i, i32 %sub.i %cmp1 = icmp eq i32 %retval.0.i, 0 br i1 %cmp1, label %land.lhs.true, label %if.end11 Index: test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll =================================================================== --- test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll +++ test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll @@ -6,8 +6,8 @@ define void @t() nounwind { ; CHECK-LABEL: t: -; CHECK: it eq -; CHECK-NEXT: cmpeq +; CHECK: it ne +; CHECK-NEXT: bxne entry: %pix_a.i294 = alloca [4 x %struct.pix_pos], align 4 ; <[4 x %struct.pix_pos]*> [#uses=2] br i1 undef, label %land.rhs, label %lor.end Index: test/CodeGen/Thumb2/2010-11-22-EpilogueBug.ll =================================================================== --- test/CodeGen/Thumb2/2010-11-22-EpilogueBug.ll +++ test/CodeGen/Thumb2/2010-11-22-EpilogueBug.ll @@ -8,7 +8,7 @@ define void @foo() nounwind optsize "no-frame-pointer-elim"="true" { ; CHECK-LABEL: foo: ; CHECK: push -; CHECK: mov r7, sp +; CHECK: add r7, sp ; CHECK: sub sp, #4 entry: %m.i = alloca %struct.buf*, align 4