@@ -173,9 +173,13 @@ public TestEquivalentInvariants() {
173
173
return testMemorySegmentIInvarL3e (data , 1 , 2 , 3 , RANGE -200 );
174
174
});
175
175
tests .put ("testMemorySegmentIInvarL3f" , () -> {
176
- MemorySegment data = MemorySegment .ofArray (aI .clone ());
176
+ MemorySegment data = MemorySegment .ofArray (aL .clone ());
177
177
return testMemorySegmentIInvarL3f (data , 1 , 2 , 3 , RANGE -200 );
178
178
});
179
+ tests .put ("testMemorySegmentIInvarL3g" , () -> {
180
+ MemorySegment data = MemorySegment .ofArray (aI .clone ());
181
+ return testMemorySegmentIInvarL3g (data , 1 , 2 , 3 , RANGE -200 );
182
+ });
179
183
tests .put ("testMemorySegmentLInvarL3a" , () -> {
180
184
MemorySegment data = MemorySegment .ofArray (aL .clone ());
181
185
return testMemorySegmentLInvarL3a (data , 1 , 2 , 3 , RANGE -200 );
@@ -246,6 +250,7 @@ public TestEquivalentInvariants() {
246
250
"testMemorySegmentIInvarL3d3" ,
247
251
"testMemorySegmentIInvarL3e" ,
248
252
"testMemorySegmentIInvarL3f" ,
253
+ "testMemorySegmentIInvarL3g" ,
249
254
"testMemorySegmentLInvarL3a" ,
250
255
"testMemorySegmentLInvarL3b" ,
251
256
"testMemorySegmentLInvarL3c" ,
@@ -681,12 +686,17 @@ static Object[] testMemorySegmentIInvarL3c(MemorySegment m, long invar1, long in
681
686
}
682
687
683
688
@ Test
689
+ @ IR (counts = {IRNode .LOAD_VECTOR_I , "> 0" ,
690
+ IRNode .STORE_VECTOR , "> 0" },
691
+ applyIfPlatform = {"64-bit" , "true" },
692
+ applyIf = {"AlignVector" , "false" },
693
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
684
694
@ IR (counts = {IRNode .LOAD_VECTOR_I , "= 0" ,
685
695
IRNode .STORE_VECTOR , "= 0" },
686
696
applyIfPlatform = {"64-bit" , "true" },
697
+ applyIf = {"AlignVector" , "true" },
687
698
applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
688
- // Would be nice if it vectorized.
689
- // Fails because of control flow. Somehow the "offsetPlain" check (checks for alignment) is not folded away.
699
+ // With AlignVector (strict alignment requirements): we cannot prove that the invariants are alignable -> no vectorization.
690
700
static Object [] testMemorySegmentIInvarL3d (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
691
701
long i1 = (long )(-invar1 + invar2 + invar3 );
692
702
long i2 = (long )(invar2 + invar3 - invar1 ); // equivalent
@@ -700,12 +710,17 @@ static Object[] testMemorySegmentIInvarL3d(MemorySegment m, int invar1, int inva
700
710
}
701
711
702
712
@ Test
713
+ @ IR (counts = {IRNode .LOAD_VECTOR_I , "> 0" ,
714
+ IRNode .STORE_VECTOR , "> 0" },
715
+ applyIfPlatform = {"64-bit" , "true" },
716
+ applyIf = {"AlignVector" , "false" },
717
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
703
718
@ IR (counts = {IRNode .LOAD_VECTOR_I , "= 0" ,
704
719
IRNode .STORE_VECTOR , "= 0" },
705
720
applyIfPlatform = {"64-bit" , "true" },
721
+ applyIf = {"AlignVector" , "true" },
706
722
applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
707
- // Would be nice if it vectorized.
708
- // Fails because of control flow. Somehow the "offsetPlain" check (checks for alignment) is not folded away.
723
+ // With AlignVector (strict alignment requirements): we cannot prove that the invariants are alignable -> no vectorization.
709
724
static Object [] testMemorySegmentIInvarL3d2 (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
710
725
long i1 = (long )(-invar1 + invar2 + invar3 );
711
726
for (int i = 0 ; i < size ; i +=2 ) {
@@ -735,6 +750,31 @@ static Object[] testMemorySegmentIInvarL3d3(MemorySegment m, int size) {
735
750
return new Object []{ m };
736
751
}
737
752
753
+ @ Test
754
+ @ IR (counts = {IRNode .LOAD_VECTOR_I , "> 0" ,
755
+ IRNode .STORE_VECTOR , "> 0" },
756
+ applyIfPlatform = {"64-bit" , "true" },
757
+ applyIf = {"AlignVector" , "false" },
758
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
759
+ @ IR (counts = {IRNode .LOAD_VECTOR_I , "= 0" ,
760
+ IRNode .STORE_VECTOR , "= 0" },
761
+ applyIfPlatform = {"64-bit" , "true" },
762
+ applyIf = {"AlignVector" , "true" },
763
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
764
+ // With AlignVector (strict alignment requirements): we cannot prove that the invariants are alignable -> no vectorization.
765
+ static Object [] testMemorySegmentIInvarL3e (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
766
+ long i1 = (long )(-invar1 + invar2 + invar3 );
767
+ long i2 = (long )(invar2 + invar3 ) - (long )(invar1 ); // not equivalent
768
+ for (int i = 0 ; i < size ; i +=2 ) {
769
+ int v0 = m .getAtIndex (ValueLayout .JAVA_INT , i + i1 + 0 );
770
+ int v1 = m .getAtIndex (ValueLayout .JAVA_INT , i + i2 + 1 );
771
+ m .setAtIndex (ValueLayout .JAVA_INT , i + i1 + 0 , v0 + 1 );
772
+ m .setAtIndex (ValueLayout .JAVA_INT , i + i2 + 1 , v1 + 1 );
773
+ }
774
+ return new Object []{ m };
775
+ }
776
+
777
+ // Same as testMemorySegmentIInvarL3e, but with long[] input.
738
778
@ Test
739
779
@ IR (counts = {IRNode .LOAD_VECTOR_I , "= 0" ,
740
780
IRNode .STORE_VECTOR , "= 0" },
@@ -743,7 +783,7 @@ static Object[] testMemorySegmentIInvarL3d3(MemorySegment m, int size) {
743
783
// Should never vectorize, since i1 and i2 are not guaranteed to be adjacent
744
784
// invar2 + invar3 could overflow, and the address be valid with and without overflow.
745
785
// So both addresses are valid, and not adjacent.
746
- static Object [] testMemorySegmentIInvarL3e (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
786
+ static Object [] testMemorySegmentIInvarL3f (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
747
787
long i1 = (long )(-invar1 + invar2 + invar3 );
748
788
long i2 = (long )(invar2 + invar3 ) - (long )(invar1 ); // not equivalent
749
789
for (int i = 0 ; i < size ; i +=2 ) {
@@ -762,7 +802,7 @@ static Object[] testMemorySegmentIInvarL3e(MemorySegment m, int invar1, int inva
762
802
applyIfPlatform = {"64-bit" , "true" },
763
803
applyIf = {"AlignVector" , "false" },
764
804
applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
765
- static Object [] testMemorySegmentIInvarL3f (MemorySegment m , long invar1 , long invar2 , long invar3 , int size ) {
805
+ static Object [] testMemorySegmentIInvarL3g (MemorySegment m , long invar1 , long invar2 , long invar3 , int size ) {
766
806
long i1 = -invar1 + invar2 + invar3 ;
767
807
long i2 = invar2 + invar3 - invar1 ; // equivalent
768
808
for (int i = 0 ; i < size ; i ++) {
@@ -825,12 +865,17 @@ static Object[] testMemorySegmentLInvarL3c(MemorySegment m, long invar1, long in
825
865
}
826
866
827
867
@ Test
868
+ @ IR (counts = {IRNode .LOAD_VECTOR_L , "> 0" ,
869
+ IRNode .STORE_VECTOR , "> 0" },
870
+ applyIfPlatform = {"64-bit" , "true" },
871
+ applyIf = {"AlignVector" , "false" },
872
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
828
873
@ IR (counts = {IRNode .LOAD_VECTOR_L , "= 0" ,
829
874
IRNode .STORE_VECTOR , "= 0" },
830
875
applyIfPlatform = {"64-bit" , "true" },
876
+ applyIf = {"AlignVector" , "true" },
831
877
applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
832
- // Would be nice if it vectorized.
833
- // Fails because of control flow. Somehow the "offsetPlain" check (checks for alignment) is not folded away.
878
+ // With AlignVector (strict alignment requirements): we cannot prove that the invariants are alignable -> no vectorization.
834
879
static Object [] testMemorySegmentLInvarL3d (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
835
880
long i1 = (long )(-invar1 + invar2 + invar3 );
836
881
long i2 = (long )(invar2 + invar3 - invar1 ); // equivalent
@@ -844,12 +889,17 @@ static Object[] testMemorySegmentLInvarL3d(MemorySegment m, int invar1, int inva
844
889
}
845
890
846
891
@ Test
892
+ @ IR (counts = {IRNode .LOAD_VECTOR_L , "> 0" ,
893
+ IRNode .STORE_VECTOR , "> 0" },
894
+ applyIfPlatform = {"64-bit" , "true" },
895
+ applyIf = {"AlignVector" , "false" },
896
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
847
897
@ IR (counts = {IRNode .LOAD_VECTOR_L , "= 0" ,
848
898
IRNode .STORE_VECTOR , "= 0" },
849
899
applyIfPlatform = {"64-bit" , "true" },
900
+ applyIf = {"AlignVector" , "true" },
850
901
applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
851
- // Would be nice if it vectorized.
852
- // Fails because of control flow. Somehow the "offsetPlain" check (checks for alignment) is not folded away.
902
+ // With AlignVector (strict alignment requirements): we cannot prove that the invariants are alignable -> no vectorization.
853
903
static Object [] testMemorySegmentLInvarL3d2 (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
854
904
long i1 = (long )(-invar1 + invar2 + invar3 );
855
905
for (int i = 0 ; i < size ; i +=2 ) {
@@ -880,11 +930,17 @@ static Object[] testMemorySegmentLInvarL3d3(MemorySegment m, int size) {
880
930
}
881
931
882
932
@ Test
933
+ @ IR (counts = {IRNode .LOAD_VECTOR_L , "> 0" ,
934
+ IRNode .STORE_VECTOR , "> 0" },
935
+ applyIfPlatform = {"64-bit" , "true" },
936
+ applyIf = {"AlignVector" , "false" },
937
+ applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
883
938
@ IR (counts = {IRNode .LOAD_VECTOR_L , "= 0" ,
884
939
IRNode .STORE_VECTOR , "= 0" },
885
940
applyIfPlatform = {"64-bit" , "true" },
941
+ applyIf = {"AlignVector" , "true" },
886
942
applyIfCPUFeatureOr = {"sse4.1" , "true" , "asimd" , "true" })
887
- // FAILS: should be ok to vectorize, but does not. Investigate in JDK-8331659 .
943
+ // With AlignVector (strict alignment requirements): we cannot prove that the invariants are alignable -> no vectorization .
888
944
static Object [] testMemorySegmentLInvarL3e (MemorySegment m , int invar1 , int invar2 , int invar3 , int size ) {
889
945
long i1 = (long )(-invar1 + invar2 + invar3 );
890
946
long i2 = (long )(invar2 + invar3 ) - (long )(invar1 ); // not equivalent
0 commit comments