1 ; RUN: opt -loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S -o - < %s | FileCheck %s
2 ; RUN: opt -mattr=+sve -loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S -o - < %s | FileCheck %s
4 target triple = "aarch64-unknown-linux-gnu"
6 ; This test is defending against a bug that appeared when we have a target
7 ; configuration where masked loads/stores are legal -- e.g. AArch64 with SVE.
8 ; Predication would not be applied during interleaving, enabling the
9 ; possibility of superfluous loads/stores which could result in miscompiles.
10 ; This test checks that, when we disable vectorisation and force interleaving,
11 ; stores are predicated properly.
13 ; This is _not_ an SVE-specific test. The same bug could manifest on any
14 ; architecture with masked loads/stores, but we use SVE for testing purposes
17 define void @foo(i32* %data1, i32* %data2) {
20 ; CHECK: br i1 {{%.*}}, label %pred.store.if, label %pred.store.continue
21 ; CHECK: pred.store.if:
22 ; CHECK-NEXT: store i32 {{%.*}}, i32* {{%.*}}
23 ; CHECK-NEXT: br label %pred.store.continue
24 ; CHECK: pred.store.continue:
25 ; CHECK-NEXT: br i1 {{%.*}}, label %pred.store.if2, label %pred.store.continue3
26 ; CHECK: pred.store.if2:
27 ; CHECK-NEXT: store i32 {{%.*}}, i32* {{%.*}}
28 ; CHECK-NEXT: br label %pred.store.continue3
29 ; CHECK: pred.store.continue3:
35 %i = phi i64 [ 1023, %entry ], [ %i.next, %if.end ]
36 %arrayidx = getelementptr inbounds i32, i32* %data1, i64 %i
37 %ld = load i32, i32* %arrayidx, align 4
38 %cmp = icmp sgt i32 %ld, %ld
39 br i1 %cmp, label %if.then, label %if.end
42 store i32 %ld, i32* %arrayidx, align 4
46 %i.next = add nsw i64 %i, -1
47 %tobool.not = icmp eq i64 %i, 0
48 br i1 %tobool.not, label %while.end, label %while.body