[Doc] Proposal for vector predication · llvm/llvm-project@c49b9e0 (original) (raw)

``

1

`+

==========================

`

``

2

`+

Vector Predication Roadmap

`

``

3

`+

==========================

`

``

4

+

``

5

`+

.. contents:: Table of Contents

`

``

6

`+

:depth: 3

`

``

7

`+

:local:

`

``

8

+

``

9

`+

Motivation

`

``

10

`+

==========

`

``

11

+

``

12

`+

This proposal defines a roadmap towards native vector predication in LLVM,

`

``

13

`+

specifically for vector instructions with a mask and/or an explicit vector

`

``

14

`+

length. LLVM currently has no target-independent means to model predicated

`

``

15

`+

vector instructions for modern SIMD ISAs such as AVX512, ARM SVE, the RISC-V V

`

``

16

`+

extension and NEC SX-Aurora. Only some predicated vector operations, such as

`

``

17

`+

masked loads and stores, are available through intrinsics [MaskedIR]_.

`

``

18

+

``

19

`+

The Vector Predication (VP) extensions is a concrete RFC and prototype

`

``

20

`+

implementation to achieve native vector predication in LLVM. The VP prototype

`

``

21

`+

and all related discussions can be found in the VP patch on Phabricator

`

``

22

`+

[VPRFC]_.

`

``

23

+

``

24

`+

Roadmap

`

``

25

`+

=======

`

``

26

+

``

27

`+

  1. IR-level VP intrinsics

`

``

28

`+


`

``

29

+

``

30

`+

`

``

31

`+

`

``

32


- TTI has capability flags for VP (``supportsVP()``?,

``

33


 ``haveActiveVectorLength()``?).

``

34

+

``

35

`+

Result: VP usable for IR-level vectorizers (LV, VPlan, RegionVectorizer),

`

``

36

`+

potential integration in Clang with builtins.

`

``

37

+

``

38

`+

  1. CodeGen support

`

``

39

`+


`

``

40

+

``

41

`+

`

``

42


 (eg ``llvm.vp.fdiv.* -> vp_fdiv``).

``

43

`+

`

``

44

`+

SDNodes to pre-existing ones (SSE, NEON)).

`

``

45

+

``

46

`+

Result: Backend development based on VP SDNodes.

`

``

47

+

``

48

`+

  1. Lift InstSimplify/InstCombine/DAGCombiner to VP

`

``

49

`+


`

``

50

+

``

51

`+

`

``

52

`+

that match standard vector IR and VP intrinsics.

`

``

53

`+

`

``

54

`+

`

``

55

`+

vector instructions.

`

``

56

`+

`

``

57

`+

regular IR instructions.

`

``

58

+

``

59

`+

Result: Optimization of VP intrinsics on par with standard vector instructions.

`

``

60

+

``

61

`+

  1. Deprecate llvm.masked.* / llvm.experimental.reduce.*

`

``

62

`+


`

``

63

+

``

64

`+

`

``

65

`+

`

``

66

+

``

67

`+

Result: VP has superseded earlier vector intrinsics.

`

``

68

+

``

69

`+

  1. Predicated IR Instructions

`

``

70

`+


`

``

71

+

``

72

`+

`

``

73

`+

lower to VP SDNodes (from Stage 2).

`

``

74

`+

`

``

75

`+

vectorized scalar instructions (reduce, shuffles, ..)

`

``

76

`+

`

``

77

`+

has laid the groundwork).

`

``

78

+

``

79

`+

Result: Native vector predication in IR.

`

``

80

+

``

81

`+

References

`

``

82

`+

==========

`

``

83

+

``

84

`` +

.. [MaskedIR] llvm.masked.* intrinsics,

``

``

85

`+

https://llvm.org/docs/LangRef.html#masked-vector-load-and-store-intrinsics

`

``

86

+

``

87

`+

.. [VPRFC] RFC: Prototype & Roadmap for vector predication in LLVM,

`

``

88

`+

https://reviews.llvm.org/D57504

`