12 changes: 6 additions & 6 deletions llvm/test/Transforms/InstSimplify/ConstProp/cast-vector.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
define <2 x i16> @test1() {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr ([10 x i32], [10 x i32]* null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x ptr> getelementptr ([10 x i32], ptr null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
;
entry:
%gep = getelementptr inbounds [10 x i32], [10 x i32]* null, i16 0, <2 x i16> <i16 5, i16 7>
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
%gep = getelementptr inbounds [10 x i32], ptr null, i16 0, <2 x i16> <i16 5, i16 7>
%vec = ptrtoint <2 x ptr> %gep to <2 x i16>
ret <2 x i16> %vec
}

Expand All @@ -23,10 +23,10 @@ entry:
define <2 x i16> @test2() {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr (i32, i32* null, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x ptr> getelementptr (i32, ptr null, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
;
entry:
%gep = getelementptr i32, i32* null, <2 x i16> <i16 5, i16 7>
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
%gep = getelementptr i32, ptr null, <2 x i16> <i16 5, i16 7>
%vec = ptrtoint <2 x ptr> %gep to <2 x i16>
ret <2 x i16> %vec
}
84 changes: 42 additions & 42 deletions llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,60 @@
@Y = external global i8
@Z = external global i8

@A = global i1 add (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
; CHECK: @A = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
@B = global i1 sub (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)), align 2
; CHECK: @B = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
@C = global i1 mul (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
; CHECK: @C = global i1 and (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))

@D = global i1 sdiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
; CHECK: @D = global i1 icmp ult (i8* @X, i8* @Y)
@E = global i1 udiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
; CHECK: @E = global i1 icmp ult (i8* @X, i8* @Y)
@F = global i1 srem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
@A = global i1 add (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
; CHECK: @A = global i1 xor (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
@B = global i1 sub (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z)), align 2
; CHECK: @B = global i1 xor (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
@C = global i1 mul (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
; CHECK: @C = global i1 and (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))

@D = global i1 sdiv (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
; CHECK: @D = global i1 icmp ult (ptr @X, ptr @Y)
@E = global i1 udiv (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
; CHECK: @E = global i1 icmp ult (ptr @X, ptr @Y)
@F = global i1 srem (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
; CHECK: @F = global i1 false
@G = global i1 urem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z))
@G = global i1 urem (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
; CHECK: @G = global i1 false

@H = global i1 icmp ule (i32* bitcast (i8* @X to i32*), i32* bitcast (i8* @Y to i32*))
; CHECK: @H = global i1 icmp ule (i8* @X, i8* @Y)
@H = global i1 icmp ule (ptr @X, ptr @Y)
; CHECK: @H = global i1 icmp ule (ptr @X, ptr @Y)

@I = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 false)
; CHECK: @I = global i1 icmp ult (i8* @X, i8* @Y)
@J = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 true)
; CHECK: @J = global i1 icmp uge (i8* @X, i8* @Y)
@I = global i1 xor (i1 icmp ult (ptr @X, ptr @Y), i1 false)
; CHECK: @I = global i1 icmp ult (ptr @X, ptr @Y)
@J = global i1 xor (i1 icmp ult (ptr @X, ptr @Y), i1 true)
; CHECK: @J = global i1 icmp uge (ptr @X, ptr @Y)

@K = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 false)
; CHECK: @K = global i1 icmp uge (i8* @X, i8* @Y)
@L = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 true)
; CHECK: @L = global i1 icmp ult (i8* @X, i8* @Y)
@M = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 true)
; CHECK: @M = global i1 icmp uge (i8* @X, i8* @Y)
@N = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 false)
; CHECK: @N = global i1 icmp ult (i8* @X, i8* @Y)
@K = global i1 icmp eq (i1 icmp ult (ptr @X, ptr @Y), i1 false)
; CHECK: @K = global i1 icmp uge (ptr @X, ptr @Y)
@L = global i1 icmp eq (i1 icmp ult (ptr @X, ptr @Y), i1 true)
; CHECK: @L = global i1 icmp ult (ptr @X, ptr @Y)
@M = global i1 icmp ne (i1 icmp ult (ptr @X, ptr @Y), i1 true)
; CHECK: @M = global i1 icmp uge (ptr @X, ptr @Y)
@N = global i1 icmp ne (i1 icmp ult (ptr @X, ptr @Y), i1 false)
; CHECK: @N = global i1 icmp ult (ptr @X, ptr @Y)

@O = global i1 icmp eq (i32 zext (i1 icmp ult (i8* @X, i8* @Y) to i32), i32 0)
; CHECK: @O = global i1 icmp uge (i8* @X, i8* @Y)
@O = global i1 icmp eq (i32 zext (i1 icmp ult (ptr @X, ptr @Y) to i32), i32 0)
; CHECK: @O = global i1 icmp uge (ptr @X, ptr @Y)



; PR5176

; CHECK: @T1 = global i1 true
@T1 = global i1 icmp eq (i64 and (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64), i64 1), i64 0)
@T1 = global i1 icmp eq (i64 and (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 64) to i64), i64 1), i64 0)

; CHECK: @T2 = global i1* @B
@T2 = global i1* inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 192)), i256 128) to i64)) to i1*)
; CHECK: @T2 = global ptr @B
@T2 = global ptr inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 192)), i256 128) to i64)) to ptr)

; CHECK: @T3 = global i64 add (i64 ptrtoint (i1* @B to i64), i64 -1)
@T3 = global i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64), i64 -1)
; CHECK: @T3 = global i64 add (i64 ptrtoint (ptr @B to i64), i64 -1)
@T3 = global i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 64) to i64), i64 -1)

; CHECK: @T4 = global i1* @B
@T4 = global i1* inttoptr (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64) to i1*)
; CHECK: @T4 = global ptr @B
@T4 = global ptr inttoptr (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 64) to i64) to ptr)

; CHECK: @T5 = global i1* @A
@T5 = global i1* inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 128) to i64)) to i1*)
; CHECK: @T5 = global ptr @A
@T5 = global ptr inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 128) to i64)) to ptr)



Expand Down Expand Up @@ -102,10 +102,10 @@
; CHECK: pr9011_15 = constant i128 0

