Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2296,7 +2296,9 @@ // If this is a series of conditions that are or'd or and'd together, emit // this as a sequence of branches instead of setcc's with and/or operations. - // As long as jumps are not expensive, this should improve performance. + // As long as jumps are not expensive (exceptions for multi-use logic ops, + // unpredictable branches, and vector extracts because those jumps are likely + // expensive for any target), this should improve performance. // For example, instead of something like: // cmp A, B // C = seteq @@ -2311,9 +2313,12 @@ // jle foo if (const BinaryOperator *BOp = dyn_cast(CondVal)) { Instruction::BinaryOps Opcode = BOp->getOpcode(); + Value *Vec, *BOp0 = BOp->getOperand(0), *BOp1 = BOp->getOperand(1); if (!DAG.getTargetLoweringInfo().isJumpExpensive() && BOp->hasOneUse() && !I.hasMetadata(LLVMContext::MD_unpredictable) && - (Opcode == Instruction::And || Opcode == Instruction::Or)) { + (Opcode == Instruction::And || Opcode == Instruction::Or) && + !(match(BOp0, m_ExtractElt(m_Value(Vec), m_Value())) && + match(BOp1, m_ExtractElt(m_Specific(Vec), m_Value())))) { FindMergedConditions(BOp, Succ0MBB, Succ1MBB, BrMBB, BrMBB, Opcode, getEdgeProbability(BrMBB, Succ0MBB), Index: llvm/test/CodeGen/AArch64/vec-extract-branch.ll =================================================================== --- llvm/test/CodeGen/AArch64/vec-extract-branch.ll +++ llvm/test/CodeGen/AArch64/vec-extract-branch.ll @@ -6,16 +6,15 @@ ; CHECK: // %bb.0: ; CHECK-NEXT: fcmgt v0.2d, v0.2d, #0.0 ; CHECK-NEXT: xtn v0.2s, v0.2d -; CHECK-NEXT: fmov w8, s0 -; CHECK-NEXT: tbz w8, #0, .LBB0_3 -; CHECK-NEXT: // %bb.1: ; CHECK-NEXT: mov w8, v0.s[1] -; CHECK-NEXT: tbz w8, #0, .LBB0_3 -; CHECK-NEXT: // %bb.2: // %true +; CHECK-NEXT: fmov w9, s0 +; CHECK-NEXT: and w8, w9, w8 +; CHECK-NEXT: tbz w8, #0, .LBB0_2 +; CHECK-NEXT: // %bb.1: // %true ; CHECK-NEXT: mov w8, #42 ; CHECK-NEXT: sdiv w0, w8, w0 ; CHECK-NEXT: ret -; CHECK-NEXT: .LBB0_3: // %false +; CHECK-NEXT: .LBB0_2: // %false ; CHECK-NEXT: mov w0, #88 ; CHECK-NEXT: ret %t1 = fcmp ogt <2 x double> %x, zeroinitializer Index: llvm/test/CodeGen/SystemZ/knownbits.ll =================================================================== --- llvm/test/CodeGen/SystemZ/knownbits.ll +++ llvm/test/CodeGen/SystemZ/knownbits.ll @@ -37,17 +37,14 @@ ; CHECK-NEXT: clhhsi 0, 0 ; CHECK-NEXT: lhi %r0, 0 ; CHECK-NEXT: lochie %r0, 1 -; CHECK-NEXT: lghi %r1, 1 -; CHECK-NEXT: vlvgp %v0, %r0, %r1 +; CHECK-NEXT: vlvgp %v0, %r0, %r0 ; CHECK-NEXT: vrepig %v1, 1 ; CHECK-NEXT: vx %v0, %v0, %v1 ; CHECK-NEXT: vlgvf %r0, %v0, 1 -; CHECK-NEXT: cijlh %r0, 0, .LBB1_3 +; CHECK-NEXT: tmll %r0, 1 +; CHECK-NEXT: je .LBB1_2 ; CHECK-NEXT: # %bb.1: -; CHECK-NEXT: vlgvf %r0, %v0, 3 -; CHECK-NEXT: cijlh %r0, 0, .LBB1_3 -; CHECK-NEXT: # %bb.2: -; CHECK-NEXT: .LBB1_3: +; CHECK-NEXT: .LBB1_2: %1 = load i16, i16* null, align 2 %2 = icmp eq i16 %1, 0 %3 = insertelement <2 x i1> undef, i1 %2, i32 0 Index: llvm/test/CodeGen/X86/setcc-logic.ll =================================================================== --- llvm/test/CodeGen/X86/setcc-logic.ll +++ llvm/test/CodeGen/X86/setcc-logic.ll @@ -323,15 +323,12 @@ ; CHECK-NEXT: xorpd %xmm1, %xmm1 ; CHECK-NEXT: cmpltpd %xmm0, %xmm1 ; CHECK-NEXT: movmskpd %xmm1, %eax -; CHECK-NEXT: testb $1, %al -; CHECK-NEXT: je .LBB16_3 -; CHECK-NEXT: # %bb.1: -; CHECK-NEXT: shrb %al -; CHECK-NEXT: je .LBB16_3 -; CHECK-NEXT: # %bb.2: # %true +; CHECK-NEXT: cmpb $3, %al +; CHECK-NEXT: jne .LBB16_2 +; CHECK-NEXT: # %bb.1: # %true ; CHECK-NEXT: movl $42, %eax ; CHECK-NEXT: retq -; CHECK-NEXT: .LBB16_3: # %false +; CHECK-NEXT: .LBB16_2: # %false ; CHECK-NEXT: movl $88, %eax ; CHECK-NEXT: retq %t1 = fcmp ogt <2 x double> %x, zeroinitializer