Skip to content

Commit

Permalink
[test][InstCombine] Update some test cases to use opaque pointers
Browse files Browse the repository at this point in the history
These tests cases were converted using the script at
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

Differential Revision: https://reviews.llvm.org/D135094
  • Loading branch information
bjope committed Oct 3, 2022
1 parent 5530099 commit 4ab40ec
Show file tree
Hide file tree
Showing 601 changed files with 11,298 additions and 12,177 deletions.
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstCombine/2003-05-27-ConstExprCrash.ll
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
; RUN: opt < %s -passes=instcombine -disable-output

@X = global i32 5 ; <i32*> [#uses=1]
@X = global i32 5 ; <ptr> [#uses=1]

define i64 @test() {
%C = add i64 1, 2 ; <i64> [#uses=1]
%V = add i64 ptrtoint (i32* @X to i64), %C ; <i64> [#uses=1]
%V = add i64 ptrtoint (ptr @X to i64), %C ; <i64> [#uses=1]
ret i64 %V
}

26 changes: 13 additions & 13 deletions llvm/test/Transforms/InstCombine/2003-07-21-ExternalConstant.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@
; END.

target datalayout = "e-p:32:32"
@silly = external constant i32 ; <i32*> [#uses=1]
@silly = external constant i32 ; <ptr> [#uses=1]

declare void @bzero(i8*, i32)
declare void @bzero(ptr, i32)

declare void @bcopy(i8*, i8*, i32)
declare void @bcopy(ptr, ptr, i32)

declare i32 @bcmp(i8*, i8*, i32)
declare i32 @bcmp(ptr, ptr, i32)

declare i32 @fputs(i8*, i8*)
declare i32 @fputs(ptr, ptr)

declare i32 @fputs_unlocked(i8*, i8*)
declare i32 @fputs_unlocked(ptr, ptr)

define i32 @function(i32 %a.1) {
entry:
%a.0 = alloca i32 ; <i32*> [#uses=2]
%result = alloca i32 ; <i32*> [#uses=2]
store i32 %a.1, i32* %a.0
%tmp.0 = load i32, i32* %a.0 ; <i32> [#uses=1]
%tmp.1 = load i32, i32* @silly ; <i32> [#uses=1]
%a.0 = alloca i32 ; <ptr> [#uses=2]
%result = alloca i32 ; <ptr> [#uses=2]
store i32 %a.1, ptr %a.0
%tmp.0 = load i32, ptr %a.0 ; <i32> [#uses=1]
%tmp.1 = load i32, ptr @silly ; <i32> [#uses=1]
%tmp.2 = add i32 %tmp.0, %tmp.1 ; <i32> [#uses=1]
store i32 %tmp.2, i32* %result
store i32 %tmp.2, ptr %result
br label %return

return: ; preds = %entry
%tmp.3 = load i32, i32* %result ; <i32> [#uses=1]
%tmp.3 = load i32, ptr %result ; <i32> [#uses=1]
ret i32 %tmp.3
}

6 changes: 3 additions & 3 deletions llvm/test/Transforms/InstCombine/2003-08-12-AllocaNonNull.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ declare i32 @bitmap_clear(...)

define i32 @oof() {
entry:
%live_head = alloca i32 ; <i32*> [#uses=2]
%tmp.1 = icmp ne i32* %live_head, null ; <i1> [#uses=1]
%live_head = alloca i32 ; <ptr> [#uses=2]
%tmp.1 = icmp ne ptr %live_head, null ; <i1> [#uses=1]
br i1 %tmp.1, label %then, label %UnifiedExitNode

then: ; preds = %entry
%tmp.4 = call i32 (...) @bitmap_clear( i32* %live_head ) ; <i32> [#uses=0]
%tmp.4 = call i32 (...) @bitmap_clear( ptr %live_head ) ; <i32> [#uses=0]
br label %UnifiedExitNode

UnifiedExitNode: ; preds = %then, %entry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; RUN: opt < %s -passes=instcombine -S | grep load

define void @test(i32* %P) {
define void @test(ptr %P) {
; Dead but not deletable!
%X = load volatile i32, i32* %P ; <i32> [#uses=0]
%X = load volatile i32, ptr %P ; <i32> [#uses=0]
ret void
}
14 changes: 7 additions & 7 deletions llvm/test/Transforms/InstCombine/2003-10-29-CallSiteResolve.ll
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
; RUN: opt < %s -passes=instcombine -disable-output

declare i32* @bar()
declare ptr @bar()

define float* @foo() personality i32 (...)* @__gxx_personality_v0 {
%tmp.11 = invoke float* bitcast (i32* ()* @bar to float* ()*)( )
to label %invoke_cont unwind label %X ; <float*> [#uses=1]
define ptr @foo() personality ptr @__gxx_personality_v0 {
%tmp.11 = invoke ptr @bar( )
to label %invoke_cont unwind label %X ; <ptr> [#uses=1]

invoke_cont: ; preds = %0
ret float* %tmp.11
ret ptr %tmp.11

X: ; preds = %0
%exn = landingpad {i8*, i32}
%exn = landingpad {ptr, i32}
cleanup
ret float* null
ret ptr null
}

declare i32 @__gxx_personality_v0(...)
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ target datalayout = "e-p:32:32"
declare void @foo(...)

define void @test(i64 %X) {
%Y = inttoptr i64 %X to i32* ; <i32*> [#uses=1]
call void (...) @foo( i32* %Y )
%Y = inttoptr i64 %X to ptr ; <ptr> [#uses=1]
call void (...) @foo( ptr %Y )
ret void
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
;
; RUN: opt < %s -passes=instcombine -disable-output

declare i8* @test()
declare ptr @test()

define i32 @foo() personality i32 (...)* @__gxx_personality_v0 {
define i32 @foo() personality ptr @__gxx_personality_v0 {
entry:
br i1 true, label %cont, label %call

call: ; preds = %entry
%P = invoke i32* bitcast (i8* ()* @test to i32* ()*)( )
to label %cont unwind label %N ; <i32*> [#uses=1]
%P = invoke ptr @test( )
to label %cont unwind label %N ; <ptr> [#uses=1]

cont: ; preds = %call, %entry
%P2 = phi i32* [ %P, %call ], [ null, %entry ] ; <i32*> [#uses=1]
%V = load i32, i32* %P2 ; <i32> [#uses=1]
%P2 = phi ptr [ %P, %call ], [ null, %entry ] ; <ptr> [#uses=1]
%V = load i32, ptr %P2 ; <i32> [#uses=1]
ret i32 %V

N: ; preds = %call
%exn = landingpad {i8*, i32}
%exn = landingpad {ptr, i32}
cleanup
ret i32 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

%Ty = type opaque

define i32 @test(%Ty* %X) {
%Y = bitcast %Ty* %X to i32* ; <i32*> [#uses=1]
%Z = load i32, i32* %Y ; <i32> [#uses=1]
define i32 @test(ptr %X) {
%Z = load i32, ptr %X ; <i32> [#uses=1]
ret i32 %Z
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
; RUN: opt < %s -passes=instcombine -disable-output

@p = weak global i32 0 ; <i32*> [#uses=1]
@p = weak global i32 0 ; <ptr> [#uses=1]

define i32 @test(i32 %x) {
%y = mul i32 %x, ptrtoint (i32* @p to i32) ; <i32> [#uses=1]
%y = mul i32 %x, ptrtoint (ptr @p to i32) ; <i32> [#uses=1]
ret i32 %y
}

14 changes: 7 additions & 7 deletions llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
; so could produce incorrect results!

define i32 @test(i1 %C) {
%X = alloca i32 ; <i32*> [#uses=3]
%X2 = alloca i32 ; <i32*> [#uses=2]
store i32 1, i32* %X
store i32 2, i32* %X2
%Y = select i1 %C, i32* %X, i32* %X2 ; <i32*> [#uses=1]
store i32 3, i32* %X
%Z = load i32, i32* %Y ; <i32> [#uses=1]
%X = alloca i32 ; <ptr> [#uses=3]
%X2 = alloca i32 ; <ptr> [#uses=2]
store i32 1, ptr %X
store i32 2, ptr %X2
%Y = select i1 %C, ptr %X, ptr %X2 ; <ptr> [#uses=1]
store i32 3, ptr %X
%Z = load i32, ptr %Y ; <i32> [#uses=1]
ret i32 %Z
}

14 changes: 7 additions & 7 deletions llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

define i32 @test(i1 %C) {
entry:
%X = alloca i32 ; <i32*> [#uses=3]
%X2 = alloca i32 ; <i32*> [#uses=2]
store i32 1, i32* %X
store i32 2, i32* %X2
%X = alloca i32 ; <ptr> [#uses=3]
%X2 = alloca i32 ; <ptr> [#uses=2]
store i32 1, ptr %X
store i32 2, ptr %X2
br i1 %C, label %cond_true.i, label %cond_continue.i

cond_true.i: ; preds = %entry
br label %cond_continue.i

cond_continue.i: ; preds = %cond_true.i, %entry
%mem_tmp.i.0 = phi i32* [ %X, %cond_true.i ], [ %X2, %entry ] ; <i32*> [#uses=1]
store i32 3, i32* %X
%tmp.3 = load i32, i32* %mem_tmp.i.0 ; <i32> [#uses=1]
%mem_tmp.i.0 = phi ptr [ %X, %cond_true.i ], [ %X2, %entry ] ; <ptr> [#uses=1]
store i32 3, ptr %X
%tmp.3 = load i32, ptr %mem_tmp.i.0 ; <i32> [#uses=1]
ret i32 %tmp.3
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ define i1 @lt_signed_to_large_unsigned(i8 %SB) {
; PR28011 - https://llvm.org/bugs/show_bug.cgi?id=28011
; The above transform only applies to scalar integers; it shouldn't be attempted for constant expressions or vectors.

@a = common global i32** null
@a = common global ptr null
@b = common global [1 x i32] zeroinitializer

define i1 @PR28011(i16 %a) {
; CHECK-LABEL: @PR28011(
; CHECK-NEXT: [[CONV:%.*]] = sext i16 [[A:%.*]] to i32
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[CONV]], or (i32 zext (i1 icmp ne (i32*** bitcast ([1 x i32]* @b to i32***), i32*** @a) to i32), i32 1)
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[CONV]], or (i32 zext (i1 icmp ne (ptr @b, ptr @a) to i32), i32 1)
; CHECK-NEXT: ret i1 [[CMP]]
;
%conv = sext i16 %a to i32
%cmp = icmp ne i32 %conv, or (i32 zext (i1 icmp ne (i32*** bitcast ([1 x i32]* @b to i32***), i32*** @a) to i32), i32 1)
%cmp = icmp ne i32 %conv, or (i32 zext (i1 icmp ne (ptr @b, ptr @a) to i32), i32 1)
ret i1 %cmp
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstCombine/2005-07-07-DeadPHILoop.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

; This example caused instcombine to spin into an infinite loop.

define void @test(i32* %P) {
define void @test(ptr %P) {
ret void

Dead: ; preds = %Dead
%X = phi i32 [ %Y, %Dead ] ; <i32> [#uses=1]
%Y = sdiv i32 %X, 10 ; <i32> [#uses=2]
store i32 %Y, i32* %P
store i32 %Y, ptr %P
br label %Dead
}

4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstCombine/2006-09-15-CastToBool.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; RUN: opt < %s -passes=instcombine -S | grep and
; PR913

define i32 @test(i32* %tmp1) {
%tmp.i = load i32, i32* %tmp1 ; <i32> [#uses=1]
define i32 @test(ptr %tmp1) {
%tmp.i = load i32, ptr %tmp1 ; <i32> [#uses=1]
%tmp = bitcast i32 %tmp.i to i32 ; <i32> [#uses=1]
%tmp2.ui = lshr i32 %tmp, 5 ; <i32> [#uses=1]
%tmp2 = bitcast i32 %tmp2.ui to i32 ; <i32> [#uses=1]
Expand Down
36 changes: 15 additions & 21 deletions llvm/test/Transforms/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ target triple = "i686-pc-linux-gnu"

define i32 @visible(i32 %direction, i64 %p1.0, i64 %p2.0, i64 %p3.0) {
entry:
%p1_addr = alloca %struct.point ; <%struct.point*> [#uses=2]
%p2_addr = alloca %struct.point ; <%struct.point*> [#uses=2]
%p3_addr = alloca %struct.point ; <%struct.point*> [#uses=2]
%p1_addr = alloca %struct.point ; <ptr> [#uses=2]
%p2_addr = alloca %struct.point ; <ptr> [#uses=2]
%p3_addr = alloca %struct.point ; <ptr> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
%tmp = bitcast %struct.point* %p1_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp.upgrd.1 = getelementptr { i64 }, { i64 }* %tmp, i64 0, i32 0 ; <i64*> [#uses=1]
store i64 %p1.0, i64* %tmp.upgrd.1
%tmp1 = bitcast %struct.point* %p2_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp2 = getelementptr { i64 }, { i64 }* %tmp1, i64 0, i32 0 ; <i64*> [#uses=1]
store i64 %p2.0, i64* %tmp2
%tmp3 = bitcast %struct.point* %p3_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp4 = getelementptr { i64 }, { i64 }* %tmp3, i64 0, i32 0 ; <i64*> [#uses=1]
store i64 %p3.0, i64* %tmp4
%tmp.upgrd.1 = getelementptr { i64 }, ptr %p1_addr, i64 0, i32 0 ; <ptr> [#uses=1]
store i64 %p1.0, ptr %tmp.upgrd.1
%tmp2 = getelementptr { i64 }, ptr %p2_addr, i64 0, i32 0 ; <ptr> [#uses=1]
store i64 %p2.0, ptr %tmp2
%tmp4 = getelementptr { i64 }, ptr %p3_addr, i64 0, i32 0 ; <ptr> [#uses=1]
store i64 %p3.0, ptr %tmp4
%tmp.upgrd.2 = icmp eq i32 %direction, 0 ; <i1> [#uses=1]
%tmp5 = bitcast %struct.point* %p1_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp6 = getelementptr { i64 }, { i64 }* %tmp5, i64 0, i32 0 ; <i64*> [#uses=1]
%tmp.upgrd.3 = load i64, i64* %tmp6 ; <i64> [#uses=1]
%tmp7 = bitcast %struct.point* %p2_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp8 = getelementptr { i64 }, { i64 }* %tmp7, i64 0, i32 0 ; <i64*> [#uses=1]
%tmp9 = load i64, i64* %tmp8 ; <i64> [#uses=1]
%tmp10 = bitcast %struct.point* %p3_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp11 = getelementptr { i64 }, { i64 }* %tmp10, i64 0, i32 0 ; <i64*> [#uses=1]
%tmp12 = load i64, i64* %tmp11 ; <i64> [#uses=1]
%tmp6 = getelementptr { i64 }, ptr %p1_addr, i64 0, i32 0 ; <ptr> [#uses=1]
%tmp.upgrd.3 = load i64, ptr %tmp6 ; <i64> [#uses=1]
%tmp8 = getelementptr { i64 }, ptr %p2_addr, i64 0, i32 0 ; <ptr> [#uses=1]
%tmp9 = load i64, ptr %tmp8 ; <i64> [#uses=1]
%tmp11 = getelementptr { i64 }, ptr %p3_addr, i64 0, i32 0 ; <ptr> [#uses=1]
%tmp12 = load i64, ptr %tmp11 ; <i64> [#uses=1]
%tmp13 = call i32 @determinant( i64 %tmp.upgrd.3, i64 %tmp9, i64 %tmp12 ) ; <i32> [#uses=2]
br i1 %tmp.upgrd.2, label %cond_true, label %cond_false

Expand Down
36 changes: 15 additions & 21 deletions llvm/test/Transforms/InstCombine/2006-12-08-Select-ICmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,22 @@ target triple = "i686-pc-linux-gnu"

define i32 @visible(i32 %direction, i64 %p1.0, i64 %p2.0, i64 %p3.0) {
entry:
%p1_addr = alloca %struct.point ; <%struct.point*> [#uses=2]
%p2_addr = alloca %struct.point ; <%struct.point*> [#uses=2]
%p3_addr = alloca %struct.point ; <%struct.point*> [#uses=2]
%tmp = bitcast %struct.point* %p1_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp.upgrd.1 = getelementptr { i64 }, { i64 }* %tmp, i32 0, i32 0 ; <i64*> [#uses=1]
store i64 %p1.0, i64* %tmp.upgrd.1
%tmp1 = bitcast %struct.point* %p2_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp2 = getelementptr { i64 }, { i64 }* %tmp1, i32 0, i32 0 ; <i64*> [#uses=1]
store i64 %p2.0, i64* %tmp2
%tmp3 = bitcast %struct.point* %p3_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp4 = getelementptr { i64 }, { i64 }* %tmp3, i32 0, i32 0 ; <i64*> [#uses=1]
store i64 %p3.0, i64* %tmp4
%p1_addr = alloca %struct.point ; <ptr> [#uses=2]
%p2_addr = alloca %struct.point ; <ptr> [#uses=2]
%p3_addr = alloca %struct.point ; <ptr> [#uses=2]
%tmp.upgrd.1 = getelementptr { i64 }, ptr %p1_addr, i32 0, i32 0 ; <ptr> [#uses=1]
store i64 %p1.0, ptr %tmp.upgrd.1
%tmp2 = getelementptr { i64 }, ptr %p2_addr, i32 0, i32 0 ; <ptr> [#uses=1]
store i64 %p2.0, ptr %tmp2
%tmp4 = getelementptr { i64 }, ptr %p3_addr, i32 0, i32 0 ; <ptr> [#uses=1]
store i64 %p3.0, ptr %tmp4
%tmp.upgrd.2 = icmp eq i32 %direction, 0 ; <i1> [#uses=1]
%tmp5 = bitcast %struct.point* %p1_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp6 = getelementptr { i64 }, { i64 }* %tmp5, i32 0, i32 0 ; <i64*> [#uses=1]
%tmp.upgrd.3 = load i64, i64* %tmp6 ; <i64> [#uses=1]
%tmp7 = bitcast %struct.point* %p2_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp8 = getelementptr { i64 }, { i64 }* %tmp7, i32 0, i32 0 ; <i64*> [#uses=1]
%tmp9 = load i64, i64* %tmp8 ; <i64> [#uses=1]
%tmp10 = bitcast %struct.point* %p3_addr to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp11 = getelementptr { i64 }, { i64 }* %tmp10, i32 0, i32 0 ; <i64*> [#uses=1]
%tmp12 = load i64, i64* %tmp11 ; <i64> [#uses=1]
%tmp6 = getelementptr { i64 }, ptr %p1_addr, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp.upgrd.3 = load i64, ptr %tmp6 ; <i64> [#uses=1]
%tmp8 = getelementptr { i64 }, ptr %p2_addr, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp9 = load i64, ptr %tmp8 ; <i64> [#uses=1]
%tmp11 = getelementptr { i64 }, ptr %p3_addr, i32 0, i32 0 ; <ptr> [#uses=1]
%tmp12 = load i64, ptr %tmp11 ; <i64> [#uses=1]
%tmp13 = call i32 @determinant( i64 %tmp.upgrd.3, i64 %tmp9, i64 %tmp12 ) ; <i32> [#uses=2]
%tmp14 = icmp slt i32 %tmp13, 0 ; <i1> [#uses=1]
%tmp26 = icmp sgt i32 %tmp13, 0 ; <i1> [#uses=1]
Expand Down
Loading

0 comments on commit 4ab40ec

Please sign in to comment.