@select = internal constant
i32 select (i1 icmp ult (i32 ptrtoint (i8* @X to i32),
i32 ptrtoint (i8* @Y to i32)),
i32 select (i1 icmp ult (i32 ptrtoint (i8* @X to i32),
i32 ptrtoint (i8* @Y to i32)),
i32 select (i1 icmp ult (i32 ptrtoint (ptr @X to i32),
i32 ptrtoint (ptr @Y to i32)),
i32 select (i1 icmp ult (i32 ptrtoint (ptr @X to i32),
i32 ptrtoint (ptr @Y to i32)),
i32 10, i32 20),
i32 30)
; CHECK: select = internal constant i32 select {{.*}} i32 10, i32 30
2 changes: 1 addition & 1 deletion llvm/test/Transforms/InstSimplify/ConstProp/div-zero.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ declare void @ext()
define i32 @foo(i32 %ptr) {
entry:
%zero = sub i32 %ptr, %ptr ; <i32> [#uses=1]
%div_zero = sdiv i32 %zero, ptrtoint (i32* getelementptr (i32, i32* null,
%div_zero = sdiv i32 %zero, ptrtoint (ptr getelementptr (i32, ptr null,
i32 1) to i32) ; <i32> [#uses=1]
ret i32 %div_zero
}
Expand Down
14 changes: 7 additions & 7 deletions llvm/test/Transforms/InstSimplify/ConstProp/float-to-ptr-cast.ll
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s

define i32* @test1() {
%X = inttoptr i64 0 to i32* ; <i32*> [#uses=1]
ret i32* %X
define ptr @test1() {
%X = inttoptr i64 0 to ptr ; <ptr> [#uses=1]
ret ptr %X
}

; CHECK: ret i32* null
; CHECK: ret ptr null

define i32* @test2() {
ret i32* null
define ptr @test2() {
ret ptr null
}

; CHECK: ret i32* null
; CHECK: ret ptr null

12 changes: 6 additions & 6 deletions llvm/test/Transforms/InstSimplify/ConstProp/freeze.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

define i64 @ptrdiff1() {
; CHECK-LABEL: @ptrdiff1(
; CHECK-NEXT: ret i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
; CHECK-NEXT: ret i64 sub (i64 ptrtoint (ptr @g to i64), i64 ptrtoint (ptr @g2 to i64))
;
%i = ptrtoint i16* @g to i64
%i2 = ptrtoint i16* @g2 to i64
%i = ptrtoint ptr @g to i64
%i2 = ptrtoint ptr @g2 to i64
%diff = sub i64 %i, %i2
%r = freeze i64 %diff
ret i64 %r
Expand All @@ -19,9 +19,9 @@ define i64 @ptrdiff2() {
; CHECK-LABEL: @ptrdiff2(
; CHECK-NEXT: ret i64 -2
;
%i = ptrtoint i16* @g to i64
%gep = getelementptr i16, i16* @g, i64 1
%i2 = ptrtoint i16* %gep to i64
%i = ptrtoint ptr @g to i64
%gep = getelementptr i16, ptr @g, i64 1
%i2 = ptrtoint ptr %gep to i64
%diff = sub i64 %i, %i2
%r = freeze i64 %diff
ret i64 %r
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=instsimplify -S < %s | FileCheck %s

@a1 = internal alias i32, getelementptr ({[3 x i32]}, {[3 x i32]}* @b, i32 0, i32 0, i32 1)
@a2 = weak alias i32, getelementptr ({[3 x i32]}, {[3 x i32]}* @b, i32 0, i32 0, i32 1)
@a1 = internal alias i32, getelementptr ({[3 x i32]}, ptr @b, i32 0, i32 0, i32 1)
@a2 = weak alias i32, getelementptr ({[3 x i32]}, ptr @b, i32 0, i32 0, i32 1)
@b = internal constant {[3 x i32]} {[3 x i32] [i32 2, i32 3, i32 4]}

@c = internal alias i32, getelementptr ({[3 x i32]}, {[3 x i32]}* @d, i32 0, i32 0, i32 1)
@c = internal alias i32, getelementptr ({[3 x i32]}, ptr @d, i32 0, i32 0, i32 1)
@d = weak constant {[3 x i32]} {[3 x i32] [i32 2, i32 3, i32 4]}

define i32 @f() {
; CHECK-LABEL: @f(
; CHECK-NEXT: ret i32 4
;
%a = load i32, i32* getelementptr (i32, i32* @a1, i64 1)
%a = load i32, ptr getelementptr (i32, ptr @a1, i64 1)
ret i32 %a
}

define i32 @g() {
; CHECK-LABEL: @g(
; CHECK-NEXT: [[A:%.*]] = load i32, i32* getelementptr (i32, i32* @a2, i64 1), align 4
; CHECK-NEXT: [[A:%.*]] = load i32, ptr getelementptr (i32, ptr @a2, i64 1), align 4
; CHECK-NEXT: ret i32 [[A]]
;
%a = load i32, i32* getelementptr (i32, i32* @a2, i64 1)
%a = load i32, ptr getelementptr (i32, ptr @a2, i64 1)
ret i32 %a
}

define i32 @h() {
; CHECK-LABEL: @h(
; CHECK-NEXT: [[A:%.*]] = load i32, i32* getelementptr (i32, i32* @c, i64 1), align 4
; CHECK-NEXT: [[A:%.*]] = load i32, ptr getelementptr (i32, ptr @c, i64 1), align 4
; CHECK-NEXT: ret i32 [[A]]
;
%a = load i32, i32* getelementptr (i32, i32* @c, i64 1)
%a = load i32, ptr getelementptr (i32, ptr @c, i64 1)
ret i32 %a
}
10 changes: 5 additions & 5 deletions llvm/test/Transforms/InstSimplify/ConstProp/gep-alias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@a = internal global [3 x i8*] zeroinitializer
@b = linkonce_odr alias [3 x i8*], [3 x i8*]* @a
@a = internal global [3 x ptr] zeroinitializer
@b = linkonce_odr alias [3 x ptr], ptr @a

define i8** @f() {
; CHECK: ret i8** getelementptr ([3 x i8*], [3 x i8*]* @b, i64 0, i64 1)
ret i8** getelementptr ([3 x i8*], [3 x i8*]* @b, i64 0, i64 1)
define ptr @f() {
; CHECK: ret ptr getelementptr ([3 x ptr], ptr @b, i64 0, i64 1)
ret ptr getelementptr ([3 x ptr], ptr @b, i64 0, i64 1)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target triple = "armv7-none-eabi"
@t6 = local_unnamed_addr global i32 1, align 4
@j = local_unnamed_addr global [6 x [6 x [7 x i8]]] [[6 x [7 x i8]] [[7 x i8] c"\06\00\00\00\00\00\00", [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer], [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer], align 1
@p = internal global i64 0, align 8
@y = local_unnamed_addr global i64* @p, align 4
@y = local_unnamed_addr global ptr @p, align 4
@b = internal unnamed_addr global i32 0, align 4
@h = common local_unnamed_addr global i16 0, align 2
@a = common local_unnamed_addr global i32 0, align 4
Expand All @@ -20,33 +20,33 @@ target triple = "armv7-none-eabi"
; Function Attrs: nounwind
define i32 @main() local_unnamed_addr {
entry:
%0 = load i32, i32* @t6, align 4
%0 = load i32, ptr @t6, align 4
%inc = add nsw i32 %0, 1
store i32 %inc, i32* @t6, align 4
store i16 4, i16* @h, align 2
%1 = load i32, i32* @a, align 4
store i32 %inc, ptr @t6, align 4
store i16 4, ptr @h, align 2
%1 = load i32, ptr @a, align 4
%conv = trunc i32 %1 to i8
store i32 1, i32* @f, align 4
%2 = load i64, i64* @p, align 8
store i32 1, ptr @f, align 4
%2 = load i64, ptr @p, align 8
%cmp4 = icmp slt i64 %2, 2
%conv6 = zext i1 %cmp4 to i8
%3 = load i16, i16* @h, align 2
%3 = load i16, ptr @h, align 2
%conv7 = sext i16 %3 to i32
%add = add nsw i32 %conv7, 1
%f.promoted = load i32, i32* @f, align 4
%f.promoted = load i32, ptr @f, align 4
%4 = mul i32 %conv7, 7
%5 = add i32 %4, 5
%6 = sub i32 -1, %f.promoted
%7 = icmp sgt i32 %6, -2
%smax = select i1 %7, i32 %6, i32 -2
%8 = sub i32 6, %smax
%scevgep = getelementptr [6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i32 0, i32 %5, i32 %8
%scevgep = getelementptr [6 x [6 x [7 x i8]]], ptr @j, i32 0, i32 0, i32 %5, i32 %8
%9 = add i32 %f.promoted, %smax
%10 = add i32 %9, 2
call void @llvm.memset.p0i8.i32(i8* %scevgep, i8 %conv6, i32 %10, i1 false)
; CHECK: call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i{{32|64}} 5, i{{32|64}} 4, i32 1), i8 %conv6, i32 1, i1 false)
; CHECK-NOT: call void @llvm.memset.p0i8.i32(i8* getelementptr ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i64 1, i64 4, i64 4, i32 1)
call void @llvm.memset.p0.i32(ptr %scevgep, i8 %conv6, i32 %10, i1 false)
; CHECK: call void @llvm.memset.p0.i32(ptr getelementptr inbounds ([6 x [6 x [7 x i8]]], ptr @j, i32 0, i{{32|64}} 5, i{{32|64}} 4, i32 1), i8 %conv6, i32 1, i1 false)
; CHECK-NOT: call void @llvm.memset.p0.i32(ptr getelementptr ([6 x [6 x [7 x i8]]], ptr @j, i64 1, i64 4, i64 4, i32 1)
ret i32 0
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1)
declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1)
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
%rec8 = type { i16 }
@a = global [1 x %rec8] zeroinitializer

define <2 x i16*> @test_gep() {
define <2 x ptr> @test_gep() {
; CHECK-LABEL: @test_gep(
; CHECK-NEXT: ret <2 x i16*> <i16* getelementptr inbounds ([1 x %rec8], [1 x %rec8]* @a, i32 0, i32 0, i32 0), i16* getelementptr inbounds ([1 x %rec8], [1 x %rec8]* @a, i32 0, i32 0, i32 0)>
; CHECK-NEXT: ret <2 x ptr> <ptr @a, ptr @a>
;
%A = getelementptr [1 x %rec8], [1 x %rec8]* @a, <2 x i16> zeroinitializer, <2 x i64> zeroinitializer
%B = bitcast <2 x %rec8*> %A to <2 x i16*>
ret <2 x i16*> %B
%A = getelementptr [1 x %rec8], ptr @a, <2 x i16> zeroinitializer, <2 x i64> zeroinitializer
%B = bitcast <2 x ptr> %A to <2 x ptr>
ret <2 x ptr> %B
}

; Testcase that verify the cast-of-cast when the outer/second cast is to a
Expand Down
148 changes: 71 additions & 77 deletions llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S -verify | FileCheck %s

define i1 @ule_null_constexpr(i8* %x) {
define i1 @ule_null_constexpr(ptr %x) {
; CHECK-LABEL: @ule_null_constexpr(
; CHECK-NEXT: ret i1 true
;
%cmp = icmp ule i8 (...)* null, bitcast (i1 (i8*)* @ule_null_constexpr to i8 (...)*)
%cmp = icmp ule ptr null, @ule_null_constexpr
ret i1 %cmp
}

define i1 @ugt_null_constexpr(i8* %x) {
define i1 @ugt_null_constexpr(ptr %x) {
; CHECK-LABEL: @ugt_null_constexpr(
; CHECK-NEXT: ret i1 false
;
%cmp = icmp ugt i8 (...)* null, bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*)
%cmp = icmp ugt ptr null, @ugt_null_constexpr
ret i1 %cmp
}

define i1 @uge_constexpr_null(i8* %x) {
define i1 @uge_constexpr_null(ptr %x) {
; CHECK-LABEL: @uge_constexpr_null(
; CHECK-NEXT: ret i1 true
;
%cmp = icmp uge i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), null
%cmp = icmp uge ptr @ugt_null_constexpr, null
ret i1 %cmp
}

define i1 @ult_constexpr_null(i8* %x) {
define i1 @ult_constexpr_null(ptr %x) {
; CHECK-LABEL: @ult_constexpr_null(
; CHECK-NEXT: ret i1 false
;
%cmp = icmp ult i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), null
%cmp = icmp ult ptr @ugt_null_constexpr, null
ret i1 %cmp
}

; Negative test - we don't know if the constexpr is null.

define i1 @ule_constexpr_null(i8* %x) {
define i1 @ule_constexpr_null(ptr %x) {
; CHECK-LABEL: @ule_constexpr_null(
; CHECK-NEXT: ret i1 false
;
%cmp = icmp ule i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), null
%cmp = icmp ule ptr @ugt_null_constexpr, null
ret i1 %cmp
}

; Negative test - we don't know if the constexpr is *signed* less-than null.

define i1 @slt_constexpr_null(i8* %x) {
define i1 @slt_constexpr_null(ptr %x) {
; CHECK-LABEL: @slt_constexpr_null(
; CHECK-NEXT: ret i1 icmp slt (i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), i8 (...)* null)
; CHECK-NEXT: ret i1 icmp slt (ptr @ugt_null_constexpr, ptr null)
;
%cmp = icmp slt i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), null
%cmp = icmp slt ptr @ugt_null_constexpr, null
ret i1 %cmp
}

; Negative test - we don't try to evaluate this comparison of constant expressions.

define i1 @ult_constexpr_constexpr_one(i8* %x) {
define i1 @ult_constexpr_constexpr_one(ptr %x) {
; CHECK-LABEL: @ult_constexpr_constexpr_one(
; CHECK-NEXT: ret i1 icmp ult (i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), i8 (...)* inttoptr (i32 1 to i8 (...)*))
; CHECK-NEXT: ret i1 icmp ugt (ptr inttoptr (i32 1 to ptr), ptr @ugt_null_constexpr)
;
%cmp = icmp ult i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), inttoptr (i32 1 to i8 (...)*)
%cmp = icmp ult ptr @ugt_null_constexpr, inttoptr (i32 1 to ptr)
ret i1 %cmp
}

Expand All @@ -72,212 +72,206 @@ define i1 @global_ne_null() {
; CHECK-LABEL: @global_ne_null(
; CHECK-NEXT: ret i1 true
;
%cmp = icmp ne [2 x i32]* @g, null
%cmp = icmp ne ptr @g, null
ret i1 %cmp
}

define i1 @global_ugt_null() {
; CHECK-LABEL: @global_ugt_null(
; CHECK-NEXT: ret i1 true
;
%cmp = icmp ugt [2 x i32]* @g, null
%cmp = icmp ugt ptr @g, null
ret i1 %cmp
}

define i1 @global_sgt_null() {
; CHECK-LABEL: @global_sgt_null(
; CHECK-NEXT: ret i1 icmp sgt ([2 x i32]* @g, [2 x i32]* null)
; CHECK-NEXT: ret i1 icmp sgt (ptr @g, ptr null)
;
%cmp = icmp sgt [2 x i32]* @g, null
%cmp = icmp sgt ptr @g, null
ret i1 %cmp
}

; Should not fold to true, as the gep computes a null value.
define i1 @global_out_of_bounds_gep_ne_null() {
; CHECK-LABEL: @global_out_of_bounds_gep_ne_null(
; CHECK-NEXT: ret i1 icmp ne (i8* getelementptr (i8, i8* @g3, i64 sub (i64 0, i64 ptrtoint (i8* @g3 to i64))), i8* null)
; CHECK-NEXT: ret i1 icmp ne (ptr getelementptr (i8, ptr @g3, i64 sub (i64 0, i64 ptrtoint (ptr @g3 to i64))), ptr null)
;
%cmp = icmp ne i8* getelementptr (i8, i8* @g3, i64 sub (i64 0, i64 ptrtoint (i8* @g3 to i64))), null
%cmp = icmp ne ptr getelementptr (i8, ptr @g3, i64 sub (i64 0, i64 ptrtoint (ptr @g3 to i64))), null
ret i1 %cmp
}

define i1 @global_inbounds_gep_ne_null() {
; CHECK-LABEL: @global_inbounds_gep_ne_null(
; CHECK-NEXT: ret i1 true
;
%gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
%cmp = icmp ne [2 x i32]* %gep, null
%gep = getelementptr inbounds [2 x i32], ptr @g, i64 1
%cmp = icmp ne ptr %gep, null
ret i1 %cmp
}

define i1 @global_gep_ugt_null() {
; CHECK-LABEL: @global_gep_ugt_null(
; CHECK-NEXT: ret i1 true
;
%gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
%cmp = icmp ugt [2 x i32]* %gep, null
%gep = getelementptr inbounds [2 x i32], ptr @g, i64 1
%cmp = icmp ugt ptr %gep, null
ret i1 %cmp
}

define i1 @global_gep_sgt_null() {
; CHECK-LABEL: @global_gep_sgt_null(
; CHECK-NEXT: ret i1 icmp sgt ([2 x i32]* getelementptr inbounds ([2 x i32], [2 x i32]* @g, i64 1), [2 x i32]* null)
; CHECK-NEXT: ret i1 icmp sgt (ptr getelementptr inbounds ([2 x i32], ptr @g, i64 1), ptr null)
;
%gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
%cmp = icmp sgt [2 x i32]* %gep, null
%gep = getelementptr inbounds [2 x i32], ptr @g, i64 1
%cmp = icmp sgt ptr %gep, null
ret i1 %cmp
}

; @g2_weak may be null, in which case this is a zero-index GEP and the pointers
; are equal.
define i1 @null_gep_ne_null() {
; CHECK-LABEL: @null_gep_ne_null(
; CHECK-NEXT: ret i1 icmp ne (i8* getelementptr (i8, i8* null, i64 ptrtoint (i32* @g2_weak to i64)), i8* null)
; CHECK-NEXT: ret i1 icmp ne (ptr getelementptr (i8, ptr null, i64 ptrtoint (ptr @g2_weak to i64)), ptr null)
;
%gep = getelementptr i8, i8* null, i64 ptrtoint (i32* @g2_weak to i64)
%cmp = icmp ne i8* %gep, null
%gep = getelementptr i8, ptr null, i64 ptrtoint (ptr @g2_weak to i64)
%cmp = icmp ne ptr %gep, null
ret i1 %cmp
}

define i1 @null_gep_ugt_null() {
; CHECK-LABEL: @null_gep_ugt_null(
; CHECK-NEXT: ret i1 icmp ugt (i8* getelementptr (i8, i8* null, i64 ptrtoint (i32* @g2_weak to i64)), i8* null)
; CHECK-NEXT: ret i1 icmp ugt (ptr getelementptr (i8, ptr null, i64 ptrtoint (ptr @g2_weak to i64)), ptr null)
;
%gep = getelementptr i8, i8* null, i64 ptrtoint (i32* @g2_weak to i64)
%cmp = icmp ugt i8* %gep, null
%gep = getelementptr i8, ptr null, i64 ptrtoint (ptr @g2_weak to i64)
%cmp = icmp ugt ptr %gep, null
ret i1 %cmp
}

define i1 @null_gep_sgt_null() {
; CHECK-LABEL: @null_gep_sgt_null(
; CHECK-NEXT: ret i1 icmp sgt (i8* getelementptr (i8, i8* null, i64 ptrtoint (i32* @g2_weak to i64)), i8* null)
; CHECK-NEXT: ret i1 icmp sgt (ptr getelementptr (i8, ptr null, i64 ptrtoint (ptr @g2_weak to i64)), ptr null)
;
%gep = getelementptr i8, i8* null, i64 ptrtoint (i32* @g2_weak to i64)
%cmp = icmp sgt i8* %gep, null
%gep = getelementptr i8, ptr null, i64 ptrtoint (ptr @g2_weak to i64)
%cmp = icmp sgt ptr %gep, null
ret i1 %cmp
}

define i1 @null_gep_ne_null_constant_int() {
; CHECK-LABEL: @null_gep_ne_null_constant_int(
; CHECK-NEXT: ret i1 true
;
%gep = getelementptr i8, i8* null, i64 1
%cmp = icmp ne i8* %gep, null
%gep = getelementptr i8, ptr null, i64 1
%cmp = icmp ne ptr %gep, null
ret i1 %cmp
}

define i1 @null_gep_ugt_null_constant_int() {
; CHECK-LABEL: @null_gep_ugt_null_constant_int(
; CHECK-NEXT: ret i1 true
;
%gep = getelementptr i8, i8* null, i64 1
%cmp = icmp ugt i8* %gep, null
%gep = getelementptr i8, ptr null, i64 1
%cmp = icmp ugt ptr %gep, null
ret i1 %cmp
}

define i1 @null_gep_ne_global() {
; CHECK-LABEL: @null_gep_ne_global(
; CHECK-NEXT: ret i1 icmp ne (i8* getelementptr (i8, i8* null, i64 ptrtoint (i8* @g3 to i64)), i8* @g3)
; CHECK-NEXT: ret i1 icmp ne (ptr getelementptr (i8, ptr null, i64 ptrtoint (ptr @g3 to i64)), ptr @g3)
;
%gep = getelementptr i8, i8* null, i64 ptrtoint (i8* @g3 to i64)
%cmp = icmp ne i8* %gep, @g3
%gep = getelementptr i8, ptr null, i64 ptrtoint (ptr @g3 to i64)
%cmp = icmp ne ptr %gep, @g3
ret i1 %cmp
}

define i1 @null_gep_ult_global() {
; CHECK-LABEL: @null_gep_ult_global(
; CHECK-NEXT: ret i1 icmp ult (i8* getelementptr (i8, i8* null, i64 ptrtoint (i8* @g3 to i64)), i8* @g3)
; CHECK-NEXT: ret i1 icmp ult (ptr getelementptr (i8, ptr null, i64 ptrtoint (ptr @g3 to i64)), ptr @g3)
;
%gep = getelementptr i8, i8* null, i64 ptrtoint (i8* @g3 to i64)
%cmp = icmp ult i8* %gep, @g3
%gep = getelementptr i8, ptr null, i64 ptrtoint (ptr @g3 to i64)
%cmp = icmp ult ptr %gep, @g3
ret i1 %cmp
}

define i1 @null_gep_slt_global() {
; CHECK-LABEL: @null_gep_slt_global(
; CHECK-NEXT: ret i1 icmp slt ([2 x i32]* getelementptr ([2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)), [2 x i32]* @g)
; CHECK-NEXT: ret i1 icmp slt (ptr getelementptr ([2 x i32], ptr null, i64 ptrtoint (ptr @g2 to i64)), ptr @g)
;
%gep = getelementptr [2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)
%cmp = icmp slt [2 x i32]* %gep, @g
%gep = getelementptr [2 x i32], ptr null, i64 ptrtoint (ptr @g2 to i64)
%cmp = icmp slt ptr %gep, @g
ret i1 %cmp
}

define i1 @global_gep_ne_global() {
; CHECK-LABEL: @global_gep_ne_global(
; CHECK-NEXT: ret i1 true
;
%gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
%cmp = icmp ne [2 x i32]* %gep, @g
%gep = getelementptr inbounds [2 x i32], ptr @g, i64 1
%cmp = icmp ne ptr %gep, @g
ret i1 %cmp
}

define i1 @global_gep_ugt_global() {
; CHECK-LABEL: @global_gep_ugt_global(
; CHECK-NEXT: ret i1 true
;
%gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
%cmp = icmp ugt [2 x i32]* %gep, @g
%gep = getelementptr inbounds [2 x i32], ptr @g, i64 1
%cmp = icmp ugt ptr %gep, @g
ret i1 %cmp
}

define i1 @global_gep_sgt_global() {
; CHECK-LABEL: @global_gep_sgt_global(
; CHECK-NEXT: ret i1 icmp sgt ([2 x i32]* getelementptr inbounds ([2 x i32], [2 x i32]* @g, i64 1), [2 x i32]* @g)
; CHECK-NEXT: ret i1 icmp sgt (ptr getelementptr inbounds ([2 x i32], ptr @g, i64 1), ptr @g)
;
%gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
%cmp = icmp sgt [2 x i32]* %gep, @g
%gep = getelementptr inbounds [2 x i32], ptr @g, i64 1
%cmp = icmp sgt ptr %gep, @g
ret i1 %cmp
}

; This should not fold to true, as the offset is negative.
define i1 @global_gep_ugt_global_neg_offset() {
; CHECK-LABEL: @global_gep_ugt_global_neg_offset(
; CHECK-NEXT: ret i1 icmp ugt ([2 x i32]* getelementptr ([2 x i32], [2 x i32]* @g, i64 -1), [2 x i32]* @g)
; CHECK-NEXT: ret i1 icmp ugt (ptr getelementptr ([2 x i32], ptr @g, i64 -1), ptr @g)
;
%gep = getelementptr [2 x i32], [2 x i32]* @g, i64 -1
%cmp = icmp ugt [2 x i32]* %gep, @g
%gep = getelementptr [2 x i32], ptr @g, i64 -1
%cmp = icmp ugt ptr %gep, @g
ret i1 %cmp
}

define i1 @global_gep_sgt_global_neg_offset() {
; CHECK-LABEL: @global_gep_sgt_global_neg_offset(
; CHECK-NEXT: ret i1 icmp sgt ([2 x i32]* getelementptr ([2 x i32], [2 x i32]* @g, i64 -1), [2 x i32]* @g)
; CHECK-NEXT: ret i1 icmp sgt (ptr getelementptr ([2 x i32], ptr @g, i64 -1), ptr @g)
;
%gep = getelementptr [2 x i32], [2 x i32]* @g, i64 -1
%cmp = icmp sgt [2 x i32]* %gep, @g
%gep = getelementptr [2 x i32], ptr @g, i64 -1
%cmp = icmp sgt ptr %gep, @g
ret i1 %cmp
}

define i1 @global_gep_ugt_global_gep() {
; CHECK-LABEL: @global_gep_ugt_global_gep(
; CHECK-NEXT: ret i1 true
;
%gep1 = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 0, i64 0
%gep2 = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 0, i64 1
%cmp = icmp ugt i32* %gep2, %gep1
%gep2 = getelementptr inbounds [2 x i32], ptr @g, i64 0, i64 1
%cmp = icmp ugt ptr %gep2, @g
ret i1 %cmp
}

; Should not fold due to signed comparison.
define i1 @global_gep_sgt_global_gep() {
; CHECK-LABEL: @global_gep_sgt_global_gep(
; CHECK-NEXT: ret i1 icmp sgt (i32* getelementptr inbounds ([2 x i32], [2 x i32]* @g, i64 0, i64 1), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @g, i64 0, i64 0))
; CHECK-NEXT: ret i1 icmp sgt (ptr getelementptr inbounds ([2 x i32], ptr @g, i64 0, i64 1), ptr @g)
;
%gep1 = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 0, i64 0
%gep2 = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 0, i64 1
%cmp = icmp sgt i32* %gep2, %gep1
%gep2 = getelementptr inbounds [2 x i32], ptr @g, i64 0, i64 1
%cmp = icmp sgt ptr %gep2, @g
ret i1 %cmp
}

define i1 @global_gep_ugt_global_gep_complex() {
; CHECK-LABEL: @global_gep_ugt_global_gep_complex(
; CHECK-NEXT: ret i1 true
;
%gep1 = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 0, i64 0
%gep2 = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 0, i64 0
%gep2.cast = bitcast i32* %gep2 to i8*
%gep3 = getelementptr inbounds i8, i8* %gep2.cast, i64 2
%gep3.cast = bitcast i8* %gep3 to i32*
%cmp = icmp ugt i32* %gep3.cast, %gep1
%gep3 = getelementptr inbounds i8, ptr @g, i64 2
%cmp = icmp ugt ptr %gep3, @g
ret i1 %cmp
}
124 changes: 62 additions & 62 deletions llvm/test/Transforms/InstSimplify/ConstProp/loads.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define i32 @test1() {
; CHECK-LABEL: @test1(
; CHECK-NEXT: ret i32 -559038737
;
%r = load i32, i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0)
%r = load i32, ptr getelementptr ({{i32,i8},i32}, ptr @g1, i32 0, i32 0, i32 0)
ret i32 %r
}

Expand All @@ -26,7 +26,7 @@ define i16 @test2() {
; BE-LABEL: @test2(
; BE-NEXT: ret i16 -8531
;
%r = load i16, i16* bitcast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*)
%r = load i16, ptr getelementptr ({{i32,i8},i32}, ptr @g1, i32 0, i32 0, i32 0)
ret i16 %r
}

Expand All @@ -37,7 +37,7 @@ define i16 @test2_addrspacecast() {
; BE-LABEL: @test2_addrspacecast(
; BE-NEXT: ret i16 -8531
;
%r = load i16, i16 addrspace(1)* addrspacecast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16 addrspace(1)*)
%r = load i16, ptr addrspace(1) addrspacecast(ptr getelementptr ({{i32,i8},i32}, ptr @g1, i32 0, i32 0, i32 0) to ptr addrspace(1))
ret i16 %r
}

Expand All @@ -49,7 +49,7 @@ define i16 @test3() {
; BE-LABEL: @test3(
; BE-NEXT: ret i16 -16657
;
%r = load i16, i16* getelementptr(i16, i16* bitcast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 1)
%r = load i16, ptr getelementptr(i16, ptr getelementptr ({{i32,i8},i32}, ptr @g1, i32 0, i32 0, i32 0), i32 1)
ret i16 %r
}

Expand All @@ -61,7 +61,7 @@ define i16 @test4() {
; BE-LABEL: @test4(
; BE-NEXT: ret i16 -17920
;
%r = load i16, i16* getelementptr(i16, i16* bitcast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 2)
%r = load i16, ptr getelementptr(i16, ptr getelementptr ({{i32,i8},i32}, ptr @g1, i32 0, i32 0, i32 0), i32 2)
ret i16 %r
}

Expand All @@ -70,7 +70,7 @@ define i64 @test6() {
; CHECK-LABEL: @test6(
; CHECK-NEXT: ret i64 4607182418800017408
;
%r = load i64, i64* bitcast(double* @g2 to i64*)
%r = load i64, ptr @g2
ret i64 %r
}

Expand All @@ -82,7 +82,7 @@ define i16 @test7() {
; BE-LABEL: @test7(
; BE-NEXT: ret i16 16368
;
%r = load i16, i16* bitcast(double* @g2 to i16*)
%r = load i16, ptr @g2
ret i16 %r
}

Expand All @@ -94,7 +94,7 @@ define double @test8() {
; BE-LABEL: @test8(
; BE-NEXT: ret double 0xDEADBEEFBA000000
;
%r = load double, double* bitcast({{i32,i8},i32}* @g1 to double*)
%r = load double, ptr @g1
ret double %r
}

Expand All @@ -107,7 +107,7 @@ define i128 @test_i128() {
; BE-LABEL: @test_i128(
; BE-NEXT: ret i128 2268949521066387161080
;
%r = load i128, i128* bitcast({i64, i64}* @g3 to i128*)
%r = load i128, ptr @g3
ret i128 %r
}

Expand All @@ -118,7 +118,7 @@ define fp128 @test_fp128() {
; BE-LABEL: @test_fp128(
; BE-NEXT: ret fp128 0xL0000000006B1BFF8000000000000007B
;
%r = load fp128, fp128* bitcast({i64, i64}* @g3 to fp128*)
%r = load fp128, ptr @g3
ret fp128 %r
}

Expand All @@ -129,7 +129,7 @@ define ppc_fp128 @test_ppc_fp128() {
; BE-LABEL: @test_ppc_fp128(
; BE-NEXT: ret ppc_fp128 bitcast (i128 2268949521066387161080 to ppc_fp128)
;
%r = load ppc_fp128, ppc_fp128* bitcast({i64, i64}* @g3 to ppc_fp128*)
%r = load ppc_fp128, ptr @g3
ret ppc_fp128 %r
}

Expand All @@ -140,7 +140,7 @@ define x86_fp80 @test_x86_fp80() {
; BE-LABEL: @test_x86_fp80(
; BE-NEXT: ret x86_fp80 0xK000000000000007B0000
;
%r = load x86_fp80, x86_fp80* bitcast({i64, i64}* @g3 to x86_fp80*)
%r = load x86_fp80, ptr @g3
ret x86_fp80 %r
}

Expand All @@ -151,7 +151,7 @@ define bfloat @test_bfloat() {
; BE-LABEL: @test_bfloat(
; BE-NEXT: ret bfloat 0xR0000
;
%r = load bfloat, bfloat* bitcast({i64, i64}* @g3 to bfloat*)
%r = load bfloat, ptr @g3
ret bfloat %r
}

Expand All @@ -160,7 +160,7 @@ define <2 x i64> @test10() {
; CHECK-LABEL: @test10(
; CHECK-NEXT: ret <2 x i64> <i64 123, i64 112312312>
;
%r = load <2 x i64>, <2 x i64>* bitcast({i64, i64}* @g3 to <2 x i64>*)
%r = load <2 x i64>, ptr @g3
ret <2 x i64> %r
}

Expand All @@ -179,7 +179,7 @@ define i16 @test11() nounwind {
; BE-NEXT: ret i16 -24312
;
entry:
%a = load i16, i16* bitcast ({ i8, i8 }* @g4 to i16*)
%a = load i16, ptr @g4
ret i16 %a
}

Expand All @@ -194,7 +194,7 @@ define i16 @test12() {
; BE-LABEL: @test12(
; BE-NEXT: ret i16 25088
;
%a = load i16, i16* getelementptr inbounds ([3 x i16], [3 x i16]* bitcast ([6 x i8]* @test12g to [3 x i16]*), i32 0, i64 1)
%a = load i16, ptr getelementptr inbounds ([3 x i16], ptr @test12g, i32 0, i64 1)
ret i16 %a
}

Expand All @@ -205,30 +205,30 @@ define i1 @test13() {
; CHECK-LABEL: @test13(
; CHECK-NEXT: ret i1 false
;
%A = load i1, i1* bitcast (i8* @g5 to i1*)
%A = load i1, ptr @g5
ret i1 %A
}

@g6 = constant [2 x i8*] [i8* inttoptr (i64 1 to i8*), i8* inttoptr (i64 2 to i8*)]
@g6 = constant [2 x ptr] [ptr inttoptr (i64 1 to ptr), ptr inttoptr (i64 2 to ptr)]
define i64 @test14() nounwind {
; CHECK-LABEL: @test14(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i64 1
;
entry:
%tmp = load i64, i64* bitcast ([2 x i8*]* @g6 to i64*)
%tmp = load i64, ptr @g6
ret i64 %tmp
}

; Check with address space pointers
@g6_as1 = constant [2 x i8 addrspace(1)*] [i8 addrspace(1)* inttoptr (i16 1 to i8 addrspace(1)*), i8 addrspace(1)* inttoptr (i16 2 to i8 addrspace(1)*)]
@g6_as1 = constant [2 x ptr addrspace(1)] [ptr addrspace(1) inttoptr (i16 1 to ptr addrspace(1)), ptr addrspace(1) inttoptr (i16 2 to ptr addrspace(1))]
define i16 @test14_as1() nounwind {
; CHECK-LABEL: @test14_as1(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i16 1
;
entry:
%tmp = load i16, i16* bitcast ([2 x i8 addrspace(1)*]* @g6_as1 to i16*)
%tmp = load i16, ptr @g6_as1
ret i16 %tmp
}

Expand All @@ -238,43 +238,43 @@ define i64 @test15() nounwind {
; CHECK-NEXT: ret i64 2
;
entry:
%tmp = load i64, i64* bitcast (i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @g6, i32 0, i64 1) to i64*)
%tmp = load i64, ptr getelementptr inbounds ([2 x ptr], ptr @g6, i32 0, i64 1)
ret i64 %tmp
}

@gv7 = constant [4 x i8*] [i8* null, i8* inttoptr (i64 -14 to i8*), i8* null, i8* null]
@gv7 = constant [4 x ptr] [ptr null, ptr inttoptr (i64 -14 to ptr), ptr null, ptr null]
define i64 @test16.1() {
; CHECK-LABEL: @test16.1(
; CHECK-NEXT: ret i64 0
;
%v = load i64, i64* bitcast ([4 x i8*]* @gv7 to i64*), align 8
%v = load i64, ptr @gv7, align 8
ret i64 %v
}

define i64 @test16.2() {
; CHECK-LABEL: @test16.2(
; CHECK-NEXT: ret i64 -14
;
%v = load i64, i64* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @gv7, i64 0, i64 1) to i64*), align 8
%v = load i64, ptr getelementptr inbounds ([4 x ptr], ptr @gv7, i64 0, i64 1), align 8
ret i64 %v
}

define i64 @test16.3() {
; CHECK-LABEL: @test16.3(
; CHECK-NEXT: ret i64 0
;
%v = load i64, i64* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @gv7, i64 0, i64 2) to i64*), align 8
%v = load i64, ptr getelementptr inbounds ([4 x ptr], ptr @gv7, i64 0, i64 2), align 8
ret i64 %v
}

@g7 = constant {[0 x i32], [0 x i8], {}*} { [0 x i32] undef, [0 x i8] undef, {}* null }
@g7 = constant {[0 x i32], [0 x i8], ptr} { [0 x i32] undef, [0 x i8] undef, ptr null }

define i64* @test_leading_zero_size_elems() {
define ptr @test_leading_zero_size_elems() {
; CHECK-LABEL: @test_leading_zero_size_elems(
; CHECK-NEXT: ret i64* null
; CHECK-NEXT: ret ptr null
;
%v = load i64*, i64** bitcast ({[0 x i32], [0 x i8], {}*}* @g7 to i64**)
ret i64* %v
%v = load ptr, ptr @g7
ret ptr %v
}

@g8 = constant {[4294967295 x [0 x i32]], i64} { [4294967295 x [0 x i32]] undef, i64 123 }
Expand All @@ -283,7 +283,7 @@ define i64 @test_leading_zero_size_elems_big() {
; CHECK-LABEL: @test_leading_zero_size_elems_big(
; CHECK-NEXT: ret i64 123
;
%v = load i64, i64* bitcast ({[4294967295 x [0 x i32]], i64}* @g8 to i64*)
%v = load i64, ptr @g8
ret i64 %v
}

Expand All @@ -293,45 +293,45 @@ define i64 @test_array_of_zero_size_array() {
; CHECK-LABEL: @test_array_of_zero_size_array(
; CHECK-NEXT: ret i64 undef
;
%v = load i64, i64* bitcast ([4294967295 x [0 x i32]]* @g9 to i64*)
%v = load i64, ptr @g9
ret i64 %v
}

@g_undef = constant { i128 } undef

define i32* @test_undef_aggregate() {
define ptr @test_undef_aggregate() {
; CHECK-LABEL: @test_undef_aggregate(
; CHECK-NEXT: ret i32* undef
; CHECK-NEXT: ret ptr undef
;
%v = load i32*, i32** bitcast ({i128}* @g_undef to i32**)
ret i32* %v
%v = load ptr, ptr @g_undef
ret ptr %v
}

@g_poison = constant { i128 } poison

define i32* @test_poison_aggregate() {
define ptr @test_poison_aggregate() {
; CHECK-LABEL: @test_poison_aggregate(
; CHECK-NEXT: ret i32* poison
; CHECK-NEXT: ret ptr poison
;
%v = load i32*, i32** bitcast ({i128}* @g_poison to i32**)
ret i32* %v
%v = load ptr, ptr @g_poison
ret ptr %v
}

@g11 = constant <{ [8 x i8], [8 x i8] }> <{ [8 x i8] undef, [8 x i8] zeroinitializer }>, align 4

define {}* @test_trailing_zero_gep_index() {
define ptr @test_trailing_zero_gep_index() {
; CHECK-LABEL: @test_trailing_zero_gep_index(
; CHECK-NEXT: ret {}* null
; CHECK-NEXT: ret ptr null
;
%v = load {}*, {}** bitcast (i8* getelementptr inbounds (<{ [8 x i8], [8 x i8] }>, <{ [8 x i8], [8 x i8] }>* @g11, i32 0, i32 1, i32 0) to {}**), align 4
ret {}* %v
%v = load ptr, ptr getelementptr inbounds (<{ [8 x i8], [8 x i8] }>, ptr @g11, i32 0, i32 1, i32 0), align 4
ret ptr %v
}

define { i64, i64 } @test_load_struct() {
; CHECK-LABEL: @test_load_struct(
; CHECK-NEXT: ret { i64, i64 } { i64 123, i64 112312312 }
;
%v = load { i64, i64 }, { i64, i64 }* @g3
%v = load { i64, i64 }, ptr @g3
ret { i64, i64 } %v
}

Expand All @@ -341,10 +341,10 @@ define { i64, i64 } @test_load_struct() {
; This should not try to create an x86_mmx null value.
define x86_mmx @load_mmx() {
; CHECK-LABEL: @load_mmx(
; CHECK-NEXT: [[TEMP:%.*]] = load x86_mmx, x86_mmx* bitcast (i64* getelementptr ([2 x i64], [2 x i64]* @m64, i64 0, i64 ptrtoint (i32* @idx to i64)) to x86_mmx*), align 8
; CHECK-NEXT: [[TEMP:%.*]] = load x86_mmx, ptr getelementptr ([2 x i64], ptr @m64, i64 0, i64 ptrtoint (ptr @idx to i64)), align 8
; CHECK-NEXT: ret x86_mmx [[TEMP]]
;
%temp = load x86_mmx, x86_mmx* bitcast (i64* getelementptr ([2 x i64], [2 x i64]* @m64, i64 0, i64 ptrtoint (i32* @idx to i64)) to x86_mmx*)
%temp = load x86_mmx, ptr getelementptr ([2 x i64], ptr @m64, i64 0, i64 ptrtoint (ptr @idx to i64))
ret x86_mmx %temp
}

Expand All @@ -356,7 +356,7 @@ define i8 @load_neg_one_at_unknown_offset() {
; CHECK-LABEL: @load_neg_one_at_unknown_offset(
; CHECK-NEXT: ret i8 -1
;
%v = load i8, i8* getelementptr (<4 x i8>, <4 x i8>* @g_neg_one_vec, i64 0, i64 ptrtoint (i64* @g_offset to i64))
%v = load i8, ptr getelementptr (<4 x i8>, ptr @g_neg_one_vec, i64 0, i64 ptrtoint (ptr @g_offset to i64))
ret i8 %v
}

Expand All @@ -366,7 +366,7 @@ define i32 @load_padding() {
; CHECK-LABEL: @load_padding(
; CHECK-NEXT: ret i32 undef
;
%v = load i32, i32* getelementptr (i32, i32* bitcast ({ i32, [4 x i8] }* @g_with_padding to i32*), i64 1)
%v = load i32, ptr getelementptr (i32, ptr @g_with_padding, i64 1)
ret i32 %v
}

Expand All @@ -377,30 +377,30 @@ define i32 @load_all_undef() {
; CHECK-LABEL: @load_all_undef(
; CHECK-NEXT: ret i32 undef
;
%v = load i32, i32* getelementptr (i32, i32* bitcast ({ i32, [4 x i8] }* @g_all_undef to i32*), i64 1)
%v = load i32, ptr getelementptr (i32, ptr @g_all_undef, i64 1)
ret i32 %v
}

@g_i8_data = constant [16 x i8] c"\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"

define i64* @load_ptr_from_i8_data() {
define ptr @load_ptr_from_i8_data() {
; LE-LABEL: @load_ptr_from_i8_data(
; LE-NEXT: ret i64* inttoptr (i64 1 to i64*)
; LE-NEXT: ret ptr inttoptr (i64 1 to ptr)
;
; BE-LABEL: @load_ptr_from_i8_data(
; BE-NEXT: ret i64* inttoptr (i64 72057594037927936 to i64*)
; BE-NEXT: ret ptr inttoptr (i64 72057594037927936 to ptr)
;
%v = load i64*, i64** bitcast ([16 x i8]* @g_i8_data to i64**)
ret i64* %v
%v = load ptr, ptr @g_i8_data
ret ptr %v
}

define i64 addrspace(2)* @load_non_integral_ptr_from_i8_data() {
define ptr addrspace(2) @load_non_integral_ptr_from_i8_data() {
; CHECK-LABEL: @load_non_integral_ptr_from_i8_data(
; CHECK-NEXT: [[V:%.*]] = load i64 addrspace(2)*, i64 addrspace(2)** bitcast ([16 x i8]* @g_i8_data to i64 addrspace(2)**), align 8
; CHECK-NEXT: ret i64 addrspace(2)* [[V]]
; CHECK-NEXT: [[V:%.*]] = load ptr addrspace(2), ptr @g_i8_data, align 8
; CHECK-NEXT: ret ptr addrspace(2) [[V]]
;
%v = load i64 addrspace(2)*, i64 addrspace(2)** bitcast ([16 x i8]* @g_i8_data to i64 addrspace(2)**)
ret i64 addrspace(2)* %v
%v = load ptr addrspace(2), ptr @g_i8_data
ret ptr addrspace(2) %v
}

@g_i1 = constant i1 true
Expand All @@ -409,6 +409,6 @@ define i8 @load_i8_from_i1() {
; CHECK-LABEL: @load_i8_from_i1(
; CHECK-NEXT: ret i8 -1
;
%v = load i8, i8* bitcast (i1* @g_i1 to i8*)
%v = load i8, ptr @g_i1
ret i8 %v
}
14 changes: 7 additions & 7 deletions llvm/test/Transforms/InstSimplify/ConstProp/poison.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define void @casts() {
%i4 = fptoui float poison to i8
%i5 = fptosi float poison to i8
%i6 = bitcast float poison to i32
%i7 = ptrtoint i8* poison to i8
%i7 = ptrtoint ptr poison to i8
%f1 = fptrunc double poison to float
%f2 = fpext half poison to float
%f3 = uitofp i8 poison to float
Expand All @@ -25,12 +25,12 @@ define void @casts() {

define void @casts2() {
; CHECK-LABEL: @casts2(
; CHECK-NEXT: call void (...) @use(i8* poison, i8* poison)
; CHECK-NEXT: call void (...) @use(ptr poison, ptr poison)
; CHECK-NEXT: ret void
;
%p1 = inttoptr i8 poison to i8*
%p2 = addrspacecast i8 addrspace(1)* poison to i8*
call void (...) @use(i8* %p1, i8* %p2)
%p1 = inttoptr i8 poison to ptr
%p2 = addrspacecast ptr addrspace(1) poison to ptr
call void (...) @use(ptr %p1, ptr %p2)
ret void
}

Expand Down Expand Up @@ -104,14 +104,14 @@ define void @vec_aggr_ops() {

define void @other_ops(i8 %x) {
; CHECK-LABEL: @other_ops(
; CHECK-NEXT: call void (...) @use(i1 poison, i1 poison, i8 poison, i8 poison, i8* poison, i8* poison)
; CHECK-NEXT: call void (...) @use(i1 poison, i1 poison, i8 poison, i8 poison, ptr poison, ptr poison)
; CHECK-NEXT: ret void
;
%i1 = icmp eq i8 poison, 1
%i2 = fcmp oeq float poison, 1.0
%i3 = select i1 poison, i8 1, i8 2
%i4 = select i1 true, i8 poison, i8 %x
call void (...) @use(i1 %i1, i1 %i2, i8 %i3, i8 %i4, i8* getelementptr (i8, i8* poison, i64 1), i8* getelementptr inbounds (i8, i8* undef, i64 1))
call void (...) @use(i1 %i1, i1 %i2, i8 %i3, i8 %i4, ptr getelementptr (i8, ptr poison, i64 1), ptr getelementptr inbounds (i8, ptr undef, i64 1))
ret void
}

Expand Down
32 changes: 16 additions & 16 deletions llvm/test/Transforms/InstSimplify/ConstProp/shift.ll
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s

; CHECK-LABEL: shift_undef_64
define void @shift_undef_64(i64* %p) {
define void @shift_undef_64(ptr %p) {
%r1 = lshr i64 -1, 4294967296 ; 2^32
; CHECK: store i64 poison
store i64 %r1, i64* %p
store i64 %r1, ptr %p

%r2 = ashr i64 -1, 4294967297 ; 2^32 + 1
; CHECK: store i64 poison
store i64 %r2, i64* %p
store i64 %r2, ptr %p

%r3 = shl i64 -1, 4294967298 ; 2^32 + 2
; CHECK: store i64 poison
store i64 %r3, i64* %p
store i64 %r3, ptr %p

ret void
}

; CHECK-LABEL: shift_undef_65
define void @shift_undef_65(i65* %p) {
define void @shift_undef_65(ptr %p) {
%r1 = lshr i65 2, 18446744073709551617
; CHECK: store i65 poison
store i65 %r1, i65* %p
store i65 %r1, ptr %p

%r2 = ashr i65 4, 18446744073709551617
; CHECK: store i65 poison
store i65 %r2, i65* %p
store i65 %r2, ptr %p

%r3 = shl i65 1, 18446744073709551617
; CHECK: store i65 poison
store i65 %r3, i65* %p
store i65 %r3, ptr %p

ret void
}

; CHECK-LABEL: shift_undef_256
define void @shift_undef_256(i256* %p) {
define void @shift_undef_256(ptr %p) {
%r1 = lshr i256 2, 18446744073709551617
; CHECK: store i256 poison
store i256 %r1, i256* %p
store i256 %r1, ptr %p

%r2 = ashr i256 4, 18446744073709551618
; CHECK: store i256 poison
store i256 %r2, i256* %p
store i256 %r2, ptr %p

%r3 = shl i256 1, 18446744073709551619
; CHECK: store i256 poison
store i256 %r3, i256* %p
store i256 %r3, ptr %p

ret void
}

; CHECK-LABEL: shift_undef_511
define void @shift_undef_511(i511* %p) {
define void @shift_undef_511(ptr %p) {
%r1 = lshr i511 -1, 1208925819614629174706276 ; 2^80 + 100
; CHECK: store i511 poison
store i511 %r1, i511* %p
store i511 %r1, ptr %p

%r2 = ashr i511 -2, 1208925819614629174706200
; CHECK: store i511 poison
store i511 %r2, i511* %p
store i511 %r2, ptr %p

%r3 = shl i511 -3, 1208925819614629174706180
; CHECK: store i511 poison
store i511 %r3, i511* %p
store i511 %r3, ptr %p

ret void
}
60 changes: 30 additions & 30 deletions llvm/test/Transforms/InstSimplify/ConstProp/timeout.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv8-none-eabi"

%struct.ST = type { %struct.ST* }
%struct.ST = type { ptr }

@global = internal global [121 x i8] zeroinitializer, align 1

define void @func() #0 {
;CHECK-LABEL: func
entry:
%s = alloca %struct.ST*, align 4
%s = alloca ptr, align 4
%j = alloca i32, align 4
store %struct.ST* bitcast ([121 x i8]* @global to %struct.ST*), %struct.ST** %s, align 4
store i32 0, i32* %j, align 4
store ptr @global, ptr %s, align 4
store i32 0, ptr %j, align 4
br label %for.cond

for.cond: ; preds = %for.inc, %entry
%0 = load i32, i32* %j, align 4
%0 = load i32, ptr %j, align 4
%cmp = icmp slt i32 %0, 30
br i1 %cmp, label %for.body, label %for.end

for.body: ; preds = %for.cond
%1 = load %struct.ST*, %struct.ST** %s, align 4
%2 = bitcast %struct.ST* %1 to i8*
%add.ptr = getelementptr inbounds i8, i8* %2, i32 4
%3 = ptrtoint i8* %add.ptr to i32
%4 = load %struct.ST*, %struct.ST** %s, align 4
%5 = bitcast %struct.ST* %4 to i8*
%add.ptr1 = getelementptr inbounds i8, i8* %5, i32 4
%6 = ptrtoint i8* %add.ptr1 to i32
%1 = load ptr, ptr %s, align 4
%2 = bitcast ptr %1 to ptr
%add.ptr = getelementptr inbounds i8, ptr %2, i32 4
%3 = ptrtoint ptr %add.ptr to i32
%4 = load ptr, ptr %s, align 4
%5 = bitcast ptr %4 to ptr
%add.ptr1 = getelementptr inbounds i8, ptr %5, i32 4
%6 = ptrtoint ptr %add.ptr1 to i32
%rem = urem i32 %6, 2
%cmp2 = icmp eq i32 %rem, 0
br i1 %cmp2, label %cond.true, label %cond.false
Expand All @@ -38,36 +38,36 @@ cond.true: ; preds = %for.body
br label %cond.end

cond.false: ; preds = %for.body
%7 = load %struct.ST*, %struct.ST** %s, align 4
%8 = bitcast %struct.ST* %7 to i8*
%add.ptr3 = getelementptr inbounds i8, i8* %8, i32 4
%9 = ptrtoint i8* %add.ptr3 to i32
%7 = load ptr, ptr %s, align 4
%8 = bitcast ptr %7 to ptr
%add.ptr3 = getelementptr inbounds i8, ptr %8, i32 4
%9 = ptrtoint ptr %add.ptr3 to i32
%rem4 = urem i32 %9, 2
br label %cond.end

cond.end: ; preds = %cond.false, %cond.true
%cond = phi i32 [ 0, %cond.true ], [ %rem4, %cond.false ]
%add = add i32 %3, %cond
%10 = inttoptr i32 %add to %struct.ST*
%11 = load %struct.ST*, %struct.ST** %s, align 4
%next = getelementptr inbounds %struct.ST, %struct.ST* %11, i32 0, i32 0
store %struct.ST* %10, %struct.ST** %next, align 4
%12 = load %struct.ST*, %struct.ST** %s, align 4
%next5 = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 0
%13 = load %struct.ST*, %struct.ST** %next5, align 4
store %struct.ST* %13, %struct.ST** %s, align 4
%10 = inttoptr i32 %add to ptr
%11 = load ptr, ptr %s, align 4
%next = getelementptr inbounds %struct.ST, ptr %11, i32 0, i32 0
store ptr %10, ptr %next, align 4
%12 = load ptr, ptr %s, align 4
%next5 = getelementptr inbounds %struct.ST, ptr %12, i32 0, i32 0
%13 = load ptr, ptr %next5, align 4
store ptr %13, ptr %s, align 4
br label %for.inc

for.inc: ; preds = %cond.end
%14 = load i32, i32* %j, align 4
%14 = load i32, ptr %j, align 4
%inc = add nsw i32 %14, 1
store i32 %inc, i32* %j, align 4
store i32 %inc, ptr %j, align 4
br label %for.cond

for.end: ; preds = %for.cond
%15 = load %struct.ST*, %struct.ST** %s, align 4
%next6 = getelementptr inbounds %struct.ST, %struct.ST* %15, i32 0, i32 0
store %struct.ST* null, %struct.ST** %next6, align 4
%15 = load ptr, ptr %s, align 4
%next6 = getelementptr inbounds %struct.ST, ptr %15, i32 0, i32 0
store ptr null, ptr %next6, align 4
ret void
}

54 changes: 27 additions & 27 deletions llvm/test/Transforms/InstSimplify/ConstProp/vectorgep-crash.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,57 @@ target triple = "x86_64-unknown-linux-gnu"
%Partials.73 = type { [2 x %Dual.72] }

; Function Attrs: sspreq
define <8 x i64*> @"julia_axpy!_65480"(%Dual* %arg1, <8 x i64> %arg2) {
define <8 x ptr> @"julia_axpy!_65480"(ptr %arg1, <8 x i64> %arg2) {
top:
; CHECK: %VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
%VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
%0 = bitcast <8 x double*> %VectorGep14 to <8 x i64*>
ret <8 x i64*> %0
; CHECK: %VectorGep14 = getelementptr inbounds %Dual, ptr %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
%VectorGep14 = getelementptr inbounds %Dual, ptr %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
%0 = bitcast <8 x ptr> %VectorGep14 to <8 x ptr>
ret <8 x ptr> %0
}

%struct.A = type { i32, %struct.B* }
%struct.B = type { i64, %struct.C* }
%struct.A = type { i32, ptr }
%struct.B = type { i64, ptr }
%struct.C = type { i64 }

@G = internal global [65 x %struct.A] zeroinitializer, align 16
; CHECK-LABEL: @test
; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, i32 0)
define <16 x i32*> @test() {
; CHECK: ret <16 x ptr> getelementptr ([65 x %struct.A], ptr @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, i32 0)
define <16 x ptr> @test() {
vector.body:
%VectorGep = getelementptr [65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
ret <16 x i32*> %VectorGep
%VectorGep = getelementptr [65 x %struct.A], ptr @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
ret <16 x ptr> %VectorGep
}

; CHECK-LABEL: @test2
; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9,
define <16 x i32*> @test2() {
; CHECK: ret <16 x ptr> getelementptr ([65 x %struct.A], ptr @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9,
define <16 x ptr> @test2() {
vector.body:
%VectorGep = getelementptr [65 x %struct.A], [65 x %struct.A]* @G, <16 x i32> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
ret <16 x i32*> %VectorGep
%VectorGep = getelementptr [65 x %struct.A], ptr @G, <16 x i32> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
ret <16 x ptr> %VectorGep
}

@g = external global i8, align 1

define <2 x i8*> @constant_zero_index() {
define <2 x ptr> @constant_zero_index() {
; CHECK-LABEL: @constant_zero_index(
; CHECK-NEXT: ret <2 x i8*> <i8* @g, i8* @g>
; CHECK-NEXT: ret <2 x ptr> <ptr @g, ptr @g>
;
%gep = getelementptr i8, i8* @g, <2 x i64> zeroinitializer
ret <2 x i8*> %gep
%gep = getelementptr i8, ptr @g, <2 x i64> zeroinitializer
ret <2 x ptr> %gep
}

define <2 x i8*> @constant_undef_index() {
define <2 x ptr> @constant_undef_index() {
; CHECK-LABEL: @constant_undef_index(
; CHECK-NEXT: ret <2 x i8*> <i8* @g, i8* @g>
; CHECK-NEXT: ret <2 x ptr> <ptr @g, ptr @g>
;
%gep = getelementptr i8, i8* @g, <2 x i64> undef
ret <2 x i8*> %gep
%gep = getelementptr i8, ptr @g, <2 x i64> undef
ret <2 x ptr> %gep
}

define <2 x i8*> @constant_inbounds() {
define <2 x ptr> @constant_inbounds() {
; CHECK-LABEL: @constant_inbounds(
; CHECK-NEXT: ret <2 x i8*> getelementptr inbounds (i8, i8* @g, <2 x i64> <i64 1, i64 1>)
; CHECK-NEXT: ret <2 x ptr> getelementptr inbounds (i8, ptr @g, <2 x i64> <i64 1, i64 1>)
;
%gep = getelementptr i8, i8* @g, <2 x i64> <i64 1, i64 1>
ret <2 x i8*> %gep
%gep = getelementptr i8, ptr @g, <2 x i64> <i64 1, i64 1>
ret <2 x ptr> %gep
}
40 changes: 20 additions & 20 deletions llvm/test/Transforms/InstSimplify/ConstProp/vscale-getelementptr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"

; CHECK-LABEL: define <4 x i32*> @fixed_length_version_first() {
; CHECK-NEXT: ret <4 x i32*> undef
define <4 x i32*> @fixed_length_version_first() {
%ptr = getelementptr i32, <4 x i32*> undef, <4 x i64> undef
ret <4 x i32*> %ptr
; CHECK-LABEL: define <4 x ptr> @fixed_length_version_first() {
; CHECK-NEXT: ret <4 x ptr> undef
define <4 x ptr> @fixed_length_version_first() {
%ptr = getelementptr i32, <4 x ptr> undef, <4 x i64> undef
ret <4 x ptr> %ptr
}

; CHECK-LABEL: define <4 x <4 x i32>*> @fixed_length_version_second() {
; CHECK-NEXT: ret <4 x <4 x i32>*> undef
define <4 x <4 x i32>*> @fixed_length_version_second() {
%ptr = getelementptr <4 x i32>, <4 x i32>* undef, <4 x i64> undef
ret <4 x <4 x i32>*> %ptr
; CHECK-LABEL: define <4 x ptr> @fixed_length_version_second() {
; CHECK-NEXT: ret <4 x ptr> undef
define <4 x ptr> @fixed_length_version_second() {
%ptr = getelementptr <4 x i32>, ptr undef, <4 x i64> undef
ret <4 x ptr> %ptr
}

; CHECK-LABEL: define <vscale x 4 x i32*> @vscale_version_first() {
; CHECK-NEXT: ret <vscale x 4 x i32*> undef
define <vscale x 4 x i32*> @vscale_version_first() {
%ptr = getelementptr i32, <vscale x 4 x i32*> undef, <vscale x 4 x i64> undef
ret <vscale x 4 x i32*> %ptr
; CHECK-LABEL: define <vscale x 4 x ptr> @vscale_version_first() {
; CHECK-NEXT: ret <vscale x 4 x ptr> undef
define <vscale x 4 x ptr> @vscale_version_first() {
%ptr = getelementptr i32, <vscale x 4 x ptr> undef, <vscale x 4 x i64> undef
ret <vscale x 4 x ptr> %ptr
}

; CHECK-LABEL: define <vscale x 4 x <vscale x 4 x i32>*> @vscale_version_second() {
; CHECK-NEXT: ret <vscale x 4 x <vscale x 4 x i32>*> undef
define <vscale x 4 x <vscale x 4 x i32>*> @vscale_version_second() {
%ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* undef, <vscale x 4 x i64> undef
ret <vscale x 4 x <vscale x 4 x i32>*> %ptr
; CHECK-LABEL: define <vscale x 4 x ptr> @vscale_version_second() {
; CHECK-NEXT: ret <vscale x 4 x ptr> undef
define <vscale x 4 x ptr> @vscale_version_second() {
%ptr = getelementptr <vscale x 4 x i32>, ptr undef, <vscale x 4 x i64> undef
ret <vscale x 4 x ptr> %ptr
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ define <vscale x 4 x i32> @shufflevector() {

define <vscale x 2 x double> @load() {
; CHECK-LABEL: @load(
; CHECK-NEXT: [[R:%.*]] = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1), align 16
; CHECK-NEXT: [[R:%.*]] = load <vscale x 2 x double>, ptr getelementptr (<vscale x 2 x double>, ptr null, i64 1), align 16
; CHECK-NEXT: ret <vscale x 2 x double> [[R]]
;
%r = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
%r = load <vscale x 2 x double>, ptr getelementptr (<vscale x 2 x double>, ptr null, i64 1)
ret <vscale x 2 x double> %r
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ define <vscale x 4 x i32> @shufflevector() {

define <vscale x 2 x double> @load() {
; CHECK-LABEL: @load(
; CHECK-NEXT: [[R:%.*]] = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1), align 16
; CHECK-NEXT: [[R:%.*]] = load <vscale x 2 x double>, ptr getelementptr (<vscale x 2 x double>, ptr null, i64 1), align 16
; CHECK-NEXT: ret <vscale x 2 x double> [[R]]
;
%r = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
%r = load <vscale x 2 x double>, ptr getelementptr (<vscale x 2 x double>, ptr null, i64 1)
ret <vscale x 2 x double> %r
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstSimplify/add-mask.ll
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ declare void @llvm.assume(i1)
; Known bits without a constant
define i1 @test4(i32 %a) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: [[B:%.*]] = load i32, i32* @B, align 4
; CHECK-NEXT: [[B:%.*]] = load i32, ptr @B, align 4
; CHECK-NEXT: [[B_AND:%.*]] = and i32 [[B]], 1
; CHECK-NEXT: [[B_CND:%.*]] = icmp eq i32 [[B_AND]], 1
; CHECK-NEXT: call void @llvm.assume(i1 [[B_CND]])
; CHECK-NEXT: ret i1 false
;
%b = load i32, i32* @B
%b = load i32, ptr @B
%b.and = and i32 %b, 1
%b.cnd = icmp eq i32 %b.and, 1
call void @llvm.assume(i1 %b.cnd)
Expand Down
236 changes: 118 additions & 118 deletions llvm/test/Transforms/InstSimplify/and-or-icmp-nullptr.ll

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ define i1 @and_cmps_eq_zero_with_mask_commute4(i64 %x, i64 %y) {

; or (icmp eq (and (ptrtoint P), ?), 0), (icmp eq P, 0) --> icmp eq (and (ptrtoint P), ?), 0

define i1 @or_cmps_ptr_eq_zero_with_mask_commute1(i64* %p, i64 %y) {
define i1 @or_cmps_ptr_eq_zero_with_mask_commute1(ptr %p, i64 %y) {
; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute1(
; CHECK-NEXT: [[X:%.*]] = ptrtoint i64* [[P:%.*]] to i64
; CHECK-NEXT: [[X:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SOMEBITS:%.*]] = and i64 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[SOMEBITS_ARE_ZERO:%.*]] = icmp eq i64 [[SOMEBITS]], 0
; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_ZERO]]
;
%isnull = icmp eq i64* %p, null
%x = ptrtoint i64* %p to i64
%isnull = icmp eq ptr %p, null
%x = ptrtoint ptr %p to i64
%somebits = and i64 %x, %y
%somebits_are_zero = icmp eq i64 %somebits, 0
%r = or i1 %somebits_are_zero, %isnull
Expand All @@ -145,15 +145,15 @@ define i1 @or_cmps_ptr_eq_zero_with_mask_commute1(i64* %p, i64 %y) {

; or (icmp eq P, 0), (icmp eq (and (ptrtoint P), ?), 0) --> icmp eq (and (ptrtoint P), ?), 0

define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute2(<2 x i64*> %p, <2 x i64> %y) {
define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute2(<2 x ptr> %p, <2 x i64> %y) {
; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute2(
; CHECK-NEXT: [[X:%.*]] = ptrtoint <2 x i64*> [[P:%.*]] to <2 x i64>
; CHECK-NEXT: [[X:%.*]] = ptrtoint <2 x ptr> [[P:%.*]] to <2 x i64>
; CHECK-NEXT: [[SOMEBITS:%.*]] = and <2 x i64> [[X]], [[Y:%.*]]
; CHECK-NEXT: [[SOMEBITS_ARE_ZERO:%.*]] = icmp eq <2 x i64> [[SOMEBITS]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[SOMEBITS_ARE_ZERO]]
;
%isnull = icmp eq <2 x i64*> %p, zeroinitializer
%x = ptrtoint <2 x i64*> %p to <2 x i64>
%isnull = icmp eq <2 x ptr> %p, zeroinitializer
%x = ptrtoint <2 x ptr> %p to <2 x i64>
%somebits = and <2 x i64> %x, %y
%somebits_are_zero = icmp eq <2 x i64> %somebits, zeroinitializer
%r = or <2 x i1> %isnull, %somebits_are_zero
Expand All @@ -162,15 +162,15 @@ define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute2(<2 x i64*> %p, <2 x i64>

; or (icmp eq (and ?, (ptrtoint P)), 0), (icmp eq P, 0) --> icmp eq (and ?, (ptrtoint P)), 0

define i1 @or_cmps_ptr_eq_zero_with_mask_commute3(i4* %p, i4 %y) {
define i1 @or_cmps_ptr_eq_zero_with_mask_commute3(ptr %p, i4 %y) {
; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute3(
; CHECK-NEXT: [[X:%.*]] = ptrtoint i4* [[P:%.*]] to i4
; CHECK-NEXT: [[X:%.*]] = ptrtoint ptr [[P:%.*]] to i4
; CHECK-NEXT: [[SOMEBITS:%.*]] = and i4 [[Y:%.*]], [[X]]
; CHECK-NEXT: [[SOMEBITS_ARE_ZERO:%.*]] = icmp eq i4 [[SOMEBITS]], 0
; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_ZERO]]
;
%isnull = icmp eq i4* %p, null
%x = ptrtoint i4* %p to i4
%isnull = icmp eq ptr %p, null
%x = ptrtoint ptr %p to i4
%somebits = and i4 %y, %x
%somebits_are_zero = icmp eq i4 %somebits, 0
%r = or i1 %somebits_are_zero, %isnull
Expand All @@ -179,15 +179,15 @@ define i1 @or_cmps_ptr_eq_zero_with_mask_commute3(i4* %p, i4 %y) {

; or (icmp eq P, 0), (icmp eq (and ?, (ptrtoint P)), 0) --> icmp eq (and ?, (ptrtoint P)), 0

define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute4(<2 x i4*> %p, <2 x i4> %y) {
define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute4(<2 x ptr> %p, <2 x i4> %y) {
; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute4(
; CHECK-NEXT: [[X:%.*]] = ptrtoint <2 x i4*> [[P:%.*]] to <2 x i4>
; CHECK-NEXT: [[X:%.*]] = ptrtoint <2 x ptr> [[P:%.*]] to <2 x i4>
; CHECK-NEXT: [[SOMEBITS:%.*]] = and <2 x i4> [[Y:%.*]], [[X]]
; CHECK-NEXT: [[SOMEBITS_ARE_ZERO:%.*]] = icmp eq <2 x i4> [[SOMEBITS]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[SOMEBITS_ARE_ZERO]]
;
%isnull = icmp eq <2 x i4*> %p, zeroinitializer
%x = ptrtoint <2 x i4*> %p to <2 x i4>
%isnull = icmp eq <2 x ptr> %p, zeroinitializer
%x = ptrtoint <2 x ptr> %p to <2 x i4>
%somebits = and <2 x i4> %y, %x
%somebits_are_zero = icmp eq <2 x i4> %somebits, zeroinitializer
%r = or <2 x i1> %isnull, %somebits_are_zero
Expand All @@ -196,15 +196,15 @@ define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute4(<2 x i4*> %p, <2 x i4> %

; and (icmp ne (and (ptrtoint P), ?), 0), (icmp ne P, 0) --> icmp ne (and (ptrtoint P), ?), 0

define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute1(<3 x i4*> %p, <3 x i4> %y) {
define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute1(<3 x ptr> %p, <3 x i4> %y) {
; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute1(
; CHECK-NEXT: [[X:%.*]] = ptrtoint <3 x i4*> [[P:%.*]] to <3 x i4>
; CHECK-NEXT: [[X:%.*]] = ptrtoint <3 x ptr> [[P:%.*]] to <3 x i4>
; CHECK-NEXT: [[SOMEBITS:%.*]] = and <3 x i4> [[X]], [[Y:%.*]]
; CHECK-NEXT: [[SOMEBITS_ARE_NOT_ZERO:%.*]] = icmp ne <3 x i4> [[SOMEBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[SOMEBITS_ARE_NOT_ZERO]]
;
%isnotnull = icmp ne <3 x i4*> %p, zeroinitializer
%x = ptrtoint <3 x i4*> %p to <3 x i4>
%isnotnull = icmp ne <3 x ptr> %p, zeroinitializer
%x = ptrtoint <3 x ptr> %p to <3 x i4>
%somebits = and <3 x i4> %x, %y
%somebits_are_not_zero = icmp ne <3 x i4> %somebits, zeroinitializer
%r = and <3 x i1> %somebits_are_not_zero, %isnotnull
Expand All @@ -213,15 +213,15 @@ define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute1(<3 x i4*> %p, <3 x i4>

; and (icmp ne P, 0), (icmp ne (and (ptrtoint P), ?), 0) --> icmp ne (and (ptrtoint P), ?), 0

define i1 @and_cmps_ptr_eq_zero_with_mask_commute2(i4* %p, i4 %y) {
define i1 @and_cmps_ptr_eq_zero_with_mask_commute2(ptr %p, i4 %y) {
; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute2(
; CHECK-NEXT: [[X:%.*]] = ptrtoint i4* [[P:%.*]] to i4
; CHECK-NEXT: [[X:%.*]] = ptrtoint ptr [[P:%.*]] to i4
; CHECK-NEXT: [[SOMEBITS:%.*]] = and i4 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[SOMEBITS_ARE_NOT_ZERO:%.*]] = icmp ne i4 [[SOMEBITS]], 0
; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_NOT_ZERO]]
;
%isnotnull = icmp ne i4* %p, null
%x = ptrtoint i4* %p to i4
%isnotnull = icmp ne ptr %p, null
%x = ptrtoint ptr %p to i4
%somebits = and i4 %x, %y
%somebits_are_not_zero = icmp ne i4 %somebits, 0
%r = and i1 %isnotnull, %somebits_are_not_zero
Expand All @@ -230,15 +230,15 @@ define i1 @and_cmps_ptr_eq_zero_with_mask_commute2(i4* %p, i4 %y) {

; and (icmp ne (and ?, (ptrtoint P)), 0), (icmp ne P, 0) --> icmp ne (and ?, (ptrtoint P)), 0

define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute3(<3 x i64*> %p, <3 x i64> %y) {
define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute3(<3 x ptr> %p, <3 x i64> %y) {
; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute3(
; CHECK-NEXT: [[X:%.*]] = ptrtoint <3 x i64*> [[P:%.*]] to <3 x i64>
; CHECK-NEXT: [[X:%.*]] = ptrtoint <3 x ptr> [[P:%.*]] to <3 x i64>
; CHECK-NEXT: [[SOMEBITS:%.*]] = and <3 x i64> [[Y:%.*]], [[X]]
; CHECK-NEXT: [[SOMEBITS_ARE_NOT_ZERO:%.*]] = icmp ne <3 x i64> [[SOMEBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[SOMEBITS_ARE_NOT_ZERO]]
;
%isnotnull = icmp ne <3 x i64*> %p, zeroinitializer
%x = ptrtoint <3 x i64*> %p to <3 x i64>
%isnotnull = icmp ne <3 x ptr> %p, zeroinitializer
%x = ptrtoint <3 x ptr> %p to <3 x i64>
%somebits = and <3 x i64> %y, %x
%somebits_are_not_zero = icmp ne <3 x i64> %somebits, zeroinitializer
%r = and <3 x i1> %somebits_are_not_zero, %isnotnull
Expand All @@ -247,15 +247,15 @@ define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute3(<3 x i64*> %p, <3 x i64

; and (icmp ne P, 0), (icmp ne (and ?, (ptrtoint P)), 0) --> icmp ne (and ?, (ptrtoint P)), 0

define i1 @and_cmps_ptr_eq_zero_with_mask_commute4(i64* %p, i64 %y) {
define i1 @and_cmps_ptr_eq_zero_with_mask_commute4(ptr %p, i64 %y) {
; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute4(
; CHECK-NEXT: [[X:%.*]] = ptrtoint i64* [[P:%.*]] to i64
; CHECK-NEXT: [[X:%.*]] = ptrtoint ptr [[P:%.*]] to i64
; CHECK-NEXT: [[SOMEBITS:%.*]] = and i64 [[Y:%.*]], [[X]]
; CHECK-NEXT: [[SOMEBITS_ARE_NOT_ZERO:%.*]] = icmp ne i64 [[SOMEBITS]], 0
; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_NOT_ZERO]]
;
%isnotnull = icmp ne i64* %p, null
%x = ptrtoint i64* %p to i64
%isnotnull = icmp ne ptr %p, null
%x = ptrtoint ptr %p to i64
%somebits = and i64 %y, %x
%somebits_are_not_zero = icmp ne i64 %somebits, 0
%r = and i1 %isnotnull, %somebits_are_not_zero
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Transforms/InstSimplify/assume-non-zero.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ target triple = "x86_64-unknown-linux-gnu"

declare void @llvm.assume(i1) #1

define i1 @nonnull0_true(i8* %x) {
define i1 @nonnull0_true(ptr %x) {
; CHECK-LABEL: @nonnull0_true(
; CHECK-NEXT: [[A:%.*]] = icmp ne i8* [[X:%.*]], null
; CHECK-NEXT: [[A:%.*]] = icmp ne ptr [[X:%.*]], null
; CHECK-NEXT: call void @llvm.assume(i1 [[A]])
; CHECK-NEXT: ret i1 true
;
%a = icmp ne i8* %x, null
%a = icmp ne ptr %x, null
call void @llvm.assume(i1 %a)
%q = icmp ne i8* %x, null
%q = icmp ne ptr %x, null
ret i1 %q
}

define i1 @nonnull1_true(i8* %x) {
define i1 @nonnull1_true(ptr %x) {
; CHECK-LABEL: @nonnull1_true(
; CHECK-NEXT: [[INTPTR:%.*]] = ptrtoint i8* [[X:%.*]] to i64
; CHECK-NEXT: [[INTPTR:%.*]] = ptrtoint ptr [[X:%.*]] to i64
; CHECK-NEXT: [[A:%.*]] = icmp ne i64 [[INTPTR]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[A]])
; CHECK-NEXT: ret i1 true
;
%intptr = ptrtoint i8* %x to i64
%intptr = ptrtoint ptr %x to i64
%a = icmp ne i64 %intptr, 0
call void @llvm.assume(i1 %a)
%q = icmp ne i8* %x, null
%q = icmp ne ptr %x, null
ret i1 %q
}

Expand Down
104 changes: 52 additions & 52 deletions llvm/test/Transforms/InstSimplify/call.ll
Original file line number Diff line number Diff line change
Expand Up @@ -360,93 +360,93 @@ define float @test_idempotence(float %a) {
ret float %r5
}

define i8* @operator_new() {
define ptr @operator_new() {
; CHECK-LABEL: @operator_new(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @_Znwm(i64 8)
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias ptr @_Znwm(i64 8)
; CHECK-NEXT: br i1 false, label [[CAST_END:%.*]], label [[CAST_NOTNULL:%.*]]
; CHECK: cast.notnull:
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[CALL]], i64 4
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 4
; CHECK-NEXT: br label [[CAST_END]]
; CHECK: cast.end:
; CHECK-NEXT: [[CAST_RESULT:%.*]] = phi i8* [ [[ADD_PTR]], [[CAST_NOTNULL]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i8* [[CAST_RESULT]]
; CHECK-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], [[CAST_NOTNULL]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret ptr [[CAST_RESULT]]
;
entry:
%call = tail call noalias i8* @_Znwm(i64 8)
%cmp = icmp eq i8* %call, null
%call = tail call noalias ptr @_Znwm(i64 8)
%cmp = icmp eq ptr %call, null
br i1 %cmp, label %cast.end, label %cast.notnull

cast.notnull: ; preds = %entry
%add.ptr = getelementptr inbounds i8, i8* %call, i64 4
%add.ptr = getelementptr inbounds i8, ptr %call, i64 4
br label %cast.end

cast.end: ; preds = %cast.notnull, %entry
%cast.result = phi i8* [ %add.ptr, %cast.notnull ], [ null, %entry ]
ret i8* %cast.result
%cast.result = phi ptr [ %add.ptr, %cast.notnull ], [ null, %entry ]
ret ptr %cast.result

}

declare nonnull noalias i8* @_Znwm(i64)
declare nonnull noalias ptr @_Znwm(i64)

%"struct.std::nothrow_t" = type { i8 }
@_ZSt7nothrow = external global %"struct.std::nothrow_t"

define i8* @operator_new_nothrow_t() {
define ptr @operator_new_nothrow_t() {
; CHECK-LABEL: @operator_new_nothrow_t(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @_ZnamRKSt9nothrow_t(i64 8, %"struct.std::nothrow_t"* @_ZSt7nothrow)
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[CALL]], null
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias ptr @_ZnamRKSt9nothrow_t(i64 8, ptr @_ZSt7nothrow)
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[CALL]], null
; CHECK-NEXT: br i1 [[CMP]], label [[CAST_END:%.*]], label [[CAST_NOTNULL:%.*]]
; CHECK: cast.notnull:
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[CALL]], i64 4
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 4
; CHECK-NEXT: br label [[CAST_END]]
; CHECK: cast.end:
; CHECK-NEXT: [[CAST_RESULT:%.*]] = phi i8* [ [[ADD_PTR]], [[CAST_NOTNULL]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i8* [[CAST_RESULT]]
; CHECK-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], [[CAST_NOTNULL]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret ptr [[CAST_RESULT]]
;
entry:
%call = tail call noalias i8* @_ZnamRKSt9nothrow_t(i64 8, %"struct.std::nothrow_t"* @_ZSt7nothrow)
%cmp = icmp eq i8* %call, null
%call = tail call noalias ptr @_ZnamRKSt9nothrow_t(i64 8, ptr @_ZSt7nothrow)
%cmp = icmp eq ptr %call, null
br i1 %cmp, label %cast.end, label %cast.notnull

cast.notnull: ; preds = %entry
%add.ptr = getelementptr inbounds i8, i8* %call, i64 4
%add.ptr = getelementptr inbounds i8, ptr %call, i64 4
br label %cast.end

cast.end: ; preds = %cast.notnull, %entry
%cast.result = phi i8* [ %add.ptr, %cast.notnull ], [ null, %entry ]
ret i8* %cast.result
%cast.result = phi ptr [ %add.ptr, %cast.notnull ], [ null, %entry ]
ret ptr %cast.result

}

declare i8* @_ZnamRKSt9nothrow_t(i64, %"struct.std::nothrow_t"*) nounwind
declare ptr @_ZnamRKSt9nothrow_t(i64, ptr) nounwind

define i8* @malloc_can_return_null() {
define ptr @malloc_can_return_null() {
; CHECK-LABEL: @malloc_can_return_null(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @malloc(i64 8)
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[CALL]], null
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias ptr @malloc(i64 8)
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[CALL]], null
; CHECK-NEXT: br i1 [[CMP]], label [[CAST_END:%.*]], label [[CAST_NOTNULL:%.*]]
; CHECK: cast.notnull:
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[CALL]], i64 4
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 4
; CHECK-NEXT: br label [[CAST_END]]
; CHECK: cast.end:
; CHECK-NEXT: [[CAST_RESULT:%.*]] = phi i8* [ [[ADD_PTR]], [[CAST_NOTNULL]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i8* [[CAST_RESULT]]
; CHECK-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], [[CAST_NOTNULL]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret ptr [[CAST_RESULT]]
;
entry:
%call = tail call noalias i8* @malloc(i64 8)
%cmp = icmp eq i8* %call, null
%call = tail call noalias ptr @malloc(i64 8)
%cmp = icmp eq ptr %call, null
br i1 %cmp, label %cast.end, label %cast.notnull

cast.notnull: ; preds = %entry
%add.ptr = getelementptr inbounds i8, i8* %call, i64 4
%add.ptr = getelementptr inbounds i8, ptr %call, i64 4
br label %cast.end

cast.end: ; preds = %cast.notnull, %entry
%cast.result = phi i8* [ %add.ptr, %cast.notnull ], [ null, %entry ]
ret i8* %cast.result
%cast.result = phi ptr [ %add.ptr, %cast.notnull ], [ null, %entry ]
ret ptr %cast.result

}

Expand Down Expand Up @@ -478,21 +478,21 @@ define <8 x i32> @partial_masked_load() {
; CHECK-LABEL: @partial_masked_load(
; CHECK-NEXT: ret <8 x i32> <i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47>
;
%masked.load = call <8 x i32> @llvm.masked.load.v8i32.p0v8i32(<8 x i32>* bitcast (i32* getelementptr ([8 x i32], [8 x i32]* @GV, i64 0, i64 -2) to <8 x i32>*), i32 4, <8 x i1> <i1 false, i1 false, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef)
%masked.load = call <8 x i32> @llvm.masked.load.v8i32.p0(ptr getelementptr ([8 x i32], ptr @GV, i64 0, i64 -2), i32 4, <8 x i1> <i1 false, i1 false, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef)
ret <8 x i32> %masked.load
}

define <8 x i32> @masked_load_undef_mask(<8 x i32>* %V) {
define <8 x i32> @masked_load_undef_mask(ptr %V) {
; CHECK-LABEL: @masked_load_undef_mask(
; CHECK-NEXT: ret <8 x i32> <i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0>
;
%masked.load = call <8 x i32> @llvm.masked.load.v8i32.p0v8i32(<8 x i32>* %V, i32 4, <8 x i1> undef, <8 x i32> <i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0>)
%masked.load = call <8 x i32> @llvm.masked.load.v8i32.p0(ptr %V, i32 4, <8 x i1> undef, <8 x i32> <i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0>)
ret <8 x i32> %masked.load
}

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

declare <8 x i32> @llvm.masked.load.v8i32.p0v8i32(<8 x i32>*, i32, <8 x i1>, <8 x i32>)
declare <8 x i32> @llvm.masked.load.v8i32.p0(ptr, i32, <8 x i1>, <8 x i32>)

declare double @llvm.powi.f64.i16(double, i16)
declare <2 x double> @llvm.powi.v2f64.i16(<2 x double>, i16)
Expand Down Expand Up @@ -1311,7 +1311,7 @@ define <2 x double> @negated_mag_arg_vec(<2 x double> %x) {
; for call graph passes.

declare i32 @passthru_i32(i32 returned)
declare i8* @passthru_p8(i8* returned)
declare ptr @passthru_p8(ptr returned)

define i32 @returned_const_int_arg() {
; CHECK-LABEL: @returned_const_int_arg(
Expand All @@ -1322,13 +1322,13 @@ define i32 @returned_const_int_arg() {
ret i32 %x
}

define i8* @returned_const_ptr_arg() {
define ptr @returned_const_ptr_arg() {
; CHECK-LABEL: @returned_const_ptr_arg(
; CHECK-NEXT: [[X:%.*]] = call i8* @passthru_p8(i8* null)
; CHECK-NEXT: ret i8* [[X]]
; CHECK-NEXT: [[X:%.*]] = call ptr @passthru_p8(ptr null)
; CHECK-NEXT: ret ptr [[X]]
;
%x = call i8* @passthru_p8(i8* null)
ret i8* %x
%x = call ptr @passthru_p8(ptr null)
ret ptr %x
}

define i32 @returned_var_arg(i32 %arg) {
Expand Down Expand Up @@ -1546,18 +1546,18 @@ define <3 x i33> @ctlz_ashr_sign_bit_vec(<3 x i33> %x) {
ret <3 x i33> %r
}

declare i8* @llvm.ptrmask.p0i8.i64(i8* , i64)
declare ptr @llvm.ptrmask.p0.i64(ptr , i64)

define i1 @capture_vs_recurse(i64 %mask) {
; CHECK-LABEL: @capture_vs_recurse(
; CHECK-NEXT: [[A:%.*]] = call noalias i8* @malloc(i64 8)
; CHECK-NEXT: [[B:%.*]] = call nonnull i8* @llvm.ptrmask.p0i8.i64(i8* [[A]], i64 [[MASK:%.*]])
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8* [[A]], [[B]]
; CHECK-NEXT: [[A:%.*]] = call noalias ptr @malloc(i64 8)
; CHECK-NEXT: [[B:%.*]] = call nonnull ptr @llvm.ptrmask.p0.i64(ptr [[A]], i64 [[MASK:%.*]])
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[A]], [[B]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%a = call noalias i8* @malloc(i64 8)
%b = call nonnull i8* @llvm.ptrmask.p0i8.i64(i8* %a, i64 %mask)
%cmp = icmp eq i8* %a, %b
%a = call noalias ptr @malloc(i64 8)
%b = call nonnull ptr @llvm.ptrmask.p0.i64(ptr %a, i64 %mask)
%cmp = icmp eq ptr %a, %b
ret i1 %cmp
}

Expand Down
33 changes: 14 additions & 19 deletions llvm/test/Transforms/InstSimplify/cast.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,34 @@ entry:
ret i1 %T
}

define i8* @test2(i8* %V) {
define ptr @test2(ptr %V) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i8* [[V:%.*]]
; CHECK-NEXT: ret ptr [[V:%.*]]
;
entry:
%BC1 = bitcast i8* %V to i32*
%BC2 = bitcast i32* %BC1 to i8*
ret i8* %BC2
ret ptr %V
}

define i8* @test3(i8* %V) {
define ptr @test3(ptr %V) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i8* [[V:%.*]]
; CHECK-NEXT: ret ptr [[V:%.*]]
;
entry:
%BC = bitcast i8* %V to i8*
ret i8* %BC
ret ptr %V
}

define i32 @test4() {
; CHECK-LABEL: @test4(
; CHECK-NEXT: ret i32 4
;
%alloca = alloca i32, align 4 ; alloca + 0
%gep = getelementptr inbounds i32, i32* %alloca, i32 1 ; alloca + 4
%bc = bitcast i32* %gep to [4 x i8]* ; alloca + 4
%pti = ptrtoint i32* %alloca to i32 ; alloca
%gep = getelementptr inbounds i32, ptr %alloca, i32 1 ; alloca + 4
%pti = ptrtoint ptr %alloca to i32 ; alloca
%sub = sub i32 0, %pti ; -alloca
%add = getelementptr [4 x i8], [4 x i8]* %bc, i32 0, i32 %sub ; alloca + 4 - alloca == 4
%add_to_int = ptrtoint i8* %add to i32 ; 4
%add = getelementptr [4 x i8], ptr %gep, i32 0, i32 %sub ; alloca + 4 - alloca == 4
%add_to_int = ptrtoint ptr %add to i32 ; 4
ret i32 %add_to_int ; 4
}

Expand All @@ -53,11 +49,10 @@ define i32 @test5() {
; CHECK-NEXT: ret i32 3
;
%alloca = alloca i32, align 4 ; alloca + 0
%gep = getelementptr inbounds i32, i32* %alloca, i32 1 ; alloca + 4
%bc = bitcast i32* %gep to [4 x i8]* ; alloca + 4
%pti = ptrtoint i32* %alloca to i32 ; alloca
%gep = getelementptr inbounds i32, ptr %alloca, i32 1 ; alloca + 4
%pti = ptrtoint ptr %alloca to i32 ; alloca
%sub = xor i32 %pti, -1 ; ~alloca
%add = getelementptr [4 x i8], [4 x i8]* %bc, i32 0, i32 %sub ; alloca + 4 - alloca - 1 == 3
%add_to_int = ptrtoint i8* %add to i32 ; 4
%add = getelementptr [4 x i8], ptr %gep, i32 0, i32 %sub ; alloca + 4 - alloca - 1 == 3
%add_to_int = ptrtoint ptr %add to i32 ; 4
ret i32 %add_to_int ; 4
}
120 changes: 59 additions & 61 deletions llvm/test/Transforms/InstSimplify/cmp-alloca-offsets.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ define i1 @adjacent_alloca() {
; CHECK-LABEL: @adjacent_alloca(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 4
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A]], [[B_OFF]]
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 4
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 0
%b.off = getelementptr i8, i8* %b, i64 4
%res = icmp ne i8* %a.off, %b.off
%b.off = getelementptr i8, ptr %b, i64 4
%res = icmp ne ptr %a, %b.off
ret i1 %res
}

Expand All @@ -30,15 +29,14 @@ define i1 @adjacent_alloca2() {
; CHECK-LABEL: @adjacent_alloca2(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 4
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 4
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 4
%b.off = getelementptr i8, i8* %b, i64 0
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 4
%res = icmp ne ptr %a.off, %b
ret i1 %res
}

Expand All @@ -47,16 +45,16 @@ define i1 @positive_non_equal_end() {
; CHECK-LABEL: @positive_non_equal_end(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 4
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 4
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 4
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 4
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 4
%b.off = getelementptr i8, i8* %b, i64 4
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 4
%b.off = getelementptr i8, ptr %b, i64 4
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -65,16 +63,16 @@ define i1 @positive_equal_past_end() {
; CHECK-LABEL: @positive_equal_past_end(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 8
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 12
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 8
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 12
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 8
%b.off = getelementptr i8, i8* %b, i64 12
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 8
%b.off = getelementptr i8, ptr %b, i64 12
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -84,9 +82,9 @@ define i1 @positive_non_equal() {
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 3
%b.off = getelementptr i8, i8* %b, i64 3
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 3
%b.off = getelementptr i8, ptr %b, i64 3
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -95,16 +93,16 @@ define i1 @one_neg_equal1() {
; CHECK-LABEL: @one_neg_equal1(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 -1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 3
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 -1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 3
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 -1
%b.off = getelementptr i8, i8* %b, i64 3
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 -1
%b.off = getelementptr i8, ptr %b, i64 3
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -113,16 +111,16 @@ define i1 @one_neg_equal2() {
; CHECK-LABEL: @one_neg_equal2(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 3
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 -1
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 3
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 -1
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 3
%b.off = getelementptr i8, i8* %b, i64 -1
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 3
%b.off = getelementptr i8, ptr %b, i64 -1
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -131,16 +129,16 @@ define i1 @both_neg_equal() {
; CHECK-LABEL: @both_neg_equal(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 -4
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 -8
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 -4
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 -8
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 -4
%b.off = getelementptr i8, i8* %b, i64 -8
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 -4
%b.off = getelementptr i8, ptr %b, i64 -8
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -149,16 +147,16 @@ define i1 @mixed_offsets1() {
; CHECK-LABEL: @mixed_offsets1(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 -1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 2
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 -1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 2
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 -1
%b.off = getelementptr i8, i8* %b, i64 2
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 -1
%b.off = getelementptr i8, ptr %b, i64 2
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -167,16 +165,16 @@ define i1 @mixed_offsets2() {
; CHECK-LABEL: @mixed_offsets2(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 -2
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 1
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 -2
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 1
%b.off = getelementptr i8, i8* %b, i64 -2
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 1
%b.off = getelementptr i8, ptr %b, i64 -2
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand All @@ -185,16 +183,16 @@ define i1 @negative_in_other() {
; CHECK-LABEL: @negative_in_other(
; CHECK-NEXT: [[A:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[B:%.*]] = alloca i8, i32 4, align 1
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, i8* [[A]], i64 -3
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, i8* [[B]], i64 -2
; CHECK-NEXT: [[RES:%.*]] = icmp ne i8* [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: [[A_OFF:%.*]] = getelementptr i8, ptr [[A]], i64 -3
; CHECK-NEXT: [[B_OFF:%.*]] = getelementptr i8, ptr [[B]], i64 -2
; CHECK-NEXT: [[RES:%.*]] = icmp ne ptr [[A_OFF]], [[B_OFF]]
; CHECK-NEXT: ret i1 [[RES]]
;
%a = alloca i8, i32 4
%b = alloca i8, i32 4
%a.off = getelementptr i8, i8* %a, i64 -3
%b.off = getelementptr i8, i8* %b, i64 -2
%res = icmp ne i8* %a.off, %b.off
%a.off = getelementptr i8, ptr %a, i64 -3
%b.off = getelementptr i8, ptr %b, i64 -2
%res = icmp ne ptr %a.off, %b.off
ret i1 %res
}

Expand Down
Loading