This is an archive of the discontinued LLVM Phabricator instance.

[X86] Custom widen 128/256-bit vXi32 fp_to_uint on avx512f targets without avx512vl. Similar for vXi64 on avx512dq without avx512vl.
ClosedPublic

Authored by craig.topper on Dec 25 2019, 1:13 PM.

Details

Summary

Previously we did this with isel patterns that used garbage in
the widened part of the source. But that's not valid for strictfp.
So now we custom widen and use zeroes for the widened elemens for
strictfp.

This replaces D71864.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 25 2019, 1:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 25 2019, 1:13 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper marked 2 inline comments as done.Dec 25 2019, 1:20 PM
craig.topper added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
19929

This was needed because LegalizeVectorOps can send the Chain result in when its checking to see if our widened code needs to be legalized itself. So we have to make sure we get the VT from result 0 regardless of what's in Op.

llvm/lib/Target/X86/X86TargetTransformInfo.cpp
1401

The conversion being "Legal" made generic code return 1 previously. Now that it's Custom, the generic code doesn't work.

pengfei added inline comments.Dec 25 2019, 5:04 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
19977–19978

Why no signed, they are legal too.

20003–20005

Remove curly braces.

20034–20036

Remove curly braces.

20049

Need pad zero for strict.

llvm/test/CodeGen/X86/vec-strict-fptoint-256.ll
1531

There're tests for AVX512DQ that don't use zmm registers, I guess the actions for them are not correctly set.

pengfei added inline comments.Dec 25 2019, 5:13 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
20049

I missed the VL, sorry for the noise.

craig.topper marked 3 inline comments as done.Dec 25 2019, 5:29 PM
craig.topper added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
19977–19978

v8i32 FP_TO_SINT has a Legal setOperationAction so it should never get here. Same reason the code below only widens unsigned.

20003–20005

I tend to prefer curly braces on else if they are also on the if.

llvm/test/CodeGen/X86/vec-strict-fptoint-256.ll
1531

vcvttps2dq ymm, ymm is an avx2 instruction.

Do you have plan for uint_to _fp and signed i64? Otherwise, I can do it.

llvm/test/CodeGen/X86/vec-strict-fptoint-256.ll
1531

Oh, I see. Thanks!

pengfei accepted this revision.Dec 26 2019, 6:39 PM

LGTM.

This revision is now accepted and ready to land.Dec 26 2019, 6:39 PM
This revision was automatically updated to reflect the committed changes.