@@ -721,8 +721,6 @@ multiclass RVVUnitStridedSegLoadTuple<string op> {
721
721
NF = nf,
722
722
ManualCodegen = [{
723
723
{
724
- SmallVector<llvm::Value*, 6> Operands;
725
-
726
724
bool NoPassthru =
727
725
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
728
726
(!IsMasked && (PolicyAttrs & RVV_VTA));
@@ -733,24 +731,18 @@ multiclass RVVUnitStridedSegLoadTuple<string op> {
733
731
else
734
732
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Ops.back()->getType()};
735
733
736
- if (NoPassthru) { // Push poison into passthru
737
- Operands.push_back(llvm::PoisonValue::get(ResultType));
738
- } else { // Push intrinsics operands into passthru
739
- llvm::Value *PassthruOperand = IsMasked ? Ops[1] : Ops[0];
740
- Operands.push_back(PassthruOperand);
741
- }
742
-
743
- Operands.push_back(Ops[Offset]); // Ptr
744
734
if (IsMasked)
745
- Operands.push_back(Ops[0]);
746
- Operands.push_back(Ops[Offset + 1]); // VL
735
+ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
736
+ if (NoPassthru)
737
+ Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
738
+
747
739
if (IsMasked)
748
- Operands .push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
749
- Operands .push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
740
+ Ops .push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
741
+ Ops .push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
750
742
751
743
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
752
744
753
- llvm::Value *LoadValue = Builder.CreateCall(F, Operands , "");
745
+ llvm::Value *LoadValue = Builder.CreateCall(F, Ops , "");
754
746
if (ReturnValue.isNull())
755
747
return LoadValue;
756
748
else
@@ -787,26 +779,24 @@ multiclass RVVUnitStridedSegStoreTuple<string op> {
787
779
{
788
780
// Masked
789
781
// Builtin: (mask, ptr, v_tuple, vl)
790
- // Intrinsic: (tuple, ptr, mask, vl)
782
+ // Intrinsic: (tuple, ptr, mask, vl, SegInstSEW )
791
783
// Unmasked
792
784
// Builtin: (ptr, v_tuple, vl)
793
- // Intrinsic: (tuple, ptr, vl)
794
- unsigned Offset = IsMasked ? 1 : 0;
785
+ // Intrinsic: (tuple, ptr, vl, SegInstSEW)
795
786
796
- SmallVector<llvm::Value*, 5> Operands;
797
- Operands.push_back(Ops[Offset + 1]); // tuple
798
- Operands.push_back(Ops[Offset]); // Ptr
799
787
if (IsMasked)
800
- Operands.push_back(Ops[0]);
801
- Operands.push_back(Ops[Offset + 2]); // VL
802
- Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
788
+ std::swap(Ops[0], Ops[2]);
789
+ else
790
+ std::swap(Ops[0], Ops[1]);
791
+
792
+ Ops.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
803
793
804
794
if (IsMasked)
805
- IntrinsicTypes = {Operands [0]->getType(), Ops[Offset ]->getType(), Ops[0 ]->getType(), Operands.back() ->getType()};
795
+ IntrinsicTypes = {Ops [0]->getType(), Ops[1 ]->getType(), Ops[2 ]->getType(), Ops[3] ->getType()};
806
796
else
807
- IntrinsicTypes = {Operands [0]->getType(), Ops[Offset ]->getType(), Operands.back() ->getType()};
808
- llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
809
- return Builder.CreateCall(F, Operands, "") ;
797
+ IntrinsicTypes = {Ops [0]->getType(), Ops[1 ]->getType(), Ops[2] ->getType()};
798
+
799
+ break ;
810
800
}
811
801
}] in {
812
802
defvar T = "(Tuple:" # nf # ")";
@@ -836,8 +826,6 @@ multiclass RVVUnitStridedSegLoadFFTuple<string op> {
836
826
NF = nf,
837
827
ManualCodegen = [{
838
828
{
839
- SmallVector<llvm::Value*, 6> Operands;
840
-
841
829
bool NoPassthru =
842
830
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
843
831
(!IsMasked && (PolicyAttrs & RVV_VTA));
@@ -848,24 +836,21 @@ multiclass RVVUnitStridedSegLoadFFTuple<string op> {
848
836
else
849
837
IntrinsicTypes = {ResultType, Ops.back()->getType(), Ops[Offset]->getType()};
850
838
851
- if (NoPassthru) { // Push poison into passthru
852
- Operands.push_back(llvm::PoisonValue::get(ResultType));
853
- } else { // Push intrinsics operands into passthru
854
- llvm::Value *PassthruOperand = IsMasked ? Ops[1] : Ops[0];
855
- Operands.push_back(PassthruOperand);
856
- }
857
-
858
- Operands.push_back(Ops[Offset]); // Ptr
859
839
if (IsMasked)
860
- Operands.push_back(Ops[0]);
861
- Operands.push_back(Ops[Offset + 2]); // vl
840
+ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
841
+ if (NoPassthru)
842
+ Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
843
+
862
844
if (IsMasked)
863
- Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
864
- Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
845
+ Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
846
+ Ops.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
847
+
848
+ Value *NewVL = Ops[2];
849
+ Ops.erase(Ops.begin() + 2);
865
850
866
851
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
867
852
868
- llvm::Value *LoadValue = Builder.CreateCall(F, Operands , "");
853
+ llvm::Value *LoadValue = Builder.CreateCall(F, Ops , "");
869
854
// Get alignment from the new vl operand
870
855
clang::CharUnits Align =
871
856
CGM.getNaturalPointeeTypeAlignment(E->getArg(Offset + 1)->getType());
@@ -874,7 +859,7 @@ multiclass RVVUnitStridedSegLoadFFTuple<string op> {
874
859
875
860
// Store new_vl
876
861
llvm::Value *V = Builder.CreateExtractValue(LoadValue, 1);
877
- Builder.CreateStore(V, Address(Ops[Offset + 1] , V->getType(), Align));
862
+ Builder.CreateStore(V, Address(NewVL , V->getType(), Align));
878
863
879
864
if (ReturnValue.isNull())
880
865
return ReturnTuple;
@@ -909,8 +894,6 @@ multiclass RVVStridedSegLoadTuple<string op> {
909
894
NF = nf,
910
895
ManualCodegen = [{
911
896
{
912
- SmallVector<llvm::Value*, 7> Operands;
913
-
914
897
bool NoPassthru =
915
898
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
916
899
(!IsMasked && (PolicyAttrs & RVV_VTA));
@@ -921,24 +904,17 @@ multiclass RVVStridedSegLoadTuple<string op> {
921
904
else
922
905
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Ops.back()->getType()};
923
906
924
- if (NoPassthru) { // Push poison into passthru
925
- Operands.push_back(llvm::PoisonValue::get(ResultType));
926
- } else { // Push intrinsics operands into passthru
927
- llvm::Value *PassthruOperand = IsMasked ? Ops[1] : Ops[0];
928
- Operands.push_back(PassthruOperand);
929
- }
930
-
931
- Operands.push_back(Ops[Offset]); // Ptr
932
- Operands.push_back(Ops[Offset + 1]); // Stride
933
907
if (IsMasked)
934
- Operands.push_back(Ops[0]);
935
- Operands.push_back(Ops[Offset + 2]); // VL
908
+ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
909
+ if (NoPassthru)
910
+ Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
911
+
936
912
if (IsMasked)
937
- Operands .push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
938
- Operands .push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
913
+ Ops .push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
914
+ Ops .push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
939
915
940
916
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
941
- llvm::Value *LoadValue = Builder.CreateCall(F, Operands , "");
917
+ llvm::Value *LoadValue = Builder.CreateCall(F, Ops , "");
942
918
943
919
if (ReturnValue.isNull())
944
920
return LoadValue;
@@ -977,27 +953,23 @@ multiclass RVVStridedSegStoreTuple<string op> {
977
953
{
978
954
// Masked
979
955
// Builtin: (mask, ptr, stride, v_tuple, vl)
980
- // Intrinsic: (tuple, ptr, stride, mask, vl)
956
+ // Intrinsic: (tuple, ptr, stride, mask, vl, SegInstSEW )
981
957
// Unmasked
982
958
// Builtin: (ptr, stride, v_tuple, vl)
983
- // Intrinsic: (tuple, ptr, stride, vl)
984
- unsigned Offset = IsMasked ? 1 : 0;
959
+ // Intrinsic: (tuple, ptr, stride, vl, SegInstSEW)
985
960
986
- SmallVector<llvm::Value*, 6> Operands;
987
- Operands.push_back(Ops[Offset + 2]); // tuple
988
- Operands.push_back(Ops[Offset]); // Ptr
989
- Operands.push_back(Ops[Offset + 1]); // Stride
990
961
if (IsMasked)
991
- Operands.push_back(Ops[0]);
992
- Operands.push_back(Ops[Offset + 3]); // VL
993
- Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
962
+ std::swap(Ops[0], Ops[3]);
963
+ else
964
+ std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
965
+
966
+ Ops.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
994
967
995
968
if (IsMasked)
996
- IntrinsicTypes = {Operands [0]->getType(), Operands [1]->getType(), Operands.back() ->getType(), Ops[0 ]->getType()};
969
+ IntrinsicTypes = {Ops [0]->getType(), Ops [1]->getType(), Ops[4] ->getType(), Ops[3 ]->getType()};
997
970
else
998
- IntrinsicTypes = {Operands[0]->getType(), Operands[1]->getType(), Operands.back()->getType()};
999
- llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
1000
- return Builder.CreateCall(F, Operands, "");
971
+ IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[3]->getType()};
972
+ break;
1001
973
}
1002
974
}] in {
1003
975
defvar T = "(Tuple:" # nf # ")";
@@ -1022,40 +994,30 @@ multiclass RVVIndexedSegLoadTuple<string op> {
1022
994
NF = nf,
1023
995
ManualCodegen = [{
1024
996
{
1025
- SmallVector<llvm::Value*, 7> Operands;
1026
-
1027
997
bool NoPassthru =
1028
998
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
1029
999
(!IsMasked && (PolicyAttrs & RVV_VTA));
1030
- unsigned Offset = IsMasked ? NoPassthru ? 1 : 2 : NoPassthru ? 0 : 1;
1031
1000
1032
- if (NoPassthru) { // Push poison into passthru
1033
- Operands.push_back(llvm::PoisonValue::get(ResultType));
1034
- } else { // Push intrinsics operands into passthru
1035
- llvm::Value *PassthruOperand = IsMasked ? Ops[1] : Ops[0];
1036
- Operands.push_back(PassthruOperand);
1037
- }
1038
-
1039
- Operands.push_back(Ops[Offset]); // Ptr
1040
- Operands.push_back(Ops[Offset + 1]); // Idx
1041
1001
if (IsMasked)
1042
- Operands.push_back(Ops[0]);
1043
- Operands.push_back(Ops[Offset + 2]); // VL
1002
+ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1003
+ if (NoPassthru)
1004
+ Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1005
+
1044
1006
if (IsMasked)
1045
- Operands .push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1046
- Operands .push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
1007
+ Ops .push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1008
+ Ops .push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
1047
1009
1048
1010
if (IsMasked)
1049
- IntrinsicTypes = {ResultType, Ops[Offset ]->getType(),
1050
- Ops[Offset + 1 ]->getType(),
1051
- Ops[0 ]->getType(),
1052
- Ops.back() ->getType()};
1011
+ IntrinsicTypes = {ResultType, Ops[1 ]->getType(),
1012
+ Ops[2 ]->getType(),
1013
+ Ops[3 ]->getType(),
1014
+ Ops[4] ->getType()};
1053
1015
else
1054
- IntrinsicTypes = {ResultType, Ops[Offset ]->getType(),
1055
- Ops[Offset + 1 ]->getType(),
1056
- Ops.back() ->getType()};
1016
+ IntrinsicTypes = {ResultType, Ops[1 ]->getType(),
1017
+ Ops[2 ]->getType(),
1018
+ Ops[3] ->getType()};
1057
1019
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
1058
- llvm::Value *LoadValue = Builder.CreateCall(F, Operands , "");
1020
+ llvm::Value *LoadValue = Builder.CreateCall(F, Ops , "");
1059
1021
1060
1022
if (ReturnValue.isNull())
1061
1023
return LoadValue;
@@ -1090,30 +1052,25 @@ multiclass RVVIndexedSegStoreTuple<string op> {
1090
1052
{
1091
1053
// Masked
1092
1054
// Builtin: (mask, ptr, index, v_tuple, vl)
1093
- // Intrinsic: (tuple, ptr, index, mask, vl)
1055
+ // Intrinsic: (tuple, ptr, index, mask, vl, SegInstSEW )
1094
1056
// Unmasked
1095
1057
// Builtin: (ptr, index, v_tuple, vl)
1096
- // Intrinsic: (tuple, ptr, index, vl)
1097
- unsigned Offset = IsMasked ? 1 : 0;
1058
+ // Intrinsic: (tuple, ptr, index, vl, SegInstSEW)
1098
1059
1099
- SmallVector<llvm::Value*, 6> Operands;
1100
- Operands.push_back(Ops[Offset + 2]); // tuple
1101
- Operands.push_back(Ops[Offset]); // Ptr
1102
- Operands.push_back(Ops[Offset + 1]); // Idx
1103
1060
if (IsMasked)
1104
- Operands.push_back(Ops[0]);
1105
- Operands.push_back(Ops[Offset + 3]); // VL
1106
- Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
1061
+ std::swap(Ops[0], Ops[3]);
1062
+ else
1063
+ std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
1064
+
1065
+ Ops.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
1107
1066
1108
1067
if (IsMasked)
1109
- IntrinsicTypes = {Operands[0]->getType(), Ops[Offset]->getType(), Ops[Offset + 1]->getType(),
1110
- Ops[0]->getType(),
1111
- Operands.back()->getType()};
1068
+ IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[2]->getType(),
1069
+ Ops[3]->getType(), Ops[4]->getType()};
1112
1070
else
1113
- IntrinsicTypes = {Operands[0]->getType(), Ops[Offset]->getType(), Ops[Offset + 1]->getType(),
1114
- Operands.back()->getType()};
1115
- llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
1116
- return Builder.CreateCall(F, Operands, "");
1071
+ IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[2]->getType(),
1072
+ Ops[3]->getType()};
1073
+ break;
1117
1074
}
1118
1075
}] in {
1119
1076
defvar T = "(Tuple:" # nf # ")";
0 commit comments