Skip to content

ARM64-SVE: Use INC* when incrementing with GetActiveElementCount()/CountXBitElements() #108511

Open
@a74nh

Description

@a74nh

incp

index += GetActiveElementCount(Sve.CreateTrueMaskUInt32(), loopmask);

Generates:

ptrue p0
cntp    x7, p0, p2.s
add     x6, x7, x6

Instead it should do:

incp    x6, p2.s

decp

Also

index -= GetActiveElementCount(Sve.CreateTrueMaskUInt32(), loopmask);

Should produce:

decp    x6, p2.s

sqincp

Note that the user can also do:

index = Sve.SaturatingIncrementByActiveElementCount(index, loopmask);

This correctly produces:

sqincp   x6,  p2.s

This is currently more optimal than using GetActiveElementCount(). However, the user may not want it to saturate.
(There is nothing to fix here. It is just for reference).

incb/inch/incw/decb/dech/decw

index += Sve.Count32BitElements(SveMaskPattern.ALL);

Produces:

cntw    x7, ALL
add     x6, x7, x6

Instead it should produce:

incw  x6, ALL

The same needs to happen for Count8BitElements(), Count16BitElements(), Count64BitElements(). Also should use the DECx instructions when decrementing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2Work that is important, but not critical for the releasearch-arm64area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIarm-sveWork related to arm64 SVE/SVE2 support

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions