1; RUN: opt -basicaa -sroa -loop-rotate -licm -S < %s | FileCheck %s 2; The objects *p and *q are aliased to each other, but even though *q is 3; volatile, *p can be considered invariant in the loop. Check if it is moved 4; out of the loop. 5; CHECK: load i32, i32* %p 6; CHECK: for.body: 7; CHECK: load volatile i32, i32* %q 8 9target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 10 11; Function Attrs: nounwind uwtable 12define i32 @foo(i32* %p, i32* %q, i32 %n) #0 { 13entry: 14 %p.addr = alloca i32*, align 8 15 %q.addr = alloca i32*, align 8 16 %n.addr = alloca i32, align 4 17 %i = alloca i32, align 4 18 %s = alloca i32, align 4 19 store i32* %p, i32** %p.addr, align 8 20 store i32* %q, i32** %q.addr, align 8 21 store i32 %n, i32* %n.addr, align 4 22 store i32 0, i32* %s, align 4 23 store i32 0, i32* %i, align 4 24 br label %for.cond 25 26for.cond: ; preds = %for.inc, %entry 27 %0 = load i32, i32* %i, align 4 28 %1 = load i32, i32* %n.addr, align 4 29 %cmp = icmp slt i32 %0, %1 30 br i1 %cmp, label %for.body, label %for.end 31 32for.body: ; preds = %for.cond 33 %2 = load i32*, i32** %p.addr, align 8 34 %3 = load i32, i32* %2, align 4 35 %4 = load i32*, i32** %q.addr, align 8 36 %5 = load volatile i32, i32* %4, align 4 37 %add = add nsw i32 %3, %5 38 %6 = load i32, i32* %s, align 4 39 %add1 = add nsw i32 %6, %add 40 store i32 %add1, i32* %s, align 4 41 br label %for.inc 42 43for.inc: ; preds = %for.body 44 %7 = load i32, i32* %i, align 4 45 %inc = add nsw i32 %7, 1 46 store i32 %inc, i32* %i, align 4 47 br label %for.cond 48 49for.end: ; preds = %for.cond 50 %8 = load i32, i32* %s, align 4 51 ret i32 %8 52} 53 54attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 55