@@ -817,7 +817,28 @@ namespace {
817817
818818/// Main data required for vectorization of instructions.
819819class InstructionsState {
820- /// The main/alternate instruction. MainOp is also VL0.
820+ /// MainOp and AltOp are primarily determined by getSameOpcode. Currently,
821+ /// only BinaryOperator, CastInst, and CmpInst support alternate instructions
822+ /// (i.e., AltOp is not equal to MainOp; this can be checked using
823+ /// isAltShuffle).
824+ /// A rare exception is TrySplitNode, where the InstructionsState is derived
825+ /// from getMainAltOpsNoStateVL.
826+ /// For those InstructionsState that use alternate instructions, the resulting
827+ /// vectorized output ultimately comes from a shufflevector. For example,
828+ /// given a vector list (VL):
829+ /// VL[0] = add i32 a, e
830+ /// VL[1] = sub i32 b, f
831+ /// VL[2] = add i32 c, g
832+ /// VL[3] = sub i32 d, h
833+ /// The vectorized result would be:
834+ /// intermediated_0 = add <4 x i32> <a, b, c, d>, <e, f, g, h>
835+ /// intermediated_1 = sub <4 x i32> <a, b, c, d>, <e, f, g, h>
836+ /// result = shufflevector <4 x i32> intermediated_0,
837+ /// <4 x i32> intermediated_1,
838+ /// <4 x i32> <i32 0, i32 5, i32 2, i32 7>
839+ /// Since shufflevector is used in the final result, when calculating the cost
840+ /// (getEntryCost), we must account for the usage of shufflevector in
841+ /// GetVectorCost.
821842 Instruction *MainOp = nullptr;
822843 Instruction *AltOp = nullptr;
823844
0 commit comments