This is an archive of the discontinued LLVM Phabricator instance.

[X86] Don't fold select for vXi1 on X86 target.
ClosedPublic

Authored by LuoYuanke on Jan 14 2023, 9:26 PM.

Details

Summary

Since there is no mask instruction for vXi1 with avx512f in X86 target.
Folding select for vXi1 doesn't help to reduce instructions.

Diff Detail

Event Timeline

LuoYuanke created this revision.Jan 14 2023, 9:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2023, 9:26 PM
LuoYuanke requested review of this revision.Jan 14 2023, 9:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2023, 9:27 PM
pengfei added inline comments.Jan 15 2023, 4:13 AM
llvm/test/CodeGen/X86/fold-select.ll
4

I think passing vXi1 from arguments is not a common scenario. vXi1 will be promoted vXi16 during lowering arguments. You should add new test cases that generating vXi1 in the IR, e.g.:

%a = icmp eq <8 x i16> %0, %1
...
pengfei added inline comments.Jan 15 2023, 4:16 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
34856

Should be better to use isTypeLegal(VT)?

lebedev.ri added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
34856

If the problematic case is vXi1, then can we just check for the element type?
Why is this here?

pengfei added inline comments.Jan 15 2023, 5:56 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
34856

I guess it is used to prevent crash in line 34861. Check element type should be fine since we have checked isVector.

lebedev.ri requested changes to this revision.Jan 15 2023, 6:05 AM
lebedev.ri added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
34856

This part LG.

llvm/test/CodeGen/X86/fold-select.ll
4

+1

This revision now requires changes to proceed.Jan 15 2023, 6:05 AM
LuoYuanke updated this revision to Diff 489541.Jan 16 2023, 6:46 AM

Address Phoebe's comments.

lebedev.ri accepted this revision.Jan 16 2023, 7:14 AM

LGTM, thanks.

This revision is now accepted and ready to land.Jan 16 2023, 7:14 AM
pengfei accepted this revision.Jan 16 2023, 8:23 AM
This revision was landed with ongoing or failed builds.Jan 16 2023, 4:00 PM
This revision was automatically updated to reflect the committed changes.