1; RUN: opt -domtree -instcombine -loops -S < %s | FileCheck %s
2; Note: The -loops above can be anything that requires the domtree, and is
3; necessary to work around a pass-manager bug.
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8%struct.s = type { double* }
9
10; Function Attrs: nounwind uwtable
11define void @_Z3fooR1s(%struct.s* nocapture readonly dereferenceable(8) %x) #0 {
12
13; CHECK-LABEL: @_Z3fooR1s
14; CHECK: call void @llvm.assume
15; CHECK-NOT: call void @llvm.assume
16
17entry:
18  %a = getelementptr inbounds %struct.s, %struct.s* %x, i64 0, i32 0
19  %0 = load double*, double** %a, align 8
20  %ptrint = ptrtoint double* %0 to i64
21  %maskedptr = and i64 %ptrint, 31
22  %maskcond = icmp eq i64 %maskedptr, 0
23  br label %for.body
24
25for.body:                                         ; preds = %for.body, %entry
26  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next.1, %for.body ]
27  tail call void @llvm.assume(i1 %maskcond)
28  %arrayidx = getelementptr inbounds double, double* %0, i64 %indvars.iv
29  %1 = load double, double* %arrayidx, align 16
30  %add = fadd double %1, 1.000000e+00
31  tail call void @llvm.assume(i1 %maskcond)
32  %mul = fmul double %add, 2.000000e+00
33  store double %mul, double* %arrayidx, align 16
34  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
35  tail call void @llvm.assume(i1 %maskcond)
36  %arrayidx.1 = getelementptr inbounds double, double* %0, i64 %indvars.iv.next
37  %2 = load double, double* %arrayidx.1, align 8
38  %add.1 = fadd double %2, 1.000000e+00
39  tail call void @llvm.assume(i1 %maskcond)
40  %mul.1 = fmul double %add.1, 2.000000e+00
41  store double %mul.1, double* %arrayidx.1, align 8
42  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
43  %exitcond.1 = icmp eq i64 %indvars.iv.next, 1599
44  br i1 %exitcond.1, label %for.end, label %for.body
45
46for.end:                                          ; preds = %for.body
47  ret void
48}
49
50declare align 8 i8* @get()
51
52; Check that redundant align assume is removed
53; CHECK-LABEL: @test
54; CHECK-NOT: call void @llvm.assume
55define void @test1() {
56  %p = call align 8 i8* @get()
57  %ptrint = ptrtoint i8* %p to i64
58  %maskedptr = and i64 %ptrint, 7
59  %maskcond = icmp eq i64 %maskedptr, 0
60  call void @llvm.assume(i1 %maskcond)
61  ret void
62}
63
64; Check that redundant align assume is removed
65; CHECK-LABEL: @test
66; CHECK-NOT: call void @llvm.assume
67define void @test3() {
68  %p = alloca i8, align 8
69  %ptrint = ptrtoint i8* %p to i64
70  %maskedptr = and i64 %ptrint, 7
71  %maskcond = icmp eq i64 %maskedptr, 0
72  call void @llvm.assume(i1 %maskcond)
73  ret void
74}
75
76; Function Attrs: nounwind
77declare void @llvm.assume(i1) #1
78
79attributes #0 = { nounwind uwtable }
80attributes #1 = { nounwind }
81
82