if (SimplifyDemandedBits(Op1, DemandedMask, Known1, TLO, Depth + 1))
return true;
+ // If the length is 0, replace with 0.
+ KnownBits LengthBits = Known1.extractBits(8, 8);
+ if (LengthBits.isZero())
+ return TLO.CombineTo(Op, TLO.DAG.getConstant(0, SDLoc(Op), VT));
+
break;
}
}
;
; X64-LABEL: bextr_zero_length:
; X64: # %bb.0:
-; X64-NEXT: movzbl %sil, %eax
-; X64-NEXT: bextrl %eax, %edi, %eax
+; X64-NEXT: xorl %eax, %eax
; X64-NEXT: retq
%1 = and i32 %y, 255
%2 = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %1)