Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp =================================================================== --- lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1220,6 +1220,12 @@ Sign, ShAmt)); } } + // If this is a bitcast, let computeKnownBits handle it. Only do this on a + // recursive call where Known may be useful to the caller. + if (Depth > 0) { + TLO.DAG.computeKnownBits(Op, Known, Depth); + return false; + } break; case ISD::ADD: case ISD::MUL: Index: test/CodeGen/X86/combine-and.ll =================================================================== --- test/CodeGen/X86/combine-and.ll +++ test/CodeGen/X86/combine-and.ll @@ -275,13 +275,12 @@ ; SimplifyDemandedBits ; -; PR34620 - redundant PAND after vector shift of a byte vector (PSRLW) +; Redundant pand generated by lowering lshr <16xi8> is eliminated define <16 x i8> @PR34620(<16 x i8> %a0, <16 x i8> %a1) { ; CHECK-LABEL: PR34620: ; CHECK: # %bb.0: ; CHECK-NEXT: psrlw $1, %xmm0 ; CHECK-NEXT: pand {{.*}}(%rip), %xmm0 -; CHECK-NEXT: pand {{.*}}(%rip), %xmm0 ; CHECK-NEXT: paddb %xmm1, %xmm0 ; CHECK-NEXT: retq %1 = lshr <16 x i8> %a0,