summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoadCombine/load-combine-aa.ll
blob: 5a577516fb47d534eb54a3e760437eca2223749b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
; RUN: opt -basicaa -load-combine -S < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i64 @test1(i32* nocapture readonly noalias %a, i32* nocapture readonly noalias %b) {
; CHECK-LABEL: @test1

; CHECK: load i64, i64*
; CHECK: ret i64

  %load1 = load i32, i32* %a, align 4
  %conv = zext i32 %load1 to i64
  %arrayidx1 = getelementptr inbounds i32, i32* %a, i64 1
  store i32 %load1, i32* %b, align 4
  %load2 = load i32, i32* %arrayidx1, align 4
  %conv2 = zext i32 %load2 to i64
  %shl = shl nuw i64 %conv2, 32
  %add = or i64 %shl, %conv
  ret i64 %add
}

define i64 @test2(i32* nocapture readonly %a, i32* nocapture readonly %b) {
; CHECK-LABEL: @test2

; CHECK-NOT: load i64
; CHECK: load i32, i32*
; CHECK: load i32, i32*
; CHECK: ret i64

  %load1 = load i32, i32* %a, align 4
  %conv = zext i32 %load1 to i64
  %arrayidx1 = getelementptr inbounds i32, i32* %a, i64 1
  store i32 %load1, i32* %b, align 4
  %load2 = load i32, i32* %arrayidx1, align 4
  %conv2 = zext i32 %load2 to i64
  %shl = shl nuw i64 %conv2, 32
  %add = or i64 %shl, %conv
  ret i64 %add
}

%rec11 = type { i16, i16, i16 }
@str = global %rec11 { i16 1, i16 2, i16 3 }

; PR31517 - Check that loads which span an aliasing store are not combined.
define i16 @test3() {
; CHECK-LABEL: @test3

; CHECK-NOT: load i32
; CHECK: load i16, i16*
; CHECK: store i16
; CHECK: load i16, i16*
; CHECK: ret i16

  %_tmp9 = getelementptr %rec11, %rec11* @str, i16 0, i32 1
  %_tmp10 = load i16, i16* %_tmp9
  %_tmp12 = getelementptr %rec11, %rec11* @str, i16 0, i32 0
  store i16 %_tmp10, i16* %_tmp12
  %_tmp13 = getelementptr %rec11, %rec11* @str, i16 0, i32 0
  %_tmp14 = load i16, i16* %_tmp13
  %_tmp15 = icmp eq i16 %_tmp14, 3
  %_tmp16 = select i1 %_tmp15, i16 1, i16 0
  ret i16 %_tmp16
}
OpenPOWER on IntegriCloud