Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the CvtVectorToMask node is inserted in the right place #103356

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

tannergooding
Copy link
Member

This fixes

[MethodImpl(MethodImplOptions.NoInlining)]
public static Vector<byte> M3(SveMaskPattern pattern)
{
    return Sve.CreateTrueMaskByte(pattern);
}

Which now correctly generates

; Method Program:M3(ubyte):System.Numerics.Vector`1[ubyte] (FullOpts)
G_M15394_IG01:  ;; offset=0x0000
            stp     fp, lr, [sp, #-0x10]!
            mov     fp, sp
						;; size=8 bbWeight=1 PerfScore 1.50

G_M15394_IG02:  ;; offset=0x0008
            uxtb    w0, w0
            movz    x1, #0x6E98      // code for System.Runtime.Intrinsics.Arm.Sve:CreateTrueMaskByte(ubyte):System.Numerics.Vector`1[ubyte]
            movk    x1, #0xE7A8 LSL #16
            movk    x1, #0x7FFC LSL #32
            ldr     x1, [x1]
            blr     x1
            ptrue   p7.b
            cmpne   p0.b, p7/z, z0.b, #0
            mov     z0.b, p0/z, #1
						;; size=36 bbWeight=1 PerfScore 13.00

G_M15394_IG03:  ;; offset=0x002C
            ldp     fp, lr, [sp], #0x10
            ret     lr
						;; size=8 bbWeight=1 PerfScore 2.00
; Total bytes of code: 52

Which is to say the IR:

N005 (  6,  7) [000003] --C--------                         *  RETURN    simd16 $VN.Void
N004 (  5,  6) [000002] --C--------                         \--*  HWINTRINSIC simd16 ubyte ConvertMaskToVector $200
N003 (  4,  5) [000001] --C--------                            \--*  HWINTRINSIC mask   ubyte CreateTrueMaskByte $140
N002 (  3,  4) [000004] -----------                               \--*  CAST      int <- ubyte <- int $100
N001 (  2,  2) [000000] -----------                                  \--*  LCL_VAR   int    V00 arg0         u:1 (last use) $80

rationalizes into:

               [000005] -----------                            IL_OFFSET void   INLRT @ 0x000[E-]
N001 (  2,  2) [000000] -----------                    t0 =    LCL_VAR   int    V00 arg0         u:1 (last use) $80
                                                            /--*  t0     int    
N002 (  3,  4) [000004] -----------                    t4 = *  CAST      int <- ubyte <- int $100
                                                            /--*  t4     int    arg0 in x0
N003 ( 17,  7) [000006] --C-G------                    t6 = *  CALL      simd16 System.Runtime.Intrinsics.Arm.Sve:CreateTrueMaskByte(ubyte):System.Numerics.Vector`1[ubyte]
N004 (  1,  1) [000007] -----------                    t7 =    HWINTRINSIC mask   ubyte CreateTrueMaskAll
                                                            /--*  t7     mask   
                                                            +--*  t6     simd16 
N005 ( 19,  9) [000008] --C-G------                    t8 = *  HWINTRINSIC mask   ubyte ConvertVectorToMask
                                                            /--*  t8     mask   
N004 (  5,  6) [000002] --C-G------                    t2 = *  HWINTRINSIC simd16 ubyte ConvertMaskToVector $200
                                                            /--*  t2     simd16 
N005 (  6,  7) [000003] --C-G------                         *  RETURN    simd16 $VN.Void

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 12, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@tannergooding tannergooding merged commit aa4ac3f into dotnet:main Jun 12, 2024
103 of 107 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants