@@ -491,101 +491,22 @@ for.end: ; preds = %for.body
491491 ret i32 %1
492492}
493493
494- ; /// Different objects, swapped induction, alias at the end
495- ; int noAlias15 (int a) {
496- ; int i;
497- ; for (i=0; i<SIZE; i++)
498- ; Foo.A[i] = Foo.B[SIZE-i-1] + a;
499- ; return Foo.A[a];
500- ; }
501- ; CHECK-LABEL: define i32 @noAlias15(
502- ; CHECK: vector.memcheck:
503- ; CHECK-NEXT: br i1 false, label %scalar.ph, label %vector.ph
504- ; CHECK: add nsw <4 x i32>
505- ; CHECK: ret
506-
507- define i32 @noAlias15 (i32 %a ) nounwind {
508- entry:
509- br label %for.body
510-
511- for.body: ; preds = %entry, %for.body
512- %i.05 = phi i32 [ 0 , %entry ], [ %inc , %for.body ]
513- %sub1 = sub nuw nsw i32 99 , %i.05
514- %arrayidx = getelementptr inbounds %struct.anon , ptr @Foo , i32 0 , i32 2 , i32 %sub1
515- %0 = load i32 , ptr %arrayidx , align 4
516- %add = add nsw i32 %0 , %a
517- %arrayidx2 = getelementptr inbounds [100 x i32 ], ptr @Foo , i32 0 , i32 %i.05
518- store i32 %add , ptr %arrayidx2 , align 4
519- %inc = add nuw nsw i32 %i.05 , 1
520- %exitcond.not = icmp eq i32 %inc , 100
521- br i1 %exitcond.not , label %for.end , label %for.body
522-
523- for.end: ; preds = %for.body
524- %arrayidx3 = getelementptr inbounds [100 x i32 ], ptr @Foo , i32 0 , i32 %a
525- %1 = load i32 , ptr %arrayidx3 , align 4
526- ret i32 %1
527- }
528-
529- ; /// Different objects, swapped induction, alias at the beginning
530- ; int noAlias16 (int a) {
531- ; int i;
532- ; for (i=0; i<SIZE; i++)
533- ; Foo.A[SIZE-i-1] = Foo.B[i] + a;
534- ; return Foo.A[a];
535- ; }
536- ; CHECK-LABEL: define i32 @noAlias16(
537- ; CHECK: entry:
538- ; CHECK-NEXT: br i1 false, label %scalar.ph, label %vector.ph
539-
540- ; CHECK: add nsw <4 x i32>
541- ; CHECK: ret
542-
543- define i32 @noAlias16 (i32 %a ) nounwind {
544- entry:
545- br label %for.body
546-
547- for.body: ; preds = %entry, %for.body
548- %i.05 = phi i32 [ 0 , %entry ], [ %inc , %for.body ]
549- %arrayidx = getelementptr inbounds %struct.anon , ptr @Foo , i32 0 , i32 2 , i32 %i.05
550- %0 = load i32 , ptr %arrayidx , align 4
551- %add = add nsw i32 %0 , %a
552- %sub1 = sub nuw nsw i32 99 , %i.05
553- %arrayidx2 = getelementptr inbounds [100 x i32 ], ptr @Foo , i32 0 , i32 %sub1
554- store i32 %add , ptr %arrayidx2 , align 4
555- %inc = add nuw nsw i32 %i.05 , 1
556- %exitcond.not = icmp eq i32 %inc , 100
557- br i1 %exitcond.not , label %for.end , label %for.body
558-
559- for.end: ; preds = %for.body
560- %arrayidx3 = getelementptr inbounds [100 x i32 ], ptr @Foo , i32 0 , i32 %a
561- %1 = load i32 , ptr %arrayidx3 , align 4
562- ret i32 %1
563- }
564-
565494
566495;; === Now, the tests that we could vectorize with induction changes or run-time checks ===
567496
568497
569498; /// Different objects, swapped induction, alias at the end
570- ; int mayAlias01 (int a, int N ) {
499+ ; int mayAlias01 (int a) {
571500; int i;
572- ; for (i=0; i<N ; i++)
501+ ; for (i=0; i<SIZE ; i++)
573502; Foo.A[i] = Foo.B[SIZE-i-1] + a;
574503; return Foo.A[a];
575504; }
576505; CHECK-LABEL: define i32 @mayAlias01(
577- ; CHECK: vector.memcheck:
578- ; CHECK-NEXT: [[MUL:%.+]] = shl i32 %N, 2
579- ; CHECK-NEXT: [[SCEVGEP0:%.+]] = getelementptr i8, ptr @Foo, i32 [[MUL]]
580- ; CHECK-NEXT: [[SUB:%.+]] = sub i32 804, [[MUL]]
581- ; CHECK-NEXT: [[SCEVGEP1:%.+]] = getelementptr i8, ptr @Foo, i32 [[SUB]]
582- ; CHECK-NEXT: [[BOUND:%.+]] = icmp ult ptr [[SCEVGEP1]], [[SCEVGEP0]]
583- ; CHECK-NEXT: br i1 [[BOUND]], label %scalar.ph, label %vector.ph
584-
585- ; CHECK: add nsw <4 x i32>
506+ ; CHECK-NOT: add nsw <4 x i32>
586507; CHECK: ret
587508
588- define i32 @mayAlias01 (i32 %a , i32 %N ) nounwind {
509+ define i32 @mayAlias01 (i32 %a ) nounwind {
589510entry:
590511 br label %for.body
591512
@@ -598,7 +519,7 @@ for.body: ; preds = %entry, %for.body
598519 %arrayidx2 = getelementptr inbounds [100 x i32 ], ptr @Foo , i32 0 , i32 %i.05
599520 store i32 %add , ptr %arrayidx2 , align 4
600521 %inc = add nuw nsw i32 %i.05 , 1
601- %exitcond.not = icmp eq i32 %inc , %N
522+ %exitcond.not = icmp eq i32 %inc , 100
602523 br i1 %exitcond.not , label %for.end , label %for.body
603524
604525for.end: ; preds = %for.body
@@ -608,20 +529,17 @@ for.end: ; preds = %for.body
608529}
609530
610531; /// Different objects, swapped induction, alias at the beginning
611- ; int mayAlias02 (int a, int N ) {
532+ ; int mayAlias02 (int a) {
612533; int i;
613- ; for (i=0; i<N ; i++)
534+ ; for (i=0; i<SIZE ; i++)
614535; Foo.A[SIZE-i-1] = Foo.B[i] + a;
615536; return Foo.A[a];
616537; }
617538; CHECK-LABEL: define i32 @mayAlias02(
618- ; CHECK: vector.memcheck:
619- ; CHECK-NEXT: br i1 false, label %scalar.ph, label %vector.ph
620-
621- ; CHECK: add nsw <4 x i32>
539+ ; CHECK-NOT: add nsw <4 x i32>
622540; CHECK: ret
623541
624- define i32 @mayAlias02 (i32 %a , i32 %N ) nounwind {
542+ define i32 @mayAlias02 (i32 %a ) nounwind {
625543entry:
626544 br label %for.body
627545
@@ -634,7 +552,7 @@ for.body: ; preds = %entry, %for.body
634552 %arrayidx2 = getelementptr inbounds [100 x i32 ], ptr @Foo , i32 0 , i32 %sub1
635553 store i32 %add , ptr %arrayidx2 , align 4
636554 %inc = add nuw nsw i32 %i.05 , 1
637- %exitcond.not = icmp eq i32 %inc , %N
555+ %exitcond.not = icmp eq i32 %inc , 100
638556 br i1 %exitcond.not , label %for.end , label %for.body
639557
640558for.end: ; preds = %for.body
0 commit comments