-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorsoptimization
Milestone
Description
The following C# code generates assembly which has what I understand to be a redundant test instruction:
private static int PopulatedByte(uint bytes, uint delimMask)
{
var checkDelim = bytes ^ delimMask; //zero out matches, all others non-zero
uint onlyDelimHasSign = Bmi1.AndNot( /*notted*/ checkDelim, checkDelim - INDEXOF_BYTEMULT32) & 0x80808080u;
return onlyDelimHasSign == 0 ? -1 : ByteIndexThatIsntZero(onlyDelimHasSign);
}
private static int ByteIndexThatIsntZero(uint value)
{
return (int)(Bmi1.TrailingZeroCount(value) >> 3);
} xor r9d,0A0A0A0Ah
lea r10d,[r9-1010101h]
andn r9d,r9d,r10d
and r9d,80808080h
test r9d,r9d ;not needed because flags have already been set by preceding and
je M04_L07
tzcnt r9d,r9d
shr r9d,3
jmp M04_L08
M04_L07
mov r9d,0FFFFFFFFh
M04_L08category:cq
theme:optimization
skill-level:beginner
cost:small
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorsoptimization