reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
; RUN: opt -basicaa -memdep -mldst-motion -S < %s | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes='require<memdep>',mldst-motion \
; RUN:   -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"

@r = common global i32 0, align 4
@s = common global i32 0, align 4

; CHECK-LABEL: define void @test1(
define void @test1(i1 %cmp, i32* noalias %p) {
entry:
  br i1 %cmp, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  call void @may_exit() nounwind
  %arrayidx = getelementptr inbounds i32, i32* %p, i64 1
  %0 = load i32, i32* %arrayidx, align 4
  store i32 %0, i32* @r, align 4
  br label %if.end
; CHECK:       call void @may_exit()
; CHECK-NEXT:  %[[gep:.*]] = getelementptr inbounds i32, i32* %p, i64 1
; CHECK-NEXT:  %[[load:.*]] = load i32, i32* %[[gep]], align 4
; CHECK-NEXT:  store i32 %[[load]], i32* @r, align 4

if.else:                                          ; preds = %entry
  %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1
  %1 = load i32, i32* %arrayidx1, align 4
  store i32 %1, i32* @s, align 4
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}

; CHECK-LABEL: define void @test2(
define void @test2(i1 %cmp, i32* noalias %p) {
entry:
  br i1 %cmp, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  %arrayidx = getelementptr inbounds i32, i32* %p, i64 1
  store i32 1, i32* %arrayidx, align 4
  call void @may_throw()
; CHECK:       %[[gep:.*]] = getelementptr inbounds i32, i32* %p, i64 1
; CHECK-NEXT:  store i32 1, i32* %[[gep]], align 4
; CHECK-NEXT:  call void @may_throw()
  br label %if.end

if.else:                                          ; preds = %entry
  %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1
  store i32 2, i32* %arrayidx1, align 4
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}

declare void @may_throw()
declare void @may_exit() nounwind