100 changes: 46 additions & 54 deletions llvm/test/Transforms/NewGVN/cond_br2-xfail.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,127 +6,119 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
%"class.llvm::SmallVectorImpl" = type { %"class.llvm::SmallVectorTemplateBase" }
%"class.llvm::SmallVectorTemplateBase" = type { %"class.llvm::SmallVectorTemplateCommon" }
%"class.llvm::SmallVectorTemplateCommon" = type { %"class.llvm::SmallVectorBase" }
%"class.llvm::SmallVectorBase" = type { i8*, i8*, i8*, %"union.llvm::SmallVectorBase::U" }
%"class.llvm::SmallVectorBase" = type { ptr, ptr, ptr, %"union.llvm::SmallVectorBase::U" }
%"union.llvm::SmallVectorBase::U" = type { x86_fp80 }

; Function Attrs: ssp uwtable
define void @_Z4testv() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
define void @_Z4testv() #0 personality ptr @__gxx_personality_v0 {
; CHECK: @_Z4testv()
; CHECK: invoke.cont:
; CHECK: br i1 true, label %new.notnull.i11, label %if.end.i14
; CHECK: Retry.i10:

entry:
%sv = alloca %"class.llvm::SmallVector", align 16
%0 = bitcast %"class.llvm::SmallVector"* %sv to i8*
call void @llvm.lifetime.start.p0i8(i64 64, i8* %0) #1
%BeginX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 0
%FirstEl.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 3
%1 = bitcast %"union.llvm::SmallVectorBase::U"* %FirstEl.i.i.i.i.i.i to i8*
store i8* %1, i8** %BeginX.i.i.i.i.i.i, align 16, !tbaa !4
%EndX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 1
store i8* %1, i8** %EndX.i.i.i.i.i.i, align 8, !tbaa !4
%CapacityX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 2
%add.ptr.i.i.i.i2.i.i = getelementptr inbounds %"union.llvm::SmallVectorBase::U", %"union.llvm::SmallVectorBase::U"* %FirstEl.i.i.i.i.i.i, i64 2
%add.ptr.i.i.i.i.i.i = bitcast %"union.llvm::SmallVectorBase::U"* %add.ptr.i.i.i.i2.i.i to i8*
store i8* %add.ptr.i.i.i.i.i.i, i8** %CapacityX.i.i.i.i.i.i, align 16, !tbaa !4
%EndX.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 1
%2 = load i8*, i8** %EndX.i, align 8, !tbaa !4
%CapacityX.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 2
%cmp.i = icmp ult i8* %2, %add.ptr.i.i.i.i.i.i
call void @llvm.lifetime.start.p0(i64 64, ptr %sv) #1
%FirstEl.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 3
store ptr %FirstEl.i.i.i.i.i.i, ptr %sv, align 16, !tbaa !4
%EndX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 1
store ptr %FirstEl.i.i.i.i.i.i, ptr %EndX.i.i.i.i.i.i, align 8, !tbaa !4
%CapacityX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 2
%add.ptr.i.i.i.i2.i.i = getelementptr inbounds %"union.llvm::SmallVectorBase::U", ptr %FirstEl.i.i.i.i.i.i, i64 2
store ptr %add.ptr.i.i.i.i2.i.i, ptr %CapacityX.i.i.i.i.i.i, align 16, !tbaa !4
%EndX.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 1
%0 = load ptr, ptr %EndX.i, align 8, !tbaa !4
%CapacityX.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 2
%cmp.i = icmp ult ptr %0, %add.ptr.i.i.i.i2.i.i
br i1 %cmp.i, label %Retry.i, label %if.end.i

Retry.i: ; preds = %.noexc, %entry
%3 = phi i8* [ %2, %entry ], [ %.pre.i, %.noexc ]
%new.isnull.i = icmp eq i8* %3, null
%1 = phi ptr [ %0, %entry ], [ %.pre.i, %.noexc ]
%new.isnull.i = icmp eq ptr %1, null
br i1 %new.isnull.i, label %invoke.cont, label %new.notnull.i

new.notnull.i: ; preds = %Retry.i
%4 = bitcast i8* %3 to i32*
store i32 1, i32* %4, align 4, !tbaa !5
store i32 1, ptr %1, align 4, !tbaa !5
br label %invoke.cont

if.end.i: ; preds = %entry
%5 = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0
invoke void @_ZN4llvm15SmallVectorBase8grow_podEmm(%"class.llvm::SmallVectorBase"* %5, i64 0, i64 4)
invoke void @_ZN4llvm15SmallVectorBase8grow_podEmm(ptr %sv, i64 0, i64 4)
to label %.noexc unwind label %lpad

.noexc: ; preds = %if.end.i
%.pre.i = load i8*, i8** %EndX.i, align 8, !tbaa !4
%.pre.i = load ptr, ptr %EndX.i, align 8, !tbaa !4
br label %Retry.i

invoke.cont: ; preds = %new.notnull.i, %Retry.i
%add.ptr.i = getelementptr inbounds i8, i8* %3, i64 4
store i8* %add.ptr.i, i8** %EndX.i, align 8, !tbaa !4
%6 = load i8*, i8** %CapacityX.i, align 16, !tbaa !4
%cmp.i8 = icmp ult i8* %add.ptr.i, %6
%add.ptr.i = getelementptr inbounds i8, ptr %1, i64 4
store ptr %add.ptr.i, ptr %EndX.i, align 8, !tbaa !4
%2 = load ptr, ptr %CapacityX.i, align 16, !tbaa !4
%cmp.i8 = icmp ult ptr %add.ptr.i, %2
br i1 %cmp.i8, label %new.notnull.i11, label %if.end.i14

Retry.i10: ; preds = %if.end.i14
%.pre.i13 = load i8*, i8** %EndX.i, align 8, !tbaa !4
%new.isnull.i9 = icmp eq i8* %.pre.i13, null
%.pre.i13 = load ptr, ptr %EndX.i, align 8, !tbaa !4
%new.isnull.i9 = icmp eq ptr %.pre.i13, null
br i1 %new.isnull.i9, label %invoke.cont2, label %new.notnull.i11

new.notnull.i11: ; preds = %invoke.cont, %Retry.i10
%7 = phi i8* [ %.pre.i13, %Retry.i10 ], [ %add.ptr.i, %invoke.cont ]
%8 = bitcast i8* %7 to i32*
store i32 2, i32* %8, align 4, !tbaa !5
%3 = phi ptr [ %.pre.i13, %Retry.i10 ], [ %add.ptr.i, %invoke.cont ]
store i32 2, ptr %3, align 4, !tbaa !5
br label %invoke.cont2

if.end.i14: ; preds = %invoke.cont
%9 = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0
invoke void @_ZN4llvm15SmallVectorBase8grow_podEmm(%"class.llvm::SmallVectorBase"* %9, i64 0, i64 4)
invoke void @_ZN4llvm15SmallVectorBase8grow_podEmm(ptr %sv, i64 0, i64 4)
to label %Retry.i10 unwind label %lpad

invoke.cont2: ; preds = %new.notnull.i11, %Retry.i10
%10 = phi i8* [ null, %Retry.i10 ], [ %7, %new.notnull.i11 ]
%add.ptr.i12 = getelementptr inbounds i8, i8* %10, i64 4
store i8* %add.ptr.i12, i8** %EndX.i, align 8, !tbaa !4
invoke void @_Z1gRN4llvm11SmallVectorIiLj8EEE(%"class.llvm::SmallVector"* %sv)
%4 = phi ptr [ null, %Retry.i10 ], [ %3, %new.notnull.i11 ]
%add.ptr.i12 = getelementptr inbounds i8, ptr %4, i64 4
store ptr %add.ptr.i12, ptr %EndX.i, align 8, !tbaa !4
invoke void @_Z1gRN4llvm11SmallVectorIiLj8EEE(ptr %sv)
to label %invoke.cont3 unwind label %lpad

invoke.cont3: ; preds = %invoke.cont2
%11 = load i8*, i8** %BeginX.i.i.i.i.i.i, align 16, !tbaa !4
%cmp.i.i.i.i19 = icmp eq i8* %11, %1
%5 = load ptr, ptr %sv, align 16, !tbaa !4
%cmp.i.i.i.i19 = icmp eq ptr %5, %FirstEl.i.i.i.i.i.i
br i1 %cmp.i.i.i.i19, label %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit21, label %if.then.i.i.i20

if.then.i.i.i20: ; preds = %invoke.cont3
call void @free(i8* %11) #1
call void @free(ptr %5) #1
br label %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit21

_ZN4llvm11SmallVectorIiLj8EED1Ev.exit21: ; preds = %invoke.cont3, %if.then.i.i.i20
call void @llvm.lifetime.end.p0i8(i64 64, i8* %0) #1
call void @llvm.lifetime.end.p0(i64 64, ptr %sv) #1
ret void

lpad: ; preds = %if.end.i14, %if.end.i, %invoke.cont2
%12 = landingpad { i8*, i32 }
%6 = landingpad { ptr, i32 }
cleanup
%13 = load i8*, i8** %BeginX.i.i.i.i.i.i, align 16, !tbaa !4
%cmp.i.i.i.i = icmp eq i8* %13, %1
%7 = load ptr, ptr %sv, align 16, !tbaa !4
%cmp.i.i.i.i = icmp eq ptr %7, %FirstEl.i.i.i.i.i.i
br i1 %cmp.i.i.i.i, label %eh.resume, label %if.then.i.i.i

if.then.i.i.i: ; preds = %lpad
call void @free(i8* %13) #1
call void @free(ptr %7) #1
br label %eh.resume

eh.resume: ; preds = %if.then.i.i.i, %lpad
resume { i8*, i32 } %12
resume { ptr, i32 } %6
}

; Function Attrs: nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

declare void @_Z1gRN4llvm11SmallVectorIiLj8EEE(%"class.llvm::SmallVector"*) #2
declare void @_Z1gRN4llvm11SmallVectorIiLj8EEE(ptr) #2

; Function Attrs: nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1

declare void @_ZN4llvm15SmallVectorBase8grow_podEmm(%"class.llvm::SmallVectorBase"*, i64, i64) #2
declare void @_ZN4llvm15SmallVectorBase8grow_podEmm(ptr, i64, i64) #2

; Function Attrs: nounwind
declare void @free(i8* nocapture) #3
declare void @free(ptr nocapture) #3

attributes #0 = { ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind }
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Transforms/NewGVN/condprop-xfail.ll
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
; XFAIL: *
; RUN: opt < %s -passes=newgvn -S | FileCheck %s

@a = external global i32 ; <i32*> [#uses=7]
@a = external global i32 ; <ptr> [#uses=7]

;; NewGVN takes two passes to get this, because we prune predicateinfo
; CHECK-LABEL: @test1(
define i32 @test1() nounwind {
entry:
%0 = load i32, i32* @a, align 4
%0 = load i32, ptr @a, align 4
%1 = icmp eq i32 %0, 4
br i1 %1, label %bb, label %bb1

bb: ; preds = %entry
br label %bb8

bb1: ; preds = %entry
%2 = load i32, i32* @a, align 4
%2 = load i32, ptr @a, align 4
%3 = icmp eq i32 %2, 5
br i1 %3, label %bb2, label %bb3

bb2: ; preds = %bb1
br label %bb8

bb3: ; preds = %bb1
%4 = load i32, i32* @a, align 4
%4 = load i32, ptr @a, align 4
%5 = icmp eq i32 %4, 4
; CHECK: br i1 false, label %bb4, label %bb5
br i1 %5, label %bb4, label %bb5

bb4: ; preds = %bb3
%6 = load i32, i32* @a, align 4
%6 = load i32, ptr @a, align 4
%7 = add i32 %6, 5
br label %bb8

bb5: ; preds = %bb3
%8 = load i32, i32* @a, align 4
%8 = load i32, ptr @a, align 4
%9 = icmp eq i32 %8, 5
; CHECK: br i1 false, label %bb6, label %bb7
br i1 %9, label %bb6, label %bb7

bb6: ; preds = %bb5
%10 = load i32, i32* @a, align 4
%10 = load i32, ptr @a, align 4
%11 = add i32 %10, 4
br label %bb8

bb7: ; preds = %bb5
%12 = load i32, i32* @a, align 4
%12 = load i32, ptr @a, align 4
br label %bb8

bb8: ; preds = %bb7, %bb6, %bb4, %bb2, %bb
Expand Down
10 changes: 5 additions & 5 deletions llvm/test/Transforms/NewGVN/crash-no-aa.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
target triple = "x86_64-unknown-freebsd8.0"

; PR5744
define i32 @test1({i16, i32} *%P) {
%P2 = getelementptr {i16, i32}, {i16, i32} *%P, i32 0, i32 0
store i16 42, i16* %P2
define i32 @test1(ptr %P) {
%P2 = getelementptr {i16, i32}, ptr %P, i32 0, i32 0
store i16 42, ptr %P2

%P3 = getelementptr {i16, i32}, {i16, i32} *%P, i32 0, i32 1
%V = load i32, i32* %P3
%P3 = getelementptr {i16, i32}, ptr %P, i32 0, i32 1
%V = load i32, ptr %P3
ret i32 %V
}

89 changes: 40 additions & 49 deletions llvm/test/Transforms/NewGVN/crash.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
target 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"
target triple = "x86_64-apple-darwin10.0"

define i32* @test1(i8* %name, i32 %namelen, i32* %o, i32 %expected_type) nounwind ssp {
define ptr @test1(ptr %name, i32 %namelen, ptr %o, i32 %expected_type) nounwind ssp {
entry:
br i1 undef, label %if.end13, label %while.body.preheader

Expand All @@ -17,28 +17,26 @@ while.body.preheader: ; preds = %if.end13, %if.end
br label %while.body

while.body: ; preds = %while.body.backedge, %while.body.preheader
%o.addr.0 = phi i32* [ undef, %while.body.preheader ], [ %o.addr.0.be, %while.body.backedge ] ; <i32*> [#uses=2]
%o.addr.0 = phi ptr [ undef, %while.body.preheader ], [ %o.addr.0.be, %while.body.backedge ] ; <ptr> [#uses=2]
br i1 false, label %return.loopexit, label %lor.lhs.false

lor.lhs.false: ; preds = %while.body
%tmp20 = bitcast i32* %o.addr.0 to i32* ; <i32*> [#uses=1]
%tmp22 = load i32, i32* %tmp20 ; <i32> [#uses=0]
%tmp22 = load i32, ptr %o.addr.0 ; <i32> [#uses=0]
br i1 undef, label %land.lhs.true24, label %if.end31

land.lhs.true24: ; preds = %lor.lhs.false
%call28 = call i32* @parse_object(i8* undef) nounwind ; <i32*> [#uses=0]
%call28 = call ptr @parse_object(ptr undef) nounwind ; <ptr> [#uses=0]
br i1 undef, label %return.loopexit, label %if.end31

if.end31: ; preds = %land.lhs.true24, %lor.lhs.false
br i1 undef, label %return.loopexit, label %if.end41

if.end41: ; preds = %if.end31
%tmp43 = bitcast i32* %o.addr.0 to i32* ; <i32*> [#uses=1]
%tmp45 = load i32, i32* %tmp43 ; <i32> [#uses=0]
%tmp45 = load i32, ptr %o.addr.0 ; <i32> [#uses=0]
br i1 undef, label %if.then50, label %if.else

if.then50: ; preds = %if.end41
%tmp53 = load i32*, i32** undef ; <i32*> [#uses=1]
%tmp53 = load ptr, ptr undef ; <ptr> [#uses=1]
br label %while.body.backedge

if.else: ; preds = %if.end41
Expand All @@ -48,42 +46,42 @@ if.then62: ; preds = %if.else
br label %while.body.backedge

while.body.backedge: ; preds = %if.then62, %if.then50
%o.addr.0.be = phi i32* [ %tmp53, %if.then50 ], [ undef, %if.then62 ] ; <i32*> [#uses=1]
%o.addr.0.be = phi ptr [ %tmp53, %if.then50 ], [ undef, %if.then62 ] ; <ptr> [#uses=1]
br label %while.body

if.else67: ; preds = %if.else
ret i32* null
ret ptr null

return.loopexit: ; preds = %if.end31, %land.lhs.true24, %while.body
ret i32* undef
ret ptr undef
}

declare i32* @parse_object(i8*)
declare ptr @parse_object(ptr)






%struct.attribute_spec = type { i8*, i32, i32, i8, i8, i8 }
%struct.attribute_spec = type { ptr, i32, i32, i8, i8, i8 }

@attribute_tables = external global [4 x %struct.attribute_spec*] ; <[4 x %struct.attribute_spec*]*> [#uses=2]
@attribute_tables = external global [4 x ptr] ; <ptr> [#uses=2]

define void @test2() nounwind {
entry:
br label %bb69.i

bb69.i: ; preds = %bb57.i.preheader
%tmp4 = getelementptr inbounds [4 x %struct.attribute_spec*], [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1]
%tmp3 = load %struct.attribute_spec*, %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1]
%tmp4 = getelementptr inbounds [4 x ptr], ptr @attribute_tables, i32 0, i32 undef ; <ptr> [#uses=1]
%tmp3 = load ptr, ptr %tmp4, align 4 ; <ptr> [#uses=1]
br label %bb65.i

bb65.i: ; preds = %bb65.i.preheader, %bb64.i
%storemerge6.i = phi i32 [ 1, %bb64.i ], [ 0, %bb69.i ] ; <i32> [#uses=3]
%scevgep14 = getelementptr inbounds %struct.attribute_spec, %struct.attribute_spec* %tmp3, i32 %storemerge6.i, i32 0 ; <i8**> [#uses=1]
%tmp2 = load i8*, i8** %scevgep14, align 4 ; <i8*> [#uses=0]
%tmp = load %struct.attribute_spec*, %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1]
%scevgep1516 = getelementptr inbounds %struct.attribute_spec, %struct.attribute_spec* %tmp, i32 %storemerge6.i, i32 0 ; <i8**> [#uses=0]
%scevgep14 = getelementptr inbounds %struct.attribute_spec, ptr %tmp3, i32 %storemerge6.i, i32 0 ; <ptr> [#uses=1]
%tmp2 = load ptr, ptr %scevgep14, align 4 ; <ptr> [#uses=0]
%tmp = load ptr, ptr %tmp4, align 4 ; <ptr> [#uses=1]
%scevgep1516 = getelementptr inbounds %struct.attribute_spec, ptr %tmp, i32 %storemerge6.i, i32 0 ; <ptr> [#uses=0]
unreachable

bb64.i: ; Unreachable
Expand All @@ -99,38 +97,32 @@ bb66.i: ; Unreachable

@g = external global i64, align 8

define i32* @test3() {
define ptr @test3() {
do.end17.i:
%tmp18.i = load i7*, i7** undef
%tmp1 = bitcast i7* %tmp18.i to i8*
%tmp18.i = load ptr, ptr undef
br i1 undef, label %do.body36.i, label %if.then21.i

if.then21.i:
%tmp2 = bitcast i7* %tmp18.i to i8*
ret i32* undef
ret ptr undef

do.body36.i:
%ivar38.i = load i64, i64* @g
%tmp3 = bitcast i7* %tmp18.i to i8*
%ivar38.i = load i64, ptr @g
%add.ptr39.sum.i = add i64 %ivar38.i, 8
%tmp40.i = getelementptr inbounds i8, i8* %tmp3, i64 %add.ptr39.sum.i
%tmp4 = bitcast i8* %tmp40.i to i64*
%tmp41.i = load i64, i64* %tmp4
%tmp40.i = getelementptr inbounds i8, ptr %tmp18.i, i64 %add.ptr39.sum.i
%tmp41.i = load i64, ptr %tmp40.i
br i1 undef, label %if.then48.i, label %do.body57.i

if.then48.i:
%call54.i = call i32 @foo2()
br label %do.body57.i

do.body57.i:
%tmp58.i = load i7*, i7** undef
%ivar59.i = load i64, i64* @g
%tmp5 = bitcast i7* %tmp58.i to i8*
%tmp58.i = load ptr, ptr undef
%ivar59.i = load i64, ptr @g
%add.ptr65.sum.i = add i64 %ivar59.i, 8
%tmp66.i = getelementptr inbounds i8, i8* %tmp5, i64 %add.ptr65.sum.i
%tmp6 = bitcast i8* %tmp66.i to i64*
%tmp67.i = load i64, i64* %tmp6
ret i32* undef
%tmp66.i = getelementptr inbounds i8, ptr %tmp58.i, i64 %add.ptr65.sum.i
%tmp67.i = load i64, ptr %tmp66.i
ret ptr undef
}

declare i32 @foo2()
Expand All @@ -142,10 +134,10 @@ entry:
ret i32 0

dead:
%P2 = getelementptr i32, i32 *%P2, i32 52
%Q2 = getelementptr i32, i32 *%Q2, i32 52
store i32 4, i32* %P2
%A = load i32, i32* %Q2
%P2 = getelementptr i32, ptr %P2, i32 52
%Q2 = getelementptr i32, ptr %Q2, i32 52
store i32 4, ptr %P2
%A = load i32, ptr %Q2
br i1 true, label %dead, label %dead2

dead2:
Expand All @@ -154,12 +146,12 @@ dead2:


; PR9841
define fastcc i8 @test5(i8* %P) nounwind {
define fastcc i8 @test5(ptr %P) nounwind {
entry:
%0 = load i8, i8* %P, align 2
%0 = load i8, ptr %P, align 2

%Q = getelementptr i8, i8* %P, i32 1
%1 = load i8, i8* %Q, align 1
%Q = getelementptr i8, ptr %P, i32 1
%1 = load i8, ptr %Q, align 1
ret i8 %1
}

Expand All @@ -178,16 +170,15 @@ entry:
;; Unreachable code.

unreachable.bb:
%gep.val = getelementptr inbounds %struct.type, %struct.type* %gep.val, i64 1
%gep.val = getelementptr inbounds %struct.type, ptr %gep.val, i64 1
br i1 undef, label %u2.bb, label %u1.bb

u1.bb:
%tmp1 = getelementptr inbounds %struct.type, %struct.type* %gep.val, i64 0, i32 0
store i64 -1, i64* %tmp1, align 8
store i64 -1, ptr %gep.val, align 8
br label %unreachable.bb

u2.bb:
%0 = load i32, i32* undef, align 4
%0 = load i32, ptr undef, align 4
%conv.i.i.i.i.i = zext i32 %0 to i64
br label %u2.bb

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/NewGVN/cyclic-phi-handling.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; RUN: opt < %s -passes=newgvn -S | FileCheck %s
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"

define void @foo(i32 %arg, i32 %arg1, i32 (i32, i32)* %arg2) {
define void @foo(i32 %arg, i32 %arg1, ptr %arg2) {
; CHECK-LABEL: @foo(
; CHECK-NEXT: bb:
; CHECK-NEXT: br label %bb3
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/NewGVN/dbg-redundant-load.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

; CHECK: @test_redundant_load(
; CHECK-LABEL: entry:
; CHECK-NEXT: load i32, i32* %Y, align 4, !dbg ![[LOC:[0-9]+]]
; CHECK-NEXT: load i32, ptr %Y, align 4, !dbg ![[LOC:[0-9]+]]
; CHECK-LABEL: if.then:
; CHECK-NOT: load
; CHECK-LABEL: if.end:
; CHECK: ![[LOC]] = !DILocation(line: 3, scope: !{{.*}})

define i32 @test_redundant_load(i32 %X, i32* %Y) !dbg !6 {
define i32 @test_redundant_load(i32 %X, ptr %Y) !dbg !6 {
entry:
%0 = load i32, i32* %Y, align 4, !dbg !8
%0 = load i32, ptr %Y, align 4, !dbg !8
%cmp = icmp sgt i32 %X, -1, !dbg !9
br i1 %cmp, label %if.then, label %if.end, !dbg !9

if.then: ; preds = %entry
%1 = load i32, i32* %Y, align 4, !dbg !10
%1 = load i32, ptr %Y, align 4, !dbg !10
%add = add nsw i32 %0, %1, !dbg !10
call void @foo(), !dbg !11
br label %if.end, !dbg !12
Expand Down
39 changes: 19 additions & 20 deletions llvm/test/Transforms/NewGVN/deadstore.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@
;; NewGVN should be able to eliminate any stores of the same value that are actually redundnat.

;; tmp5 is store of the same value to the same location as the load.
define void @test12({ i32, i32 }* %x) nounwind {
define void @test12(ptr %x) nounwind {
; CHECK-LABEL: @test12(
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[X:%.*]], i32 0, i32 0
; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP4]], align 4
; CHECK-NEXT: [[TMP7:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[X]], i32 0, i32 1
; CHECK-NEXT: [[TMP8:%.*]] = load i32, i32* [[TMP7]], align 4
; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[X:%.*]], align 4
; CHECK-NEXT: [[TMP7:%.*]] = getelementptr { i32, i32 }, ptr [[X]], i32 0, i32 1
; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP7]], align 4
; CHECK-NEXT: [[TMP17:%.*]] = sub i32 0, [[TMP8]]
; CHECK-NEXT: store i32 [[TMP17]], i32* [[TMP7]], align 4
; CHECK-NEXT: store i32 [[TMP17]], ptr [[TMP7]], align 4
; CHECK-NEXT: ret void
;
%tmp4 = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 0
%tmp5 = load i32, i32* %tmp4, align 4
%tmp7 = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 1
%tmp8 = load i32, i32* %tmp7, align 4
%tmp4 = getelementptr { i32, i32 }, ptr %x, i32 0, i32 0
%tmp5 = load i32, ptr %tmp4, align 4
%tmp7 = getelementptr { i32, i32 }, ptr %x, i32 0, i32 1
%tmp8 = load i32, ptr %tmp7, align 4
%tmp17 = sub i32 0, %tmp8
store i32 %tmp5, i32* %tmp4, align 4
store i32 %tmp17, i32* %tmp7, align 4
store i32 %tmp5, ptr %tmp4, align 4
store i32 %tmp17, ptr %tmp7, align 4
ret void
}
; Remove redundant store if loaded value is in another block.
define i32 @test26(i1 %c, i32* %p) {
define i32 @test26(i1 %c, ptr %p) {
; CHECK-LABEL: @test26(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[P:%.*]], align 4
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: br label [[BB3:%.*]]
Expand All @@ -38,25 +37,25 @@ define i32 @test26(i1 %c, i32* %p) {
; CHECK-NEXT: ret i32 0
;
entry:
%v = load i32, i32* %p, align 4
%v = load i32, ptr %p, align 4
br i1 %c, label %bb1, label %bb2
bb1:
br label %bb3
bb2:
store i32 %v, i32* %p, align 4
store i32 %v, ptr %p, align 4
br label %bb3
bb3:
ret i32 0
}

declare void @unknown_func()
; Remove redundant store, which is in the same loop as the load.
define i32 @test33(i1 %c, i32* %p, i32 %i) {
define i32 @test33(i1 %c, ptr %p, i32 %i) {
; CHECK-LABEL: @test33(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[P:%.*]], align 4
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4
; CHECK-NEXT: br label [[BB2:%.*]]
; CHECK: bb2:
; CHECK-NEXT: call void @unknown_func()
Expand All @@ -67,10 +66,10 @@ define i32 @test33(i1 %c, i32* %p, i32 %i) {
entry:
br label %bb1
bb1:
%v = load i32, i32* %p, align 4
%v = load i32, ptr %p, align 4
br label %bb2
bb2:
store i32 %v, i32* %p, align 4
store i32 %v, ptr %p, align 4
; Might read and overwrite value at %p, but doesn't matter.
call void @unknown_func()
br i1 undef, label %bb1, label %bb3
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/NewGVN/debugloc-xfail.ll
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define void @foo(i32 %x, i32 %y, i32 %z) local_unnamed_addr #0 !dbg !4 {
entry:
%not.tobool = icmp eq i32 %x, 0, !dbg !8
%.sink = zext i1 %not.tobool to i32, !dbg !8
store i32 %.sink, i32* @g, align 4, !tbaa !9
store i32 %.sink, ptr @g, align 4, !tbaa !9
%cmp8 = icmp sgt i32 %y, 0, !dbg !13
br i1 %cmp8, label %for.body.preheader, label %for.end, !dbg !17

Expand All @@ -29,9 +29,9 @@ for.body: ; preds = %for.body.preheader,
br i1 %cmp1, label %if.then2, label %for.inc, !dbg !21

if.then2: ; preds = %for.body
%0 = load i32, i32* @g, align 4, !dbg !22, !tbaa !9
%0 = load i32, ptr @g, align 4, !dbg !22, !tbaa !9
%inc = add nsw i32 %0, 1, !dbg !22
store i32 %inc, i32* @g, align 4, !dbg !22, !tbaa !9
store i32 %inc, ptr @g, align 4, !dbg !22, !tbaa !9
br label %for.inc, !dbg !23

for.inc: ; preds = %for.body, %if.then2
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/NewGVN/edge.ll
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ bb2:
}

declare void @g(i1)
define void @f4(i8 * %x) {
define void @f4(ptr %x) {
; CHECK-LABEL: define void @f4(
bb0:
%y = icmp eq i8* null, %x
%y = icmp eq ptr null, %x
br i1 %y, label %bb2, label %bb1
bb1:
br label %bb2
bb2:
%zed = icmp eq i8* null, %x
%zed = icmp eq ptr null, %x
call void @g(i1 %zed)
; CHECK: call void @g(i1 %y)
ret void
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ define void @g() {
; CHECK-NEXT: br label [[IF_END11_LOOPEXIT]]
; CHECK: if.end11.loopexit:
; CHECK-NEXT: [[STOREMERGE_LCSSA:%.*]] = phi i32 [ 0, [[FOR_COND6_PREHEADER]] ], [ 1, [[FOR_COND6_PREHEADER3]] ]
; CHECK-NEXT: store i32 [[STOREMERGE_LCSSA]], i32* @b, align 4
; CHECK-NEXT: store i32 [[STOREMERGE_LCSSA]], ptr @b, align 4
; CHECK-NEXT: br label [[IF_END11]]
; CHECK: if.end11:
; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @b, align 4
; CHECK-NEXT: [[TMP1:%.*]] = load i8, i8* @a, align 1
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @b, align 4
; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr @a, align 1
; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[TMP1]] to i32
; CHECK-NEXT: [[CMP12:%.*]] = icmp eq i32 [[TMP0]], [[CONV]]
; CHECK-NEXT: br i1 [[CMP12]], label [[IF_THEN14:%.*]], label [[IF_END16:%.*]]
; CHECK: if.then14:
; CHECK-NEXT: [[CONV15:%.*]] = trunc i32 [[TMP0]] to i16
; CHECK-NEXT: store i16 [[CONV15]], i16* @f, align 2
; CHECK-NEXT: store i16 [[CONV15]], ptr @f, align 2
; CHECK-NEXT: unreachable
; CHECK: if.end16:
; CHECK-NEXT: ret void
Expand All @@ -61,19 +61,19 @@ for.cond6.preheader3: ; preds = %for.cond6.preheader

if.end11.loopexit: ; preds = %for.cond6.preheader3, %for.cond6.preheader
%storemerge.lcssa = phi i32 [ 0, %for.cond6.preheader ], [ 1, %for.cond6.preheader3 ]
store i32 %storemerge.lcssa, i32* @b, align 4
store i32 %storemerge.lcssa, ptr @b, align 4
br label %if.end11

if.end11: ; preds = %if.end11.loopexit, %for.end4.split
%0 = load i32, i32* @b, align 4
%1 = load i8, i8* @a, align 1
%0 = load i32, ptr @b, align 4
%1 = load i8, ptr @a, align 1
%conv = sext i8 %1 to i32
%cmp12 = icmp eq i32 %0, %conv
br i1 %cmp12, label %if.then14, label %if.end16

if.then14: ; preds = %if.end11
%conv15 = trunc i32 %0 to i16
store i16 %conv15, i16* @f, align 2
store i16 %conv15, ptr @f, align 2
unreachable

if.end16: ; preds = %if.end11
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/Transforms/NewGVN/equivalent-phi.ll
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ define i32 @bar(i32 %arg, i32 %arg1, i32 %arg2) #0 {
; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ %arg2, %bb ], [ [[TMP18:%.*]], %bb17 ]
; CHECK-NEXT: [[TMP6:%.*]] = phi i32 [ 0, %bb ], [ [[TMP14:%.*]], %bb17 ]
; CHECK-NEXT: [[TMP7:%.*]] = sext i32 [[TMP]] to i64
; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds [1024 x i32], [1024 x i32]* @global, i64 0, i64 [[TMP7]]
; CHECK-NEXT: [[TMP9:%.*]] = load i32, i32* [[TMP8]], align 4
; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds [1024 x i32], ptr @global, i64 0, i64 [[TMP7]]
; CHECK-NEXT: [[TMP9:%.*]] = load i32, ptr [[TMP8]], align 4
; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP6]], [[TMP9]]
; CHECK-NEXT: [[TMP14]] = add nsw i32 [[TMP10]], [[TMP9]]
; CHECK-NEXT: [[TMP15:%.*]] = add nsw i32 [[TMP]], %arg1
Expand All @@ -39,12 +39,12 @@ bb3: ; preds = %bb17, %bb
%tmp5 = phi i32 [ %arg, %bb ], [ %tmp16, %bb17 ]
%tmp6 = phi i32 [ 0, %bb ], [ %tmp14, %bb17 ]
%tmp7 = sext i32 %tmp to i64
%tmp8 = getelementptr inbounds [1024 x i32], [1024 x i32]* @global, i64 0, i64 %tmp7
%tmp9 = load i32, i32* %tmp8, align 4
%tmp8 = getelementptr inbounds [1024 x i32], ptr @global, i64 0, i64 %tmp7
%tmp9 = load i32, ptr %tmp8, align 4
%tmp10 = add nsw i32 %tmp6, %tmp9
%tmp11 = sext i32 %tmp5 to i64
%tmp12 = getelementptr inbounds [1024 x i32], [1024 x i32]* @global, i64 0, i64 %tmp11
%tmp13 = load i32, i32* %tmp12, align 4
%tmp12 = getelementptr inbounds [1024 x i32], ptr @global, i64 0, i64 %tmp11
%tmp13 = load i32, ptr %tmp12, align 4
%tmp14 = add nsw i32 %tmp10, %tmp13
%tmp15 = add nsw i32 %tmp, %arg1
%tmp16 = add nsw i32 %tmp5, %arg1
Expand Down
26 changes: 13 additions & 13 deletions llvm/test/Transforms/NewGVN/fence-xfail.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
@a = external constant i32
; We can value forward across the fence since we can (semantically)
; reorder the following load before the fence.
define i32 @test(i32* %addr.i) {
define i32 @test(ptr %addr.i) {
; CHECK-LABEL: @test
; CHECK: store
; CHECK: fence
; CHECK-NOT: load
; CHECK: ret
store i32 5, i32* %addr.i, align 4
store i32 5, ptr %addr.i, align 4
fence release
%a = load i32, i32* %addr.i, align 4
%a = load i32, ptr %addr.i, align 4
ret i32 %a
}

; Same as above
define i32 @test2(i32* %addr.i) {
define i32 @test2(ptr %addr.i) {
; CHECK-LABEL: @test2
; CHECK-NEXT: fence
; CHECK-NOT: load
; CHECK: ret
%a = load i32, i32* %addr.i, align 4
%a = load i32, ptr %addr.i, align 4
fence release
%a2 = load i32, i32* %addr.i, align 4
%a2 = load i32, ptr %addr.i, align 4
%res = sub i32 %a, %a2
ret i32 %res
}
Expand All @@ -35,7 +35,7 @@ define i32 @test2(i32* %addr.i) {
; ordering property (though it is that too), but a liveness
; property. We expect to eventually see the value of store by
; another thread when spinning on that location.
define i32 @test3(i32* noalias %addr.i, i32* noalias %otheraddr) {
define i32 @test3(ptr noalias %addr.i, ptr noalias %otheraddr) {
; CHECK-LABEL: @test3
; CHECK: load
; CHECK: fence
Expand All @@ -47,28 +47,28 @@ define i32 @test3(i32* noalias %addr.i, i32* noalias %otheraddr) {
; It's hopefully clear that allowing PRE to turn this into:
; if (!*%addr.i) while(true) {} would be unfortunate
fence acquire
%a = load i32, i32* %addr.i, align 4
%a = load i32, ptr %addr.i, align 4
fence acquire
%a2 = load i32, i32* %addr.i, align 4
%a2 = load i32, ptr %addr.i, align 4
%res = sub i32 %a, %a2
ret i32 %res
}

; We can forward the value forward the load
; across both the fences, because the load is from
; a constant memory location.
define i32 @test4(i32* %addr) {
define i32 @test4(ptr %addr) {
; CHECK-LABEL: @test4
; CHECK-NOT: load
; CHECK: fence release
; CHECK: store
; CHECK: fence seq_cst
; CHECK: ret i32 0
%var = load i32, i32* @a
%var = load i32, ptr @a
fence release
store i32 42, i32* %addr, align 8
store i32 42, ptr %addr, align 8
fence seq_cst
%var2 = load i32, i32* @a
%var2 = load i32, ptr @a
%var3 = sub i32 %var, %var2
ret i32 %var3
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/NewGVN/flags-simplify.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ define i64 @ashr_lsh_nsw(i64 %tmp) {
; CHECK-LABEL: @ashr_lsh_nsw(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CONV3:%.*]] = shl i64 [[TMP:%.*]], 32
; CHECK-NEXT: store i64 [[CONV3]], i64* @f, align 8
; CHECK-NEXT: store i64 [[CONV3]], ptr @f, align 8
; CHECK-NEXT: [[CONV7:%.*]] = ashr exact i64 [[CONV3]], 32
; CHECK-NEXT: ret i64 [[CONV7]]
;
entry: ; preds = %if.then
%conv3 = shl nsw i64 %tmp, 32
store i64 %conv3, i64* @f, align 8
store i64 %conv3, ptr @f, align 8
%sext = shl i64 %tmp, 32
%conv7 = ashr exact i64 %sext, 32
ret i64 %conv7
Expand All @@ -30,13 +30,13 @@ define i64 @ashr_lsh_nuw(i64 %tmp) {
; CHECK-LABEL: @ashr_lsh_nuw(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CONV3:%.*]] = shl i64 [[TMP:%.*]], 32
; CHECK-NEXT: store i64 [[CONV3]], i64* @f, align 8
; CHECK-NEXT: store i64 [[CONV3]], ptr @f, align 8
; CHECK-NEXT: [[CONV7:%.*]] = ashr exact i64 [[CONV3]], 32
; CHECK-NEXT: ret i64 [[CONV7]]
;
entry: ; preds = %if.then
%conv3 = shl nuw i64 %tmp, 32
store i64 %conv3, i64* @f, align 8
store i64 %conv3, ptr @f, align 8
%sext = shl i64 %tmp, 32
%conv7 = ashr exact i64 %sext, 32
ret i64 %conv7
Expand Down
29 changes: 14 additions & 15 deletions llvm/test/Transforms/NewGVN/fold-const-expr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
%2 = type { i32, i32, i32, i32, i32 }
define i32 @_Z16vector3util_mainv(i32 %x, i32 %y) {
%tmp1 = alloca %2, align 4
%tmp114 = getelementptr inbounds %2, %2* %tmp1, i64 0, i32 1
%tmp115 = bitcast i32* %tmp114 to <4 x i32>*
store <4 x i32> <i32 234567891, i32 345678912, i32 456789123, i32 0>, <4 x i32>* %tmp115, align 4
%tmp1683 = getelementptr inbounds %2, %2* %tmp1, i64 0, i32 1
%tmp1688 = load i32, i32* %tmp1683, align 4
%tmp114 = getelementptr inbounds %2, ptr %tmp1, i64 0, i32 1
store <4 x i32> <i32 234567891, i32 345678912, i32 456789123, i32 0>, ptr %tmp114, align 4
%tmp1683 = getelementptr inbounds %2, ptr %tmp1, i64 0, i32 1
%tmp1688 = load i32, ptr %tmp1683, align 4
%tmp1693 = shl i32 %tmp1688, 5
%tmp1694 = xor i32 %tmp1693, %tmp1688
%tmp1695 = lshr i32 %tmp1694, 7
Expand All @@ -36,10 +35,10 @@ define i32 @_Z16vector3util_mainv(i32 %x, i32 %y) {
%tmp1738 = xor i32 %tmp1737, %tmp1736
%tmp1739 = shl i32 %tmp1738, 22
%tmp1740 = xor i32 %tmp1739, %tmp1738
store i32 %tmp1740, i32* %tmp1683, align 4
; CHECK: store i32 310393545, i32* %tmp114, align 4
%tmp1756 = getelementptr inbounds %2, %2* %tmp1, i64 0, i32 1
%tmp1761 = load i32, i32* %tmp1756, align 4
store i32 %tmp1740, ptr %tmp1683, align 4
; CHECK: store i32 310393545, ptr %tmp114, align 4
%tmp1756 = getelementptr inbounds %2, ptr %tmp1, i64 0, i32 1
%tmp1761 = load i32, ptr %tmp1756, align 4
%tmp1766 = shl i32 %tmp1761, 5
%tmp1767 = xor i32 %tmp1766, %tmp1761
%tmp1768 = lshr i32 %tmp1767, 7
Expand All @@ -64,10 +63,10 @@ define i32 @_Z16vector3util_mainv(i32 %x, i32 %y) {
%tmp1811 = xor i32 %tmp1810, %tmp1809
%tmp1812 = shl i32 %tmp1811, 22
%tmp1813 = xor i32 %tmp1812, %tmp1811
store i32 %tmp1813, i32* %tmp1756, align 4
; CHECK: store i32 -383584258, i32* %tmp114, align 4
%tmp2645 = getelementptr inbounds %2, %2* %tmp1, i64 0, i32 1
%tmp2650 = load i32, i32* %tmp2645, align 4
store i32 %tmp1813, ptr %tmp1756, align 4
; CHECK: store i32 -383584258, ptr %tmp114, align 4
%tmp2645 = getelementptr inbounds %2, ptr %tmp1, i64 0, i32 1
%tmp2650 = load i32, ptr %tmp2645, align 4
%tmp2655 = shl i32 %tmp2650, 5
%tmp2656 = xor i32 %tmp2655, %tmp2650
%tmp2657 = lshr i32 %tmp2656, 7
Expand All @@ -92,7 +91,7 @@ define i32 @_Z16vector3util_mainv(i32 %x, i32 %y) {
%tmp2700 = xor i32 %tmp2699, %tmp2698
%tmp2701 = shl i32 %tmp2700, 22
%tmp2702 = xor i32 %tmp2701, %tmp2700
store i32 %tmp2702, i32* %tmp2645, align 4
; CHECK: store i32 -57163022, i32* %tmp114, align 4
store i32 %tmp2702, ptr %tmp2645, align 4
; CHECK: store i32 -57163022, ptr %tmp114, align 4
ret i32 0
}
26 changes: 13 additions & 13 deletions llvm/test/Transforms/NewGVN/funclet.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

%eh.ThrowInfo = type { i32, i8*, i8*, i8* }
%struct.A = type { i32* }
%eh.ThrowInfo = type { i32, ptr, ptr, ptr }
%struct.A = type { ptr }

@"_TI1?AUA@@" = external constant %eh.ThrowInfo

define i8 @f() personality i32 (...)* @__CxxFrameHandler3 {
define i8 @f() personality ptr @__CxxFrameHandler3 {
entry:
%b = alloca i8
%c = alloca i8
store i8 42, i8* %b
store i8 13, i8* %c
invoke void @_CxxThrowException(i8* %b, %eh.ThrowInfo* nonnull @"_TI1?AUA@@")
store i8 42, ptr %b
store i8 13, ptr %c
invoke void @_CxxThrowException(ptr %b, ptr nonnull @"_TI1?AUA@@")
to label %unreachable unwind label %catch.dispatch

catch.dispatch: ; preds = %entry
%cs1 = catchswitch within none [label %catch] unwind to caller

catch: ; preds = %catch.dispatch
%catchpad = catchpad within %cs1 [i8* null, i32 64, i8* null]
store i8 5, i8* %b
%catchpad = catchpad within %cs1 [ptr null, i32 64, ptr null]
store i8 5, ptr %b
catchret from %catchpad to label %try.cont

try.cont: ; preds = %catch
%load_b = load i8, i8* %b
%load_c = load i8, i8* %c
%load_b = load i8, ptr %b
%load_c = load i8, ptr %c
%add = add i8 %load_b, %load_c
ret i8 %add

unreachable: ; preds = %entry
unreachable
}
; CHECK-LABEL: define i8 @f(
; CHECK: %[[load_b:.*]] = load i8, i8* %b
; CHECK-NEXT: %[[load_c:.*]] = load i8, i8* %c
; CHECK: %[[load_b:.*]] = load i8, ptr %b
; CHECK-NEXT: %[[load_c:.*]] = load i8, ptr %c
; CHECK-NEXT: %[[add:.*]] = add i8 %[[load_b]], %[[load_c]]
; CHECK-NEXT: ret i8 %[[add]]

declare i32 @__CxxFrameHandler3(...)

declare x86_stdcallcc void @_CxxThrowException(i8*, %eh.ThrowInfo*)
declare x86_stdcallcc void @_CxxThrowException(ptr, ptr)
12 changes: 6 additions & 6 deletions llvm/test/Transforms/NewGVN/int_sideeffect.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ declare void @llvm.sideeffect()

; CHECK-LABEL: s2l
; CHECK-NOT: load
define float @s2l(float* %p) {
store float 0.0, float* %p
define float @s2l(ptr %p) {
store float 0.0, ptr %p
call void @llvm.sideeffect()
%t = load float, float* %p
%t = load float, ptr %p
ret float %t
}

Expand All @@ -18,10 +18,10 @@ define float @s2l(float* %p) {
; CHECK-LABEL: rle
; CHECK: load
; CHECK-NOT: load
define float @rle(float* %p) {
%r = load float, float* %p
define float @rle(ptr %p) {
%r = load float, ptr %p
call void @llvm.sideeffect()
%s = load float, float* %p
%s = load float, ptr %p
%t = fadd float %r, %s
ret float %t
}
342 changes: 159 additions & 183 deletions llvm/test/Transforms/NewGVN/invariant.group.ll

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions llvm/test/Transforms/NewGVN/invariant.start.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@
; RUN: opt < %s -passes=newgvn -S | FileCheck %s


declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) nounwind readonly
declare void @llvm.invariant.end.p0i8({}*, i64, i8* nocapture) nounwind
declare ptr @llvm.invariant.start.p0(i64, ptr nocapture) nounwind readonly
declare void @llvm.invariant.end.p0(ptr, i64, ptr nocapture) nounwind

; We forward store to the load across the invariant.start intrinsic
define i8 @forward_store() {
; CHECK-LABEL: @forward_store
; CHECK: call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
; CHECK: call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
; CHECK-NOT: load
; CHECK: ret i8 0
%a = alloca i8
store i8 0, i8* %a
%i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
%r = load i8, i8* %a
store i8 0, ptr %a
%i = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
%r = load i8, ptr %a
ret i8 %r
}

declare i8 @dummy(i8* nocapture) nounwind readonly
declare i8 @dummy(ptr nocapture) nounwind readonly

; We forward store to the load in the non-local analysis case,
; i.e. invariant.start is in another basic block.
define i8 @forward_store_nonlocal(i1 %cond) {
; CHECK-LABEL: forward_store_nonlocal
; CHECK: call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
; CHECK: call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
; CHECK: ret i8 0
; CHECK: ret i8 %val
%a = alloca i8
store i8 0, i8* %a
%i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
store i8 0, ptr %a
%i = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
br i1 %cond, label %loadblock, label %exit

loadblock:
%r = load i8, i8* %a
%r = load i8, ptr %a
ret i8 %r

exit:
%val = call i8 @dummy(i8* %a)
%val = call i8 @dummy(ptr %a)
ret i8 %val
}

; We should not value forward %foo to the invariant.end corresponding to %bar.
define i8 @forward_store1() {
; CHECK-LABEL: forward_store1
; CHECK: %foo = call {}* @llvm.invariant.start.p0i8
; CHECK: %foo = call ptr @llvm.invariant.start.p0
; CHECK-NOT: load
; CHECK: %bar = call {}* @llvm.invariant.start.p0i8
; CHECK: call void @llvm.invariant.end.p0i8({}* %bar, i64 1, i8* %a)
; CHECK: %bar = call ptr @llvm.invariant.start.p0
; CHECK: call void @llvm.invariant.end.p0(ptr %bar, i64 1, ptr %a)
; CHECK: ret i8 0
%a = alloca i8
store i8 0, i8* %a
%foo = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
%r = load i8, i8* %a
%bar = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %a)
call void @llvm.invariant.end.p0i8({}* %bar, i64 1, i8* %a)
store i8 0, ptr %a
%foo = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
%r = load i8, ptr %a
%bar = call ptr @llvm.invariant.start.p0(i64 1, ptr %a)
call void @llvm.invariant.end.p0(ptr %bar, i64 1, ptr %a)
ret i8 %r
}
16 changes: 8 additions & 8 deletions llvm/test/Transforms/NewGVN/lifetime-simple.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin7"

define i8 @test(i8* %P) nounwind {
define i8 @test(ptr %P) nounwind {
; CHECK: lifetime.start
; CHECK-NOT: load
; CHECK: lifetime.end
entry:
call void @llvm.lifetime.start.p0i8(i64 32, i8* %P)
%0 = load i8, i8* %P
store i8 1, i8* %P
call void @llvm.lifetime.end.p0i8(i64 32, i8* %P)
%1 = load i8, i8* %P
call void @llvm.lifetime.start.p0(i64 32, ptr %P)
%0 = load i8, ptr %P
store i8 1, ptr %P
call void @llvm.lifetime.end.p0(i64 32, ptr %P)
%1 = load i8, ptr %P
ret i8 %1
}

declare void @llvm.lifetime.start.p0i8(i64 %S, i8* nocapture %P) readonly
declare void @llvm.lifetime.end.p0i8(i64 %S, i8* nocapture %P)
declare void @llvm.lifetime.start.p0(i64 %S, ptr nocapture %P) readonly
declare void @llvm.lifetime.end.p0(i64 %S, ptr nocapture %P)
14 changes: 7 additions & 7 deletions llvm/test/Transforms/NewGVN/load-constant-mem.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
; PR4189
@G = external constant [4 x i32]

define i32 @test(i8* %p, i32 %i) nounwind {
define i32 @test(ptr %p, i32 %i) nounwind {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P:%.*]] = getelementptr [4 x i32], [4 x i32]* @G, i32 0, i32 [[I:%.*]]
; CHECK-NEXT: store i8 4, i8* [[P:%.*]]
; CHECK-NEXT: [[P:%.*]] = getelementptr [4 x i32], ptr @G, i32 0, i32 [[I:%.*]]
; CHECK-NEXT: store i8 4, ptr [[P:%.*]]
; CHECK-NEXT: ret i32 0
;
entry:
%P = getelementptr [4 x i32], [4 x i32]* @G, i32 0, i32 %i
%A = load i32, i32* %P
store i8 4, i8* %p
%B = load i32, i32* %P
%P = getelementptr [4 x i32], ptr @G, i32 0, i32 %i
%A = load i32, ptr %P
store i8 4, ptr %p
%B = load i32, ptr %P
%C = sub i32 %A, %B
ret i32 %C
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/test/Transforms/NewGVN/load-from-unreachable-predecessor.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
; Check that an unreachable predecessor to a PHI node doesn't cause a crash.
; PR21625.

define i32 @f(i32** %f) {
define i32 @f(ptr %f) {
; CHECK: bb0:
; Load should be removed, since it's ignored.
; CHECK-NEXT: br label
bb0:
%bar = load i32*, i32** %f
%bar = load ptr, ptr %f
br label %bb2
bb1:
%zed = load i32*, i32** %f
%zed = load ptr, ptr %f
br i1 false, label %bb1, label %bb2
bb2:
%foo = phi i32* [ null, %bb0 ], [ %zed, %bb1 ]
%storemerge = load i32, i32* %foo
%foo = phi ptr [ null, %bb0 ], [ %zed, %bb1 ]
%storemerge = load i32, ptr %foo
ret i32 %storemerge
}
14 changes: 6 additions & 8 deletions llvm/test/Transforms/NewGVN/loadforward.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
;; Test that we forward the first store to the second load
define i16 @bazinga() {
; CHECK-LABEL: @bazinga(
; CHECK-NEXT: [[_TMP10:%.*]] = load i16, i16* getelementptr inbounds (%rec11, %rec11* @str, i64 0, i32 1)
; CHECK-NEXT: store i16 [[_TMP10]], i16* getelementptr inbounds (%rec11, %rec11* @str, i64 0, i32 0)
; CHECK-NEXT: [[_TMP10:%.*]] = load i16, ptr getelementptr inbounds (%rec11, ptr @str, i64 0, i32 1)
; CHECK-NEXT: store i16 [[_TMP10]], ptr @str
; CHECK-NEXT: [[_TMP15:%.*]] = icmp eq i16 [[_TMP10]], 3
; CHECK-NEXT: [[_TMP16:%.*]] = select i1 [[_TMP15]], i16 1, i16 0
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: bb1:
; CHECK-NEXT: ret i16 [[_TMP16]]
;
%_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
%_tmp9 = getelementptr %rec11, ptr @str, i16 0, i32 1
%_tmp10 = load i16, ptr %_tmp9
store i16 %_tmp10, ptr @str
%_tmp14 = load i16, ptr @str
%_tmp15 = icmp eq i16 %_tmp14, 3
%_tmp16 = select i1 %_tmp15, i16 1, i16 0
br label %bb1
Expand Down
36 changes: 18 additions & 18 deletions llvm/test/Transforms/NewGVN/malloc-load-removal.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,63 @@
target 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"
target triple = "x86_64-apple-macosx10.8.0"

declare i8* @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc"
declare ptr @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc"

define noalias i8* @test1() nounwind uwtable ssp {
define noalias ptr @test1() nounwind uwtable ssp {
entry:
%call = tail call i8* @malloc(i64 100) nounwind
%0 = load i8, i8* %call, align 1
%call = tail call ptr @malloc(i64 100) nounwind
%0 = load i8, ptr %call, align 1
%tobool = icmp eq i8 %0, 0
br i1 %tobool, label %if.end, label %if.then

if.then: ; preds = %entry
store i8 0, i8* %call, align 1
store i8 0, ptr %call, align 1
br label %if.end

if.end: ; preds = %if.then, %entry
ret i8* %call
ret ptr %call

; CHECK-LABEL: @test1(
; CHECK-NOT: load
; CHECK-NOT: icmp
}

declare i8* @_Znwm(i64) nounwind
declare ptr @_Znwm(i64) nounwind

define noalias i8* @test2() nounwind uwtable ssp {
define noalias ptr @test2() nounwind uwtable ssp {
entry:
%call = tail call i8* @_Znwm(i64 100) nounwind
%0 = load i8, i8* %call, align 1
%call = tail call ptr @_Znwm(i64 100) nounwind
%0 = load i8, ptr %call, align 1
%tobool = icmp eq i8 %0, 0
br i1 %tobool, label %if.end, label %if.then

if.then: ; preds = %entry
store i8 0, i8* %call, align 1
store i8 0, ptr %call, align 1
br label %if.end

if.end: ; preds = %if.then, %entry
ret i8* %call
ret ptr %call

; CHECK-LABEL: @test2(
; CHECK-NOT: load
; CHECK-NOT: icmp
}

declare i8* @aligned_alloc(i64 allocalign, i64) nounwind allockind("alloc,uninitialized,aligned") allocsize(1) "alloc-family"="malloc"
declare ptr @aligned_alloc(i64 allocalign, i64) nounwind allockind("alloc,uninitialized,aligned") allocsize(1) "alloc-family"="malloc"

define noalias i8* @test3() nounwind uwtable ssp {
define noalias ptr @test3() nounwind uwtable ssp {
entry:
%call = tail call i8* @aligned_alloc(i64 256, i64 32) nounwind
%0 = load i8, i8* %call, align 32
%call = tail call ptr @aligned_alloc(i64 256, i64 32) nounwind
%0 = load i8, ptr %call, align 32
%tobool = icmp eq i8 %0, 0
br i1 %tobool, label %if.end, label %if.then

if.then: ; preds = %entry
store i8 0, i8* %call, align 1
store i8 0, ptr %call, align 1
br label %if.end

if.end: ; preds = %if.then, %entry
ret i8* %call
ret ptr %call

; CHECK-LABEL: @test3(
; CHECK-NOT: load
Expand Down
80 changes: 40 additions & 40 deletions llvm/test/Transforms/NewGVN/memory-handling.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,75 +13,75 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
declare void @Fatal(i8*, i32) local_unnamed_addr #0
declare void @Fatal(ptr, i32) local_unnamed_addr #0

; Function Attrs: nounwind readnone
declare i16** @__ctype_b_loc() local_unnamed_addr #1
declare ptr @__ctype_b_loc() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define void @BuildMask(i8* nocapture readonly) local_unnamed_addr #0 {
tail call void @llvm.memset.p0i8.i64(i8* align 16 bitcast ([26 x %struct.Letter]* @alPhrase to i8*), i8 0, i64 416, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 16 bitcast ([2 x i64]* @aqMainMask to i8*), i8 0, i64 16, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 16 bitcast ([2 x i64]* @aqMainSign to i8*), i8 0, i64 16, i1 false)
define void @BuildMask(ptr nocapture readonly) local_unnamed_addr #0 {
tail call void @llvm.memset.p0.i64(ptr align 16 @alPhrase, i8 0, i64 416, i1 false)
tail call void @llvm.memset.p0.i64(ptr align 16 @aqMainMask, i8 0, i64 16, i1 false)
tail call void @llvm.memset.p0.i64(ptr align 16 @aqMainSign, i8 0, i64 16, i1 false)
br label %.sink.split

.sink.split: ; preds = %14, %1
%.0 = phi i8* [ %0, %1 ], [ %.lcssa67, %14 ]
%.0 = phi ptr [ %0, %1 ], [ %.lcssa67, %14 ]
%.sink = phi i32 [ 0, %1 ], [ %23, %14 ]
store i32 %.sink, i32* @cchPhraseLength, align 4, !tbaa !1
store i32 %.sink, ptr @cchPhraseLength, align 4, !tbaa !1
br label %2

; <label>:2: ; preds = %6, %.sink.split
%.1 = phi i8* [ %.0, %.sink.split ], [ %3, %6 ]
%3 = getelementptr inbounds i8, i8* %.1, i64 1
%4 = load i8, i8* %.1, align 1, !tbaa !5
%.1 = phi ptr [ %.0, %.sink.split ], [ %3, %6 ]
%3 = getelementptr inbounds i8, ptr %.1, i64 1
%4 = load i8, ptr %.1, align 1, !tbaa !5
%5 = icmp eq i8 %4, 0
br i1 %5, label %.preheader.preheader, label %6

.preheader.preheader: ; preds = %2
br label %.preheader

; <label>:6: ; preds = %2
%7 = tail call i16** @__ctype_b_loc() #4
%8 = load i16*, i16** %7, align 8, !tbaa !6
%7 = tail call ptr @__ctype_b_loc() #4
%8 = load ptr, ptr %7, align 8, !tbaa !6
%9 = sext i8 %4 to i64
%10 = getelementptr inbounds i16, i16* %8, i64 %9
%11 = load i16, i16* %10, align 2, !tbaa !8
%10 = getelementptr inbounds i16, ptr %8, i64 %9
%11 = load i16, ptr %10, align 2, !tbaa !8
%12 = and i16 %11, 1024
%13 = icmp eq i16 %12, 0
br i1 %13, label %2, label %14

; <label>:14: ; preds = %6
%.lcssa67 = phi i8* [ %3, %6 ]
%.lcssa67 = phi ptr [ %3, %6 ]
%.lcssa65 = phi i8 [ %4, %6 ]
%15 = sext i8 %.lcssa65 to i32
%16 = tail call i32 @tolower(i32 %15) #5
%17 = add nsw i32 %16, -97
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %18, i32 0
%20 = load i32, i32* %19, align 16, !tbaa !10
%19 = getelementptr inbounds [26 x %struct.Letter], ptr @alPhrase, i64 0, i64 %18, i32 0
%20 = load i32, ptr %19, align 16, !tbaa !10
%21 = add i32 %20, 1
store i32 %21, i32* %19, align 16, !tbaa !10
%22 = load i32, i32* @cchPhraseLength, align 4, !tbaa !1
store i32 %21, ptr %19, align 16, !tbaa !10
%22 = load i32, ptr @cchPhraseLength, align 4, !tbaa !1
%23 = add nsw i32 %22, 1
br label %.sink.split

.preheader: ; preds = %58, %.preheader.preheader
%indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %58 ]
%.04961 = phi i32 [ %.2, %58 ], [ 0, %.preheader.preheader ]
%.05160 = phi i32 [ %.253, %58 ], [ 0, %.preheader.preheader ]
%24 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 0
%25 = load i32, i32* %24, align 16, !tbaa !10
%24 = getelementptr inbounds [26 x %struct.Letter], ptr @alPhrase, i64 0, i64 %indvars.iv, i32 0
%25 = load i32, ptr %24, align 16, !tbaa !10
%26 = icmp eq i32 %25, 0
%27 = getelementptr inbounds [26 x i32], [26 x i32]* @auGlobalFrequency, i64 0, i64 %indvars.iv
%27 = getelementptr inbounds [26 x i32], ptr @auGlobalFrequency, i64 0, i64 %indvars.iv
br i1 %26, label %28, label %29

; <label>:28: ; preds = %.preheader
store i32 -1, i32* %27, align 4, !tbaa !1
store i32 -1, ptr %27, align 4, !tbaa !1
br label %58

; <label>:29: ; preds = %.preheader
store i32 0, i32* %27, align 4, !tbaa !1
store i32 0, ptr %27, align 4, !tbaa !1
%30 = zext i32 %25 to i64
br i1 false, label %._crit_edge, label %.lr.ph.preheader

Expand Down Expand Up @@ -119,34 +119,34 @@ define void @BuildMask(i8* nocapture readonly) local_unnamed_addr #0 {
br i1 %38, label %39, label %40

; <label>:39: ; preds = %36
tail call void @Fatal(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 0)
tail call void @Fatal(ptr @.str.7, i32 0)
br label %40

; <label>:40: ; preds = %39, %36, %._crit_edge
%.152 = phi i32 [ %.05160, %._crit_edge ], [ %37, %39 ], [ %37, %36 ]
%.150 = phi i32 [ %.04961, %._crit_edge ], [ 0, %39 ], [ 0, %36 ]
%41 = add i64 %.046.lcssa, 4294967295
%42 = trunc i64 %41 to i32
%43 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 2
store i32 %42, i32* %43, align 8, !tbaa !12
%43 = getelementptr inbounds [26 x %struct.Letter], ptr @alPhrase, i64 0, i64 %indvars.iv, i32 2
store i32 %42, ptr %43, align 8, !tbaa !12
%44 = zext i32 %.150 to i64
%.046. = shl i64 %.046.lcssa, %44
%45 = zext i32 %.152 to i64
%46 = getelementptr inbounds [2 x i64], [2 x i64]* @aqMainSign, i64 0, i64 %45
%47 = load i64, i64* %46, align 8, !tbaa !13
%46 = getelementptr inbounds [2 x i64], ptr @aqMainSign, i64 0, i64 %45
%47 = load i64, ptr %46, align 8, !tbaa !13
%48 = or i64 %47, %.046.
store i64 %48, i64* %46, align 8, !tbaa !13
%49 = load i32, i32* %24, align 16, !tbaa !10
store i64 %48, ptr %46, align 8, !tbaa !13
%49 = load i32, ptr %24, align 16, !tbaa !10
%50 = zext i32 %49 to i64
%51 = shl i64 %50, %44
%52 = getelementptr inbounds [2 x i64], [2 x i64]* @aqMainMask, i64 0, i64 %45
%53 = load i64, i64* %52, align 8, !tbaa !13
%52 = getelementptr inbounds [2 x i64], ptr @aqMainMask, i64 0, i64 %45
%53 = load i64, ptr %52, align 8, !tbaa !13
%54 = or i64 %51, %53
store i64 %54, i64* %52, align 8, !tbaa !13
%55 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 1
store i32 %.150, i32* %55, align 4, !tbaa !15
%56 = getelementptr inbounds [26 x %struct.Letter], [26 x %struct.Letter]* @alPhrase, i64 0, i64 %indvars.iv, i32 3
store i32 %.152, i32* %56, align 4, !tbaa !16
store i64 %54, ptr %52, align 8, !tbaa !13
%55 = getelementptr inbounds [26 x %struct.Letter], ptr @alPhrase, i64 0, i64 %indvars.iv, i32 1
store i32 %.150, ptr %55, align 4, !tbaa !15
%56 = getelementptr inbounds [26 x %struct.Letter], ptr @alPhrase, i64 0, i64 %indvars.iv, i32 3
store i32 %.152, ptr %56, align 4, !tbaa !16
%57 = add nsw i32 %.150, %.048.lcssa
br label %58

Expand All @@ -162,7 +162,7 @@ define void @BuildMask(i8* nocapture readonly) local_unnamed_addr #0 {
}

; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) #2
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1) #2

; Function Attrs: inlinehint nounwind readonly uwtable
declare i32 @tolower(i32) local_unnamed_addr #3
Expand Down
158 changes: 79 additions & 79 deletions llvm/test/Transforms/NewGVN/metadata-nonnull.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,175 +2,175 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i8* @test1(i8** %v0, i8** %v1) {
define ptr @test1(ptr %v0, ptr %v1) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: top:
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
; CHECK-NEXT: ret i8* [[V2]]
; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: store ptr [[V2]], ptr [[V1:%.*]]
; CHECK-NEXT: ret ptr [[V2]]
;
top:
%v2 = load i8*, i8** %v0, !nonnull !0
store i8* %v2, i8** %v1
%v3 = load i8*, i8** %v1
ret i8* %v3
%v2 = load ptr, ptr %v0, !nonnull !0
store ptr %v2, ptr %v1
%v3 = load ptr, ptr %v1
ret ptr %v3
}

; FIXME: could propagate nonnull to first load?
define i8* @test2(i8** %v0, i8** %v1) {
define ptr @test2(ptr %v0, ptr %v1) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: top:
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
; CHECK-NEXT: ret i8* [[V2]]
; CHECK-NEXT: store ptr [[V2]], ptr [[V1:%.*]]
; CHECK-NEXT: ret ptr [[V2]]
;
top:
%v2 = load i8*, i8** %v0
store i8* %v2, i8** %v1
%v3 = load i8*, i8** %v1, !nonnull !0
ret i8* %v3
%v2 = load ptr, ptr %v0
store ptr %v2, ptr %v1
%v3 = load ptr, ptr %v1, !nonnull !0
ret ptr %v3
}

declare void @use1(i8* %a) readonly
declare void @use1(ptr %a) readonly

define i8* @test3(i8** %v0) {
define ptr @test3(ptr %v0) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: top:
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: call void @use1(i8* [[V1]])
; CHECK-NEXT: call void @use1(ptr [[V1]])
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: ret i8* [[V1]]
; CHECK-NEXT: ret ptr [[V1]]
; CHECK: bb2:
; CHECK-NEXT: ret i8* [[V1]]
; CHECK-NEXT: ret ptr [[V1]]
;
top:
%v1 = load i8*, i8** %v0
call void @use1(i8* %v1)
%v1 = load ptr, ptr %v0
call void @use1(ptr %v1)
br i1 undef, label %bb1, label %bb2

bb1:
%v2 = load i8*, i8** %v0, !nonnull !0
ret i8* %v2
%v2 = load ptr, ptr %v0, !nonnull !0
ret ptr %v2

bb2:
%v3 = load i8*, i8** %v0
ret i8* %v3
%v3 = load ptr, ptr %v0
ret ptr %v3
}

define i8* @test4(i8** %v0) {
define ptr @test4(ptr %v0) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: top:
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: call void @use1(i8* [[V1]])
; CHECK-NEXT: call void @use1(ptr [[V1]])
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: ret i8* [[V1]]
; CHECK-NEXT: ret ptr [[V1]]
; CHECK: bb2:
; CHECK-NEXT: ret i8* [[V1]]
; CHECK-NEXT: ret ptr [[V1]]
;
top:
%v1 = load i8*, i8** %v0
call void @use1(i8* %v1)
%v1 = load ptr, ptr %v0
call void @use1(ptr %v1)
br i1 undef, label %bb1, label %bb2

bb1:
%v2 = load i8*, i8** %v0
ret i8* %v2
%v2 = load ptr, ptr %v0
ret ptr %v2

bb2:
%v3 = load i8*, i8** %v0, !nonnull !0
ret i8* %v3
%v3 = load ptr, ptr %v0, !nonnull !0
ret ptr %v3
}

define i8* @test5(i8** %v0) {
define ptr @test5(ptr %v0) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: top:
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: call void @use1(i8* [[V1]])
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: call void @use1(ptr [[V1]])
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: ret i8* [[V1]]
; CHECK-NEXT: ret ptr [[V1]]
; CHECK: bb2:
; CHECK-NEXT: ret i8* [[V1]]
; CHECK-NEXT: ret ptr [[V1]]
;
top:
%v1 = load i8*, i8** %v0, !nonnull !0
call void @use1(i8* %v1)
%v1 = load ptr, ptr %v0, !nonnull !0
call void @use1(ptr %v1)
br i1 undef, label %bb1, label %bb2

bb1:
%v2 = load i8*, i8** %v0
ret i8* %v2
%v2 = load ptr, ptr %v0
ret ptr %v2

bb2:
%v3 = load i8*, i8** %v0
ret i8* %v3
%v3 = load ptr, ptr %v0
ret ptr %v3
}

define i8* @test6(i8** %v0, i8** %v1) {
define ptr @test6(ptr %v0, ptr %v1) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: top:
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
; CHECK-NEXT: ret i8* [[V2]]
; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: store ptr [[V2]], ptr [[V1:%.*]]
; CHECK-NEXT: ret ptr [[V2]]
; CHECK: bb2:
; CHECK-NEXT: [[V4:%.*]] = load i8*, i8** [[V0]]
; CHECK-NEXT: [[V4:%.*]] = load ptr, ptr [[V0]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: store i8* [[V4]], i8** [[V1]]
; CHECK-NEXT: store ptr [[V4]], ptr [[V1]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: ret i8* [[V4]]
; CHECK-NEXT: ret ptr [[V4]]
;
top:
br i1 undef, label %bb1, label %bb2

bb1:
%v2 = load i8*, i8** %v0, !nonnull !0
store i8* %v2, i8** %v1
%v3 = load i8*, i8** %v1
ret i8* %v3
%v2 = load ptr, ptr %v0, !nonnull !0
store ptr %v2, ptr %v1
%v3 = load ptr, ptr %v1
ret ptr %v3

bb2:
%v4 = load i8*, i8** %v0
store i8* %v4, i8** %v1
%v5 = load i8*, i8** %v1, !nonnull !0
ret i8* %v5
%v4 = load ptr, ptr %v0
store ptr %v4, ptr %v1
%v5 = load ptr, ptr %v1, !nonnull !0
ret ptr %v5
}

declare void @use2(i8* %a)
declare void @use2(ptr %a)

define i8* @test7(i8** %v0) {
define ptr @test7(ptr %v0) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: top:
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: call void @use2(i8* [[V1]])
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0:%[a-z0-9]+]], align 8, !nonnull !0
; CHECK-NEXT: call void @use2(ptr [[V1]])
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0]]
; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: ret i8* [[V2]]
; CHECK-NEXT: ret ptr [[V2]]
; CHECK: bb2:
; CHECK-NEXT: [[V3:%.*]] = load i8*, i8** [[V0]]
; CHECK-NEXT: [[V3:%.*]] = load ptr, ptr [[V0]]
; CHECK-NOT: !nonnull
; CHECK-NEXT: ret i8* [[V3]]
; CHECK-NEXT: ret ptr [[V3]]
;
top:
%v1 = load i8*, i8** %v0, !nonnull !0
call void @use2(i8* %v1)
%v1 = load ptr, ptr %v0, !nonnull !0
call void @use2(ptr %v1)
br i1 undef, label %bb1, label %bb2

bb1:
%v2 = load i8*, i8** %v0
ret i8* %v2
%v2 = load ptr, ptr %v0
ret ptr %v2

bb2:
%v3 = load i8*, i8** %v0
ret i8* %v3
%v3 = load ptr, ptr %v0
ret ptr %v3
}

!0 = !{}
76 changes: 38 additions & 38 deletions llvm/test/Transforms/NewGVN/metadata-simplify.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,153 +5,153 @@

; RUN: opt < %s -S -passes=newgvn | FileCheck %s

define i1 @test1(i32** %arg, i1 %arg2) {
define i1 @test1(ptr %arg, i1 %arg2) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[LOAD1:%.*]] = load i32*, i32** [[ARG:%.*]], !nonnull !0
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32* [[LOAD1]], null
; CHECK-NEXT: [[LOAD1:%.*]] = load ptr, ptr [[ARG:%.*]], !nonnull !0
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[LOAD1]], null
; CHECK-NEXT: ret i1 [[CMP1]]
; CHECK: bb2:
; CHECK-NEXT: [[LOAD2:%.*]] = load i32*, i32** [[ARG]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32* [[LOAD2]], null
; CHECK-NEXT: [[LOAD2:%.*]] = load ptr, ptr [[ARG]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq ptr [[LOAD2]], null
; CHECK-NEXT: ret i1 [[CMP2]]
;
br i1 %arg2, label %bb1, label %bb2

bb1:
%load1 = load i32*, i32** %arg, !nonnull !0
%cmp1 = icmp eq i32* %load1, null
%load1 = load ptr, ptr %arg, !nonnull !0
%cmp1 = icmp eq ptr %load1, null
ret i1 %cmp1

bb2:
%load2 = load i32*, i32** %arg
%cmp2 = icmp eq i32* %load2, null
%load2 = load ptr, ptr %arg
%cmp2 = icmp eq ptr %load2, null
ret i1 %cmp2
}

define i1 @test2(i32** %arg, i1 %arg2) {
define i1 @test2(ptr %arg, i1 %arg2) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[LOAD1:%.*]] = load i32*, i32** [[ARG:%.*]]
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32* [[LOAD1]], null
; CHECK-NEXT: [[LOAD1:%.*]] = load ptr, ptr [[ARG:%.*]]
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[LOAD1]], null
; CHECK-NEXT: ret i1 [[CMP1]]
; CHECK: bb2:
; CHECK-NEXT: [[LOAD2:%.*]] = load i32*, i32** [[ARG]], !nonnull !0
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32* [[LOAD2]], null
; CHECK-NEXT: [[LOAD2:%.*]] = load ptr, ptr [[ARG]], !nonnull !0
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq ptr [[LOAD2]], null
; CHECK-NEXT: ret i1 [[CMP2]]
;
br i1 %arg2, label %bb1, label %bb2

bb1:
%load1 = load i32*, i32** %arg
%cmp1 = icmp eq i32* %load1, null
%load1 = load ptr, ptr %arg
%cmp1 = icmp eq ptr %load1, null
ret i1 %cmp1

bb2:
%load2 = load i32*, i32** %arg, !nonnull !0
%cmp2 = icmp eq i32* %load2, null
%load2 = load ptr, ptr %arg, !nonnull !0
%cmp2 = icmp eq ptr %load2, null
ret i1 %cmp2
}


define i1 @test3(i32* %ptr, i1 %arg2) {
define i1 @test3(ptr %ptr, i1 %arg2) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, i32* [[PTR:%.*]], !range !1
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr [[PTR:%.*]], !range !1
; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[LOAD1]], 999
; CHECK-NEXT: ret i1 [[CMP1]]
; CHECK: bb2:
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, i32* [[PTR]]
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr [[PTR]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[LOAD2]], 999
; CHECK-NEXT: ret i1 [[CMP2]]
;
br i1 %arg2, label %bb1, label %bb2

bb1:
%load1 = load i32, i32* %ptr, !range !1
%load1 = load i32, ptr %ptr, !range !1
%cmp1 = icmp ne i32 %load1, 999
ret i1 %cmp1

bb2:
%load2 = load i32, i32* %ptr
%load2 = load i32, ptr %ptr
%cmp2 = icmp ne i32 %load2, 999
ret i1 %cmp2
}

define i1 @test4(i32* %ptr, i1 %arg2) {
define i1 @test4(ptr %ptr, i1 %arg2) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, i32* [[PTR:%.*]]
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr [[PTR:%.*]]
; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[LOAD1]], 999
; CHECK-NEXT: ret i1 [[CMP1]]
; CHECK: bb2:
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, i32* [[PTR]], !range !1
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr [[PTR]], !range !1
; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[LOAD2]], 999
; CHECK-NEXT: ret i1 [[CMP2]]
;
br i1 %arg2, label %bb1, label %bb2

bb1:
%load1 = load i32, i32* %ptr
%load1 = load i32, ptr %ptr
%cmp1 = icmp ne i32 %load1, 999
ret i1 %cmp1

bb2:
%load2 = load i32, i32* %ptr, !range !1
%load2 = load i32, ptr %ptr, !range !1
%cmp2 = icmp ne i32 %load2, 999
ret i1 %cmp2
}

define i1 @test5(i32* %ptr, i1 %arg2) {
define i1 @test5(ptr %ptr, i1 %arg2) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, i32* [[PTR:%.*]], !range !1
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr [[PTR:%.*]], !range !1
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[LOAD1]], 999
; CHECK-NEXT: ret i1 [[CMP1]]
; CHECK: bb2:
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, i32* [[PTR]]
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr [[PTR]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[LOAD2]], 999
; CHECK-NEXT: ret i1 [[CMP2]]
;
br i1 %arg2, label %bb1, label %bb2

bb1:
%load1 = load i32, i32* %ptr, !range !1
%load1 = load i32, ptr %ptr, !range !1
%cmp1 = icmp slt i32 %load1, 999
ret i1 %cmp1

bb2:
%load2 = load i32, i32* %ptr
%load2 = load i32, ptr %ptr
%cmp2 = icmp slt i32 %load2, 999
ret i1 %cmp2
}

define i1 @test6(i32* %ptr, i1 %arg2) {
define i1 @test6(ptr %ptr, i1 %arg2) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, i32* [[PTR:%.*]]
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr [[PTR:%.*]]
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[LOAD1]], 999
; CHECK-NEXT: ret i1 [[CMP1]]
; CHECK: bb2:
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, i32* [[PTR]], !range !1
; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr [[PTR]], !range !1
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[LOAD2]], 999
; CHECK-NEXT: ret i1 [[CMP2]]
;
br i1 %arg2, label %bb1, label %bb2

bb1:
%load1 = load i32, i32* %ptr
%load1 = load i32, ptr %ptr
%cmp1 = icmp slt i32 %load1, 999
ret i1 %cmp1

bb2:
%load2 = load i32, i32* %ptr, !range !1
%load2 = load i32, ptr %ptr, !range !1
%cmp2 = icmp slt i32 %load2, 999
ret i1 %cmp2
}
Expand Down
32 changes: 16 additions & 16 deletions llvm/test/Transforms/NewGVN/noalias.ll
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
; RUN: opt -passes=newgvn -S < %s | FileCheck %s

define i32 @test1(i32* %p, i32* %q) {
; CHECK-LABEL: @test1(i32* %p, i32* %q)
; CHECK: load i32, i32* %p
define i32 @test1(ptr %p, ptr %q) {
; CHECK-LABEL: @test1(ptr %p, ptr %q)
; CHECK: load i32, ptr %p
; CHECK-NOT: noalias
; CHECK: %c = add i32 %a, %a
%a = load i32, i32* %p, !noalias !3
%b = load i32, i32* %p
%a = load i32, ptr %p, !noalias !3
%b = load i32, ptr %p
%c = add i32 %a, %b
ret i32 %c
}

define i32 @test2(i32* %p, i32* %q) {
; CHECK-LABEL: @test2(i32* %p, i32* %q)
; CHECK: load i32, i32* %p, align 4, !alias.scope ![[SCOPE1:[0-9]+]]
define i32 @test2(ptr %p, ptr %q) {
; CHECK-LABEL: @test2(ptr %p, ptr %q)
; CHECK: load i32, ptr %p, align 4, !alias.scope ![[SCOPE1:[0-9]+]]
; CHECK: %c = add i32 %a, %a
%a = load i32, i32* %p, !alias.scope !3
%b = load i32, i32* %p, !alias.scope !3
%a = load i32, ptr %p, !alias.scope !3
%b = load i32, ptr %p, !alias.scope !3
%c = add i32 %a, %b
ret i32 %c
}

define i32 @test3(i32* %p, i32* %q) {
; CHECK-LABEL: @test3(i32* %p, i32* %q)
; CHECK: load i32, i32* %p, align 4, !alias.scope ![[SCOPE2:[0-9]+]]
define i32 @test3(ptr %p, ptr %q) {
; CHECK-LABEL: @test3(ptr %p, ptr %q)
; CHECK: load i32, ptr %p, align 4, !alias.scope ![[SCOPE2:[0-9]+]]
; CHECK: %c = add i32 %a, %a
%a = load i32, i32* %p, !alias.scope !4
%b = load i32, i32* %p, !alias.scope !5
%a = load i32, ptr %p, !alias.scope !4
%b = load i32, ptr %p, !alias.scope !5
%c = add i32 %a, %b
ret i32 %c
}

; CHECK: ![[SCOPE1]] = !{!{{[0-9]+}}}
; CHECK: ![[SCOPE2]] = !{!{{[0-9]+}}, !{{[0-9]+}}}
declare i32 @foo(i32*) readonly
declare i32 @foo(ptr) readonly

!0 = distinct !{!0, !2, !"callee0: %a"}
!1 = distinct !{!1, !2, !"callee0: %b"}
Expand Down
16 changes: 7 additions & 9 deletions llvm/test/Transforms/NewGVN/non-integral-pointers.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,33 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:4"
target triple = "x86_64-unknown-linux-gnu"

define void @f0(i1 %alwaysFalse, i64 %val, i64* %loc) {
define void @f0(i1 %alwaysFalse, i64 %val, ptr %loc) {
; CHECK-LABEL: @f0(
; CHECK-NOT: inttoptr
; CHECK-NOT: ptrtoint
entry:
store i64 %val, i64* %loc
store i64 %val, ptr %loc
br i1 %alwaysFalse, label %neverTaken, label %alwaysTaken

neverTaken:
%loc.bc = bitcast i64* %loc to i8 addrspace(4)**
%ptr = load i8 addrspace(4)*, i8 addrspace(4)** %loc.bc
store i8 5, i8 addrspace(4)* %ptr
%ptr = load ptr addrspace(4), ptr %loc
store i8 5, ptr addrspace(4) %ptr
ret void

alwaysTaken:
ret void
}

define i64 @f1(i1 %alwaysFalse, i8 addrspace(4)* %val, i8 addrspace(4)** %loc) {
define i64 @f1(i1 %alwaysFalse, ptr addrspace(4) %val, ptr %loc) {
; CHECK-LABEL: @f1(
; CHECK-NOT: inttoptr
; CHECK-NOT: ptrtoint
entry:
store i8 addrspace(4)* %val, i8 addrspace(4)** %loc
store ptr addrspace(4) %val, ptr %loc
br i1 %alwaysFalse, label %neverTaken, label %alwaysTaken

neverTaken:
%loc.bc = bitcast i8 addrspace(4)** %loc to i64*
%int = load i64, i64* %loc.bc
%int = load i64, ptr %loc
ret i64 %int

alwaysTaken:
Expand Down
107 changes: 50 additions & 57 deletions llvm/test/Transforms/NewGVN/nonescaping-malloc-xfail.ll
Original file line number Diff line number Diff line change
Expand Up @@ -15,98 +15,91 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
target triple = "x86_64-apple-darwin10.0"

%"struct.llvm::MallocAllocator" = type <{ i8 }>
%"struct.llvm::StringMap<void*,llvm::MallocAllocator>" = type { %"struct.llvm::StringMapImpl", %"struct.llvm::MallocAllocator" }
%"struct.llvm::StringMapEntry<void*>" = type { %"struct.llvm::StringMapEntryBase", i8* }
%"struct.llvm::StringMap<ptr,llvm::MallocAllocator>" = type { %"struct.llvm::StringMapImpl", %"struct.llvm::MallocAllocator" }
%"struct.llvm::StringMapEntry<ptr>" = type { %"struct.llvm::StringMapEntryBase", ptr }
%"struct.llvm::StringMapEntryBase" = type { i32 }
%"struct.llvm::StringMapImpl" = type { %"struct.llvm::StringMapImpl::ItemBucket"*, i32, i32, i32, i32 }
%"struct.llvm::StringMapImpl::ItemBucket" = type { i32, %"struct.llvm::StringMapEntryBase"* }
%"struct.llvm::StringRef" = type { i8*, i64 }
%"struct.llvm::StringMapImpl" = type { ptr, i32, i32, i32, i32 }
%"struct.llvm::StringMapImpl::ItemBucket" = type { i32, ptr }
%"struct.llvm::StringRef" = type { ptr, i64 }

define %"struct.llvm::StringMapEntry<void*>"* @_Z3fooRN4llvm9StringMapIPvNS_15MallocAllocatorEEEPKc(%"struct.llvm::StringMap<void*,llvm::MallocAllocator>"* %X, i8* %P) ssp {
define ptr @_Z3fooRN4llvm9StringMapIPvNS_15MallocAllocatorEEEPKc(ptr %X, ptr %P) ssp {
entry:
%tmp = alloca %"struct.llvm::StringRef", align 8
%tmp.i = getelementptr inbounds %"struct.llvm::StringRef", %"struct.llvm::StringRef"* %tmp, i64 0, i32 0
store i8* %P, i8** %tmp.i, align 8
%tmp1.i = call i64 @strlen(i8* %P) nounwind readonly
%tmp2.i = getelementptr inbounds %"struct.llvm::StringRef", %"struct.llvm::StringRef"* %tmp, i64 0, i32 1
store i64 %tmp1.i, i64* %tmp2.i, align 8
%tmp1 = call %"struct.llvm::StringMapEntry<void*>"* @_ZN4llvm9StringMapIPvNS_15MallocAllocatorEE16GetOrCreateValueERKNS_9StringRefE(%"struct.llvm::StringMap<void*,llvm::MallocAllocator>"* %X, %"struct.llvm::StringRef"* %tmp) ssp
ret %"struct.llvm::StringMapEntry<void*>"* %tmp1
store ptr %P, ptr %tmp, align 8
%tmp1.i = call i64 @strlen(ptr %P) nounwind readonly
%tmp2.i = getelementptr inbounds %"struct.llvm::StringRef", ptr %tmp, i64 0, i32 1
store i64 %tmp1.i, ptr %tmp2.i, align 8
%tmp1 = call ptr @_ZN4llvm9StringMapIPvNS_15MallocAllocatorEE16GetOrCreateValueERKNS_9StringRefE(ptr %X, ptr %tmp) ssp
ret ptr %tmp1
}

declare i64 @strlen(i8* nocapture) nounwind readonly
declare i64 @strlen(ptr nocapture) nounwind readonly

declare noalias i8* @malloc(i64) nounwind
declare noalias ptr @malloc(i64) nounwind

declare i32 @_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefE(%"struct.llvm::StringMapImpl"*, i64, i64)
declare i32 @_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefE(ptr, i64, i64)

define linkonce_odr %"struct.llvm::StringMapEntry<void*>"* @_ZN4llvm9StringMapIPvNS_15MallocAllocatorEE16GetOrCreateValueERKNS_9StringRefE(%"struct.llvm::StringMap<void*,llvm::MallocAllocator>"* %this, %"struct.llvm::StringRef"* nocapture %Key) ssp align 2 {
define linkonce_odr ptr @_ZN4llvm9StringMapIPvNS_15MallocAllocatorEE16GetOrCreateValueERKNS_9StringRefE(ptr %this, ptr nocapture %Key) ssp align 2 {
entry:
%elt = bitcast %"struct.llvm::StringRef"* %Key to i64*
%val = load i64, i64* %elt
%tmp = getelementptr inbounds %"struct.llvm::StringRef", %"struct.llvm::StringRef"* %Key, i64 0, i32 1
%val2 = load i64, i64* %tmp
%tmp2.i = getelementptr inbounds %"struct.llvm::StringMap<void*,llvm::MallocAllocator>", %"struct.llvm::StringMap<void*,llvm::MallocAllocator>"* %this, i64 0, i32 0
%tmp3.i = tail call i32 @_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefE(%"struct.llvm::StringMapImpl"* %tmp2.i, i64 %val, i64 %val2)
%tmp4.i = getelementptr inbounds %"struct.llvm::StringMap<void*,llvm::MallocAllocator>", %"struct.llvm::StringMap<void*,llvm::MallocAllocator>"* %this, i64 0, i32 0, i32 0
%tmp5.i = load %"struct.llvm::StringMapImpl::ItemBucket"*, %"struct.llvm::StringMapImpl::ItemBucket"** %tmp4.i, align 8
%val = load i64, ptr %Key
%tmp = getelementptr inbounds %"struct.llvm::StringRef", ptr %Key, i64 0, i32 1
%val2 = load i64, ptr %tmp
%tmp2.i = getelementptr inbounds %"struct.llvm::StringMap<ptr,llvm::MallocAllocator>", ptr %this, i64 0, i32 0
%tmp3.i = tail call i32 @_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefE(ptr %tmp2.i, i64 %val, i64 %val2)
%tmp4.i = getelementptr inbounds %"struct.llvm::StringMap<ptr,llvm::MallocAllocator>", ptr %this, i64 0, i32 0, i32 0
%tmp5.i = load ptr, ptr %tmp4.i, align 8
%tmp6.i = zext i32 %tmp3.i to i64
%tmp7.i = getelementptr inbounds %"struct.llvm::StringMapImpl::ItemBucket", %"struct.llvm::StringMapImpl::ItemBucket"* %tmp5.i, i64 %tmp6.i, i32 1
%tmp8.i = load %"struct.llvm::StringMapEntryBase"*, %"struct.llvm::StringMapEntryBase"** %tmp7.i, align 8
%tmp9.i = icmp eq %"struct.llvm::StringMapEntryBase"* %tmp8.i, null
%tmp13.i = icmp eq %"struct.llvm::StringMapEntryBase"* %tmp8.i, inttoptr (i64 -1 to %"struct.llvm::StringMapEntryBase"*)
%tmp7.i = getelementptr inbounds %"struct.llvm::StringMapImpl::ItemBucket", ptr %tmp5.i, i64 %tmp6.i, i32 1
%tmp8.i = load ptr, ptr %tmp7.i, align 8
%tmp9.i = icmp eq ptr %tmp8.i, null
%tmp13.i = icmp eq ptr %tmp8.i, inttoptr (i64 -1 to ptr)
%or.cond.i = or i1 %tmp9.i, %tmp13.i
br i1 %or.cond.i, label %bb4.i, label %bb6.i

bb4.i: ; preds = %entry
%tmp41.i = inttoptr i64 %val to i8*
%tmp4.i35.i = getelementptr inbounds i8, i8* %tmp41.i, i64 %val2
%tmp.i.i = ptrtoint i8* %tmp4.i35.i to i64
%tmp41.i = inttoptr i64 %val to ptr
%tmp4.i35.i = getelementptr inbounds i8, ptr %tmp41.i, i64 %val2
%tmp.i.i = ptrtoint ptr %tmp4.i35.i to i64
%tmp1.i.i = trunc i64 %tmp.i.i to i32
%tmp3.i.i = trunc i64 %val to i32
%tmp4.i.i = sub i32 %tmp1.i.i, %tmp3.i.i
%tmp5.i.i = add i32 %tmp4.i.i, 17
%tmp8.i.i = zext i32 %tmp5.i.i to i64
%tmp.i20.i.i = tail call noalias i8* @malloc(i64 %tmp8.i.i) nounwind
%tmp10.i.i = bitcast i8* %tmp.i20.i.i to %"struct.llvm::StringMapEntry<void*>"*
%tmp12.i.i = icmp eq i8* %tmp.i20.i.i, null
%tmp.i20.i.i = tail call noalias ptr @malloc(i64 %tmp8.i.i) nounwind
%tmp12.i.i = icmp eq ptr %tmp.i20.i.i, null
br i1 %tmp12.i.i, label %_ZN4llvm14StringMapEntryIPvE6CreateINS_15MallocAllocatorES1_EEPS2_PKcS7_RT_T0_.exit.i, label %bb.i.i

bb.i.i: ; preds = %bb4.i
%tmp.i.i.i.i = bitcast i8* %tmp.i20.i.i to i32*
store i32 %tmp4.i.i, i32* %tmp.i.i.i.i, align 4
%tmp1.i19.i.i = getelementptr inbounds i8, i8* %tmp.i20.i.i, i64 8
%0 = bitcast i8* %tmp1.i19.i.i to i8**
store i8* null, i8** %0, align 8
store i32 %tmp4.i.i, ptr %tmp.i20.i.i, align 4
%tmp1.i19.i.i = getelementptr inbounds i8, ptr %tmp.i20.i.i, i64 8
store ptr null, ptr %tmp1.i19.i.i, align 8
br label %_ZN4llvm14StringMapEntryIPvE6CreateINS_15MallocAllocatorES1_EEPS2_PKcS7_RT_T0_.exit.i

_ZN4llvm14StringMapEntryIPvE6CreateINS_15MallocAllocatorES1_EEPS2_PKcS7_RT_T0_.exit.i: ; preds = %bb.i.i, %bb4.i
%tmp.i18.i.i = getelementptr inbounds i8, i8* %tmp.i20.i.i, i64 16
%tmp.i18.i.i = getelementptr inbounds i8, ptr %tmp.i20.i.i, i64 16
%tmp15.i.i = zext i32 %tmp4.i.i to i64
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp.i18.i.i, i8* %tmp41.i, i64 %tmp15.i.i, i1 false)
tail call void @llvm.memcpy.p0.p0.i64(ptr %tmp.i18.i.i, ptr %tmp41.i, i64 %tmp15.i.i, i1 false)
%tmp.i18.sum.i.i = add i64 %tmp15.i.i, 16
%tmp17.i.i = getelementptr inbounds i8, i8* %tmp.i20.i.i, i64 %tmp.i18.sum.i.i
store i8 0, i8* %tmp17.i.i, align 1
%tmp.i.i.i = getelementptr inbounds i8, i8* %tmp.i20.i.i, i64 8
%1 = bitcast i8* %tmp.i.i.i to i8**
store i8* null, i8** %1, align 8
%tmp22.i = load %"struct.llvm::StringMapEntryBase"*, %"struct.llvm::StringMapEntryBase"** %tmp7.i, align 8
%tmp24.i = icmp eq %"struct.llvm::StringMapEntryBase"* %tmp22.i, inttoptr (i64 -1 to %"struct.llvm::StringMapEntryBase"*)
%tmp17.i.i = getelementptr inbounds i8, ptr %tmp.i20.i.i, i64 %tmp.i18.sum.i.i
store i8 0, ptr %tmp17.i.i, align 1
%tmp.i.i.i = getelementptr inbounds i8, ptr %tmp.i20.i.i, i64 8
store ptr null, ptr %tmp.i.i.i, align 8
%tmp22.i = load ptr, ptr %tmp7.i, align 8
%tmp24.i = icmp eq ptr %tmp22.i, inttoptr (i64 -1 to ptr)
br i1 %tmp24.i, label %bb9.i, label %_ZN4llvm9StringMapIPvNS_15MallocAllocatorEE16GetOrCreateValueIS1_EERNS_14StringMapEntryIS1_EENS_9StringRefET_.exit

bb6.i: ; preds = %entry
%tmp16.i = bitcast %"struct.llvm::StringMapEntryBase"* %tmp8.i to %"struct.llvm::StringMapEntry<void*>"*
ret %"struct.llvm::StringMapEntry<void*>"* %tmp16.i
ret ptr %tmp8.i

bb9.i: ; preds = %_ZN4llvm14StringMapEntryIPvE6CreateINS_15MallocAllocatorES1_EEPS2_PKcS7_RT_T0_.exit.i
%tmp25.i = getelementptr inbounds %"struct.llvm::StringMap<void*,llvm::MallocAllocator>", %"struct.llvm::StringMap<void*,llvm::MallocAllocator>"* %this, i64 0, i32 0, i32 3
%tmp26.i = load i32, i32* %tmp25.i, align 8
%tmp25.i = getelementptr inbounds %"struct.llvm::StringMap<ptr,llvm::MallocAllocator>", ptr %this, i64 0, i32 0, i32 3
%tmp26.i = load i32, ptr %tmp25.i, align 8
%tmp27.i = add i32 %tmp26.i, -1
store i32 %tmp27.i, i32* %tmp25.i, align 8
ret %"struct.llvm::StringMapEntry<void*>"* %tmp10.i.i
store i32 %tmp27.i, ptr %tmp25.i, align 8
ret ptr %tmp.i20.i.i

_ZN4llvm9StringMapIPvNS_15MallocAllocatorEE16GetOrCreateValueIS1_EERNS_14StringMapEntryIS1_EENS_9StringRefET_.exit: ; preds = %_ZN4llvm14StringMapEntryIPvE6CreateINS_15MallocAllocatorES1_EEPS2_PKcS7_RT_T0_.exit.i
ret %"struct.llvm::StringMapEntry<void*>"* %tmp10.i.i
ret ptr %tmp.i20.i.i
}

declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
13 changes: 6 additions & 7 deletions llvm/test/Transforms/NewGVN/null-aliases-nothing.ll
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
; RUN: opt < %s -passes=newgvn -S | FileCheck %s

%t = type { i32 }
declare void @test1f(i8*)
declare void @test1f(ptr)

define void @test1(%t* noalias %stuff ) {
%p = getelementptr inbounds %t, %t* %stuff, i32 0, i32 0
%before = load i32, i32* %p
define void @test1(ptr noalias %stuff ) {
%before = load i32, ptr %stuff

call void @test1f(i8* null)
call void @test1f(ptr null)

%after = load i32, i32* %p ; <--- This should be a dead load
%after = load i32, ptr %stuff ; <--- This should be a dead load
%sum = add i32 %before, %after

store i32 %sum, i32* %p
store i32 %sum, ptr %stuff
ret void
; CHECK: load
; CHECK-NOT: load
Expand Down
26 changes: 13 additions & 13 deletions llvm/test/Transforms/NewGVN/opt-remarks-xfail.ll
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,33 @@
; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 2, Column: 10 }
; YAML-NEXT: ...

define i32 @arg(i32* %p, i32 %i) {
define i32 @arg(ptr %p, i32 %i) {
entry:
store i32 %i, i32* %p
%load = load i32, i32* %p
store i32 %i, ptr %p
%load = load i32, ptr %p
ret i32 %load
}

define i32 @const(i32* %p) {
define i32 @const(ptr %p) {
entry:
store i32 4, i32* %p
%load = load i32, i32* %p
store i32 4, ptr %p
%load = load i32, ptr %p
ret i32 %load
}

define i32 @inst(i32* %p) {
define i32 @inst(ptr %p) {
entry:
%load1 = load i32, i32* %p
%load = load i32, i32* %p
%load1 = load i32, ptr %p
%load = load i32, ptr %p
%add = add i32 %load1, %load
ret i32 %add
}

define i32 @may_alias(i32* %p, i32* %r) !dbg !7 {
define i32 @may_alias(ptr %p, ptr %r) !dbg !7 {
entry:
%load1 = load i32, i32* %p, !tbaa !13, !dbg !9
store i32 4, i32* %r, !tbaa !13, !dbg !10
%load = load i32, i32* %p, !tbaa !13, !dbg !11
%load1 = load i32, ptr %p, !tbaa !13, !dbg !9
store i32 4, ptr %r, !tbaa !13, !dbg !10
%load = load i32, ptr %p, !tbaa !13, !dbg !11
%add = add i32 %load1, %load
ret i32 %add
}
Expand Down
72 changes: 36 additions & 36 deletions llvm/test/Transforms/NewGVN/phi-of-ops-loads.ll
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=newgvn -enable-phi-of-ops=true -S -o - %s | FileCheck %s

define void @hoisted-load(i8* %p, i8* %q) {
define void @hoisted-load(ptr %p, ptr %q) {
; CHECK-LABEL: @hoisted-load(
; CHECK-NEXT: bb56:
; CHECK-NEXT: [[N60:%.*]] = load i8, i8* [[P:%.*]], align 1
; CHECK-NEXT: [[N60:%.*]] = load i8, ptr [[P:%.*]], align 1
; CHECK-NEXT: br label [[BB57:%.*]]
; CHECK: bb57:
; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i1 [ true, [[BB56:%.*]] ], [ [[N62:%.*]], [[BB229:%.*]] ]
Expand All @@ -14,13 +14,13 @@ define void @hoisted-load(i8* %p, i8* %q) {
; CHECK-NEXT: br i1 [[PHIOFOPS]], label [[BB229]], label [[BB237:%.*]]
; CHECK: bb229:
; CHECK-NEXT: [[INC]] = add i8 [[IDX]], 1
; CHECK-NEXT: store i8 [[INC]], i8* [[Q:%.*]], align 1
; CHECK-NEXT: store i8 [[INC]], ptr [[Q:%.*]], align 1
; CHECK-NEXT: br label [[BB57]]
; CHECK: bb237:
; CHECK-NEXT: ret void
;
bb56:
%n60 = load i8, i8* %p
%n60 = load i8, ptr %p
br label %bb57

bb57:
Expand All @@ -32,27 +32,27 @@ bb57:

bb229:
%inc = add i8 %idx, 1
store i8 %inc, i8* %q
store i8 %inc, ptr %q
br label %bb57

bb237:
ret void
}

define void @store-in-loop(i8* %p, i8* %q) {
define void @store-in-loop(ptr %p, ptr %q) {
; CHECK-LABEL: @store-in-loop(
; CHECK-NEXT: bb56:
; CHECK-NEXT: br label [[BB57:%.*]]
; CHECK: bb57:
; CHECK-NEXT: [[N59:%.*]] = phi i1 [ false, [[BB229:%.*]] ], [ true, [[BB56:%.*]] ]
; CHECK-NEXT: [[IDX:%.*]] = phi i8 [ 0, [[BB56]] ], [ [[INC:%.*]], [[BB229]] ]
; CHECK-NEXT: [[N60:%.*]] = load i8, i8* [[P:%.*]], align 1
; CHECK-NEXT: [[N60:%.*]] = load i8, ptr [[P:%.*]], align 1
; CHECK-NEXT: [[N62:%.*]] = icmp ne i8 [[N60]], 2
; CHECK-NEXT: [[N63:%.*]] = or i1 [[N59]], [[N62]]
; CHECK-NEXT: br i1 [[N63]], label [[BB229]], label [[BB237:%.*]]
; CHECK: bb229:
; CHECK-NEXT: [[INC]] = add i8 [[IDX]], 1
; CHECK-NEXT: store i8 [[INC]], i8* [[Q:%.*]], align 1
; CHECK-NEXT: store i8 [[INC]], ptr [[Q:%.*]], align 1
; CHECK-NEXT: br label [[BB57]]
; CHECK: bb237:
; CHECK-NEXT: ret void
Expand All @@ -63,35 +63,35 @@ bb56:
bb57:
%n59 = phi i1 [ false, %bb229 ], [ true, %bb56 ]
%idx = phi i8 [0, %bb56], [%inc, %bb229]
%n60 = load i8, i8* %p
%n60 = load i8, ptr %p
%n62 = icmp ne i8 %n60, 2
%n63 = or i1 %n59, %n62
br i1 %n63, label %bb229, label %bb237

bb229:
%inc = add i8 %idx, 1
store i8 %inc, i8* %q
store i8 %inc, ptr %q
br label %bb57

bb237:
ret void
}

; TODO: we should support this case
define void @no-alias-store-in-loop(i8* noalias %p, i8* noalias %q) {
define void @no-alias-store-in-loop(ptr noalias %p, ptr noalias %q) {
; CHECK-LABEL: @no-alias-store-in-loop(
; CHECK-NEXT: bb56:
; CHECK-NEXT: br label [[BB57:%.*]]
; CHECK: bb57:
; CHECK-NEXT: [[N59:%.*]] = phi i1 [ false, [[BB229:%.*]] ], [ true, [[BB56:%.*]] ]
; CHECK-NEXT: [[IDX:%.*]] = phi i8 [ 0, [[BB56]] ], [ [[INC:%.*]], [[BB229]] ]
; CHECK-NEXT: [[N60:%.*]] = load i8, i8* [[P:%.*]], align 1
; CHECK-NEXT: [[N60:%.*]] = load i8, ptr [[P:%.*]], align 1
; CHECK-NEXT: [[N62:%.*]] = icmp ne i8 [[N60]], 2
; CHECK-NEXT: [[N63:%.*]] = or i1 [[N59]], [[N62]]
; CHECK-NEXT: br i1 [[N63]], label [[BB229]], label [[BB237:%.*]]
; CHECK: bb229:
; CHECK-NEXT: [[INC]] = add i8 [[IDX]], 1
; CHECK-NEXT: store i8 [[INC]], i8* [[Q:%.*]], align 1
; CHECK-NEXT: store i8 [[INC]], ptr [[Q:%.*]], align 1
; CHECK-NEXT: br label [[BB57]]
; CHECK: bb237:
; CHECK-NEXT: ret void
Expand All @@ -102,27 +102,27 @@ bb56:
bb57:
%n59 = phi i1 [ false, %bb229 ], [ true, %bb56 ]
%idx = phi i8 [0, %bb56], [%inc, %bb229]
%n60 = load i8, i8* %p
%n60 = load i8, ptr %p
%n62 = icmp ne i8 %n60, 2
%n63 = or i1 %n59, %n62
br i1 %n63, label %bb229, label %bb237

bb229:
%inc = add i8 %idx, 1
store i8 %inc, i8* %q
store i8 %inc, ptr %q
br label %bb57

bb237:
ret void
}

define void @function-in-loop(i8* %p) {
define void @function-in-loop(ptr %p) {
; CHECK-LABEL: @function-in-loop(
; CHECK-NEXT: bb56:
; CHECK-NEXT: br label [[BB57:%.*]]
; CHECK: bb57:
; CHECK-NEXT: [[N59:%.*]] = phi i1 [ false, [[BB229:%.*]] ], [ true, [[BB56:%.*]] ]
; CHECK-NEXT: [[N60:%.*]] = load i8, i8* [[P:%.*]], align 1
; CHECK-NEXT: [[N60:%.*]] = load i8, ptr [[P:%.*]], align 1
; CHECK-NEXT: [[N62:%.*]] = icmp ne i8 [[N60]], 2
; CHECK-NEXT: [[N63:%.*]] = or i1 [[N59]], [[N62]]
; CHECK-NEXT: br i1 [[N63]], label [[BB229]], label [[BB237:%.*]]
Expand All @@ -137,7 +137,7 @@ bb56:

bb57:
%n59 = phi i1 [ false, %bb229 ], [ true, %bb56 ]
%n60 = load i8, i8* %p
%n60 = load i8, ptr %p
%n62 = icmp ne i8 %n60, 2
%n63 = or i1 %n59, %n62
br i1 %n63, label %bb229, label %bb237
Expand All @@ -151,13 +151,13 @@ bb237:
}

; TODO: we should support this case
define void @nowrite-function-in-loop(i8* %p) {
define void @nowrite-function-in-loop(ptr %p) {
; CHECK-LABEL: @nowrite-function-in-loop(
; CHECK-NEXT: bb56:
; CHECK-NEXT: br label [[BB57:%.*]]
; CHECK: bb57:
; CHECK-NEXT: [[N59:%.*]] = phi i1 [ false, [[BB229:%.*]] ], [ true, [[BB56:%.*]] ]
; CHECK-NEXT: [[N60:%.*]] = load i8, i8* [[P:%.*]], align 1
; CHECK-NEXT: [[N60:%.*]] = load i8, ptr [[P:%.*]], align 1
; CHECK-NEXT: [[N62:%.*]] = icmp ne i8 [[N60]], 2
; CHECK-NEXT: [[N63:%.*]] = or i1 [[N59]], [[N62]]
; CHECK-NEXT: br i1 [[N63]], label [[BB229]], label [[BB237:%.*]]
Expand All @@ -172,7 +172,7 @@ bb56:

bb57:
%n59 = phi i1 [ false, %bb229 ], [ true, %bb56 ]
%n60 = load i8, i8* %p
%n60 = load i8, ptr %p
%n62 = icmp ne i8 %n60, 2
%n63 = or i1 %n59, %n62
br i1 %n63, label %bb229, label %bb237
Expand All @@ -187,59 +187,59 @@ bb237:

declare void @f()

define void @issfeoperand([3 x [2 x [1 x i8]]]* nocapture readonly %array, i1 %cond1, i1 %cond2, i16* nocapture readonly %p1, i32* nocapture writeonly %p2, i32* nocapture writeonly %p3) local_unnamed_addr #0 {
define void @issfeoperand(ptr nocapture readonly %array, i1 %cond1, i1 %cond2, ptr nocapture readonly %p1, ptr nocapture writeonly %p2, ptr nocapture writeonly %p3) local_unnamed_addr #0 {
; CHECK-LABEL: @issfeoperand(
; CHECK-NEXT: for.body:
; CHECK-NEXT: br i1 [[COND1:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.true:
; CHECK-NEXT: [[ARRAYIDX31:%.*]] = getelementptr inbounds [3 x [2 x [1 x i8]]], [3 x [2 x [1 x i8]]]* [[ARRAY:%.*]], i64 109, i64 0, i64 0, i64 undef
; CHECK-NEXT: [[LD1:%.*]] = load i8, i8* [[ARRAYIDX31]], align 1
; CHECK-NEXT: [[ARRAYIDX31:%.*]] = getelementptr inbounds [3 x [2 x [1 x i8]]], ptr [[ARRAY:%.*]], i64 109, i64 0, i64 0, i64 undef
; CHECK-NEXT: [[LD1:%.*]] = load i8, ptr [[ARRAYIDX31]], align 1
; CHECK-NEXT: br label [[COND_FALSE]]
; CHECK: cond.false:
; CHECK-NEXT: [[PHI1:%.*]] = phi i8 [ [[LD1]], [[COND_TRUE]] ], [ 0, [[FOR_BODY:%.*]] ]
; CHECK-NEXT: [[ARRAYIDX42:%.*]] = getelementptr inbounds [3 x [2 x [1 x i8]]], [3 x [2 x [1 x i8]]]* [[ARRAY]], i64 109, i64 0, i64 0, i64 undef
; CHECK-NEXT: [[LD2:%.*]] = load i8, i8* [[ARRAYIDX42]], align 1
; CHECK-NEXT: [[ARRAYIDX42:%.*]] = getelementptr inbounds [3 x [2 x [1 x i8]]], ptr [[ARRAY]], i64 109, i64 0, i64 0, i64 undef
; CHECK-NEXT: [[LD2:%.*]] = load i8, ptr [[ARRAYIDX42]], align 1
; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 [[LD2]], [[PHI1]]
; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP1]] to i32
; CHECK-NEXT: store i32 [[ZEXT]], i32* [[P2:%.*]], align 4
; CHECK-NEXT: store i32 [[ZEXT]], ptr [[P2:%.*]], align 4
; CHECK-NEXT: br i1 [[COND2:%.*]], label [[COND_END:%.*]], label [[EXIT:%.*]]
; CHECK: cond.end:
; CHECK-NEXT: [[LD3:%.*]] = load i16, i16* [[P1:%.*]], align 2
; CHECK-NEXT: [[LD3:%.*]] = load i16, ptr [[P1:%.*]], align 2
; CHECK-NEXT: [[SEXT:%.*]] = sext i16 [[LD3]] to i32
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[PHI2:%.*]] = phi i32 [ [[SEXT]], [[COND_END]] ], [ 0, [[COND_FALSE]] ]
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 [[LD2]], 0
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP2]], i32 [[PHI2]], i32 0
; CHECK-NEXT: store i32 [[SEL]], i32* [[P3:%.*]], align 4
; CHECK-NEXT: store i32 [[SEL]], ptr [[P3:%.*]], align 4
; CHECK-NEXT: ret void
;
for.body:
br i1 %cond1, label %cond.true, label %cond.false

cond.true: ; preds = %for.body
%arrayidx31 = getelementptr inbounds [3 x [2 x [1 x i8]]], [3 x [2 x [1 x i8]]]* %array, i64 109, i64 0, i64 0, i64 undef
%ld1 = load i8, i8* %arrayidx31, align 1
%arrayidx31 = getelementptr inbounds [3 x [2 x [1 x i8]]], ptr %array, i64 109, i64 0, i64 0, i64 undef
%ld1 = load i8, ptr %arrayidx31, align 1
br label %cond.false

cond.false: ; preds = %cond.true, %for.body
%phi1 = phi i8 [ %ld1, %cond.true ], [ 0, %for.body ]
%arrayidx42 = getelementptr inbounds [3 x [2 x [1 x i8]]], [3 x [2 x [1 x i8]]]* %array, i64 109, i64 0, i64 0, i64 undef
%ld2 = load i8, i8* %arrayidx42, align 1
%arrayidx42 = getelementptr inbounds [3 x [2 x [1 x i8]]], ptr %array, i64 109, i64 0, i64 0, i64 undef
%ld2 = load i8, ptr %arrayidx42, align 1
%cmp1 = icmp ult i8 %ld2, %phi1
%zext = zext i1 %cmp1 to i32
store i32 %zext, i32* %p2, align 4
store i32 %zext, ptr %p2, align 4
br i1 %cond2, label %cond.end, label %exit

cond.end: ; preds = %cond.false
%ld3 = load i16, i16* %p1, align 2
%ld3 = load i16, ptr %p1, align 2
%sext = sext i16 %ld3 to i32
br label %exit

exit: ; preds = %cond.end, %cond.false
%phi2 = phi i32 [ %sext, %cond.end ], [ 0, %cond.false ]
%cmp2 = icmp eq i8 %ld2, 0
%sel = select i1 %cmp2, i32 %phi2, i32 0
store i32 %sel, i32* %p3, align 4
store i32 %sel, ptr %p3, align 4
ret void
}
8 changes: 4 additions & 4 deletions llvm/test/Transforms/NewGVN/phi-of-ops-move-block.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ define void @test() {
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[STOREMERGE:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD1:%.*]], [[CRITEDGE:%.*]] ]
; CHECK-NEXT: store i32 [[STOREMERGE]], i32* @g_20, align 4
; CHECK-NEXT: store i32 [[STOREMERGE]], ptr @g_20, align 4
; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[STOREMERGE]], 0
; CHECK-NEXT: br i1 [[CMP0]], label [[LR_PH:%.*]], label [[CRITEDGE]]
; CHECK: lr.ph:
; CHECK-NEXT: [[LV:%.*]] = load i64, i64* inttoptr (i64 16 to i64*), align 16
; CHECK-NEXT: [[LV:%.*]] = load i64, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i64 [[LV]], 0
; CHECK-NEXT: br i1 [[CMP1]], label [[PREHEADER_SPLIT:%.*]], label [[CRITEDGE]]
; CHECK: preheader.split:
Expand All @@ -32,12 +32,12 @@ entry:

bb1: ; preds = %critedge, %entry
%storemerge = phi i32 [ 0, %entry ], [ %add1, %critedge ]
store i32 %storemerge, i32* @g_20, align 4
store i32 %storemerge, ptr @g_20, align 4
%cmp0 = icmp eq i32 %storemerge, 0
br i1 %cmp0, label %lr.ph, label %critedge

lr.ph: ; preds = %bb1
%lv = load i64, i64* inttoptr (i64 16 to i64*), align 16
%lv = load i64, ptr inttoptr (i64 16 to ptr), align 16
%cmp1 = icmp eq i64 %lv, 0
br i1 %cmp1, label %preheader.split, label %critedge

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=newgvn -S %s | FileCheck %s

declare void @use.i16(i16*)
declare void @use.i16(ptr)
declare void @use.i32(i32)

; Test cases from PR35074, where the simplification dependencies need to be
Expand Down Expand Up @@ -58,7 +58,7 @@ for.body4.1: ; preds = %for.body4
br label %for.end
}

define void @test2(i1 %c, i16* %ptr, i64 %N) {
define void @test2(i1 %c, ptr %ptr, i64 %N) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[HEADER:%.*]]
Expand All @@ -71,12 +71,12 @@ define void @test2(i1 %c, i16* %ptr, i64 %N) {
; CHECK-NEXT: br i1 [[CMP1]], label [[LATCH]], label [[LOR_RHS:%.*]]
; CHECK: lor.rhs:
; CHECK-NEXT: [[IV_ADD_1:%.*]] = add i64 [[IV]], 1
; CHECK-NEXT: [[IDX_1:%.*]] = getelementptr inbounds i16, i16* [[PTR:%.*]], i64 [[IV_ADD_1]]
; CHECK-NEXT: call void @use.i16(i16* [[IDX_1]])
; CHECK-NEXT: [[IDX_1:%.*]] = getelementptr inbounds i16, ptr [[PTR:%.*]], i64 [[IV_ADD_1]]
; CHECK-NEXT: call void @use.i16(ptr [[IDX_1]])
; CHECK-NEXT: ret void
; CHECK: if.else:
; CHECK-NEXT: [[IDX_2:%.*]] = getelementptr inbounds i16, i16* [[PTR]], i64 [[PHIOFOPS]]
; CHECK-NEXT: call void @use.i16(i16* [[IDX_2]])
; CHECK-NEXT: [[IDX_2:%.*]] = getelementptr inbounds i16, ptr [[PTR]], i64 [[PHIOFOPS]]
; CHECK-NEXT: call void @use.i16(ptr [[IDX_2]])
; CHECK-NEXT: br label [[LATCH]]
; CHECK: latch:
; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
Expand All @@ -98,14 +98,14 @@ if.then:

lor.rhs: ; preds = %if.then
%iv.add.1 = add i64 %iv, 1
%idx.1 = getelementptr inbounds i16, i16* %ptr, i64 %iv.add.1
call void @use.i16(i16* %idx.1)
%idx.1 = getelementptr inbounds i16, ptr %ptr, i64 %iv.add.1
call void @use.i16(ptr %idx.1)
ret void

if.else:
%iv.sub.1 = add i64 %iv, -1
%idx.2 = getelementptr inbounds i16, i16* %ptr, i64 %iv.sub.1
call void @use.i16(i16* %idx.2)
%idx.2 = getelementptr inbounds i16, ptr %ptr, i64 %iv.sub.1
call void @use.i16(ptr %idx.2)
br label %latch

latch:
Expand All @@ -117,7 +117,7 @@ exit:
ret void
}

define void @pr49873_cmp_simplification_dependency(i32* %ptr, i1 %c.0) {
define void @pr49873_cmp_simplification_dependency(ptr %ptr, i1 %c.0) {
; CHECK-LABEL: @pr49873_cmp_simplification_dependency(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP_1:%.*]]
Expand All @@ -126,7 +126,7 @@ define void @pr49873_cmp_simplification_dependency(i32* %ptr, i1 %c.0) {
; CHECK: loop.2:
; CHECK-NEXT: [[I130:%.*]] = phi i32 [ [[I132:%.*]], [[LOOP_2]] ], [ 0, [[LOOP_1]] ]
; CHECK-NEXT: [[I132]] = add nuw i32 [[I130]], 1
; CHECK-NEXT: [[I133:%.*]] = load i32, i32* [[PTR:%.*]], align 4
; CHECK-NEXT: [[I133:%.*]] = load i32, ptr [[PTR:%.*]], align 4
; CHECK-NEXT: [[C_1:%.*]] = icmp ult i32 [[I132]], [[I133]]
; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_2]], label [[LOOP_2_EXIT:%.*]]
; CHECK: loop.2.exit:
Expand All @@ -148,7 +148,7 @@ loop.1:
loop.2:
%i130 = phi i32 [ %i132, %loop.2 ], [ 0, %loop.1 ]
%i132 = add nuw i32 %i130, 1
%i133 = load i32, i32* %ptr, align 4
%i133 = load i32, ptr %ptr, align 4
%c.1 = icmp ult i32 %i132, %i133
br i1 %c.1, label %loop.2, label %loop.2.exit

Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Transforms/NewGVN/phi-translate-partial-alias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; not actually redundant around the loop backedge, despite appearances
; if phi-translation is ignored.

; CHECK: define void @test0(i8* %begin)
; CHECK: define void @test0(ptr %begin)
; CHECK: loop:
; CHECK: %l0 = load i8, i8* %phi
; CHECK: %l0 = load i8, ptr %phi
; CHECK: call void @bar(i8 %l0)
; CHECK: %l1 = load i8, i8* %phi
define void @test0(i8* %begin) {
; CHECK: %l1 = load i8, ptr %phi
define void @test0(ptr %begin) {
entry:
br label %loop

loop:
%phi = phi i8* [ %begin, %entry ], [ %next, %loop ]
%l0 = load i8, i8* %phi
%phi = phi ptr [ %begin, %entry ], [ %next, %loop ]
%l0 = load i8, ptr %phi
call void @bar(i8 %l0)
%l1 = load i8, i8* %phi
%next = getelementptr inbounds i8, i8* %phi, i8 %l1
%l1 = load i8, ptr %phi
%next = getelementptr inbounds i8, ptr %phi, i8 %l1
br label %loop
}

Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/NewGVN/pr10820-xfail.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ target triple = "x86_64-unknown-linux-gnu"
define void @main() nounwind uwtable {
entry:
; CHECK: store i32
store i32 402662078, i32* bitcast (i31* @g to i32*), align 8
store i32 402662078, ptr @g, align 8
; CHECK-NOT: load i31
%0 = load i31, i31* @g, align 8
%0 = load i31, ptr @g, align 8
; CHECK: store i31
store i31 %0, i31* undef, align 1
store i31 %0, ptr undef, align 1
unreachable
}
Loading