diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-01-13 15:44:44 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-01-13 15:44:44 +0000 |
| commit | 4158eff0f84781e5449961b5544a2eb441f8a26e (patch) | |
| tree | 44b176cb6fb82f1042b7f2293861541fc6c14dfd /llvm/test | |
| parent | fda9daeb032b12d97cd96ca9863ebbd036c0d159 (diff) | |
| download | bcm5719-llvm-4158eff0f84781e5449961b5544a2eb441f8a26e.tar.gz bcm5719-llvm-4158eff0f84781e5449961b5544a2eb441f8a26e.zip | |
[InstSimplify] fold implied null ptr check (PR35790)
This extends rL322327 to handle the pointer cast and should solve:
https://bugs.llvm.org/show_bug.cgi?id=35790
Name: or_eq_zero
%isnull = icmp eq i64* %p, null
%x = ptrtoint i64* %p to i64
%somebits = and i64 %x, %y
%somebits_are_zero = icmp eq i64 %somebits, 0
%or = or i1 %somebits_are_zero, %isnull
=>
%or = %somebits_are_zero
Name: and_ne_zero
%isnotnull = icmp ne i64* %p, null
%x = ptrtoint i64* %p to i64
%somebits = and i64 %x, %y
%somebits_are_not_zero = icmp ne i64 %somebits, 0
%and = and i1 %somebits_are_not_zero, %isnotnull
=>
%and = %somebits_are_not_zero
https://rise4fun.com/Alive/CQ3
llvm-svn: 322439
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll b/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll index 30915214889..04bf5ace36a 100644 --- a/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll +++ b/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll @@ -129,12 +129,10 @@ define i1 @and_cmps_eq_zero_with_mask_commute4(i64 %x, i64 %y) { define i1 @or_cmps_ptr_eq_zero_with_mask_commute1(i64* %p, i64 %y) { ; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute1( -; CHECK-NEXT: [[ISNULL:%.*]] = icmp eq i64* %p, null ; CHECK-NEXT: [[X:%.*]] = ptrtoint i64* %p to i64 ; CHECK-NEXT: [[SOMEBITS:%.*]] = and i64 [[X]], %y ; CHECK-NEXT: [[SOMEBITS_ARE_ZERO:%.*]] = icmp eq i64 [[SOMEBITS]], 0 -; CHECK-NEXT: [[R:%.*]] = or i1 [[SOMEBITS_ARE_ZERO]], [[ISNULL]] -; CHECK-NEXT: ret i1 [[R]] +; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_ZERO]] ; %isnull = icmp eq i64* %p, null %x = ptrtoint i64* %p to i64 @@ -148,12 +146,10 @@ define i1 @or_cmps_ptr_eq_zero_with_mask_commute1(i64* %p, i64 %y) { define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute2(<2 x i64*> %p, <2 x i64> %y) { ; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute2( -; CHECK-NEXT: [[ISNULL:%.*]] = icmp eq <2 x i64*> %p, zeroinitializer ; CHECK-NEXT: [[X:%.*]] = ptrtoint <2 x i64*> %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: [[R:%.*]] = or <2 x i1> [[ISNULL]], [[SOMEBITS_ARE_ZERO]] -; CHECK-NEXT: ret <2 x i1> [[R]] +; 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> @@ -167,12 +163,10 @@ define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute2(<2 x i64*> %p, <2 x i64> define i1 @or_cmps_ptr_eq_zero_with_mask_commute3(i4* %p, i4 %y) { ; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute3( -; CHECK-NEXT: [[ISNULL:%.*]] = icmp eq i4* %p, null ; CHECK-NEXT: [[X:%.*]] = ptrtoint i4* %p to i4 ; CHECK-NEXT: [[SOMEBITS:%.*]] = and i4 %y, [[X]] ; CHECK-NEXT: [[SOMEBITS_ARE_ZERO:%.*]] = icmp eq i4 [[SOMEBITS]], 0 -; CHECK-NEXT: [[R:%.*]] = or i1 [[SOMEBITS_ARE_ZERO]], [[ISNULL]] -; CHECK-NEXT: ret i1 [[R]] +; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_ZERO]] ; %isnull = icmp eq i4* %p, null %x = ptrtoint i4* %p to i4 @@ -186,12 +180,10 @@ define i1 @or_cmps_ptr_eq_zero_with_mask_commute3(i4* %p, i4 %y) { define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute4(<2 x i4*> %p, <2 x i4> %y) { ; CHECK-LABEL: @or_cmps_ptr_eq_zero_with_mask_commute4( -; CHECK-NEXT: [[ISNULL:%.*]] = icmp eq <2 x i4*> %p, zeroinitializer ; CHECK-NEXT: [[X:%.*]] = ptrtoint <2 x i4*> %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: [[R:%.*]] = or <2 x i1> [[ISNULL]], [[SOMEBITS_ARE_ZERO]] -; CHECK-NEXT: ret <2 x i1> [[R]] +; 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> @@ -205,12 +197,10 @@ define <2 x i1> @or_cmps_ptr_eq_zero_with_mask_commute4(<2 x i4*> %p, <2 x i4> % define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute1(<3 x i4*> %p, <3 x i4> %y) { ; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute1( -; CHECK-NEXT: [[ISNOTNULL:%.*]] = icmp ne <3 x i4*> %p, zeroinitializer ; CHECK-NEXT: [[X:%.*]] = ptrtoint <3 x i4*> %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: [[R:%.*]] = and <3 x i1> [[SOMEBITS_ARE_NOT_ZERO]], [[ISNOTNULL]] -; CHECK-NEXT: ret <3 x i1> [[R]] +; 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> @@ -224,12 +214,10 @@ define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute1(<3 x i4*> %p, <3 x i4> define i1 @and_cmps_ptr_eq_zero_with_mask_commute2(i4* %p, i4 %y) { ; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute2( -; CHECK-NEXT: [[ISNOTNULL:%.*]] = icmp ne i4* %p, null ; CHECK-NEXT: [[X:%.*]] = ptrtoint i4* %p to i4 ; CHECK-NEXT: [[SOMEBITS:%.*]] = and i4 [[X]], %y ; CHECK-NEXT: [[SOMEBITS_ARE_NOT_ZERO:%.*]] = icmp ne i4 [[SOMEBITS]], 0 -; CHECK-NEXT: [[R:%.*]] = and i1 [[ISNOTNULL]], [[SOMEBITS_ARE_NOT_ZERO]] -; CHECK-NEXT: ret i1 [[R]] +; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_NOT_ZERO]] ; %isnotnull = icmp ne i4* %p, null %x = ptrtoint i4* %p to i4 @@ -243,12 +231,10 @@ define i1 @and_cmps_ptr_eq_zero_with_mask_commute2(i4* %p, i4 %y) { define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute3(<3 x i64*> %p, <3 x i64> %y) { ; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute3( -; CHECK-NEXT: [[ISNOTNULL:%.*]] = icmp ne <3 x i64*> %p, zeroinitializer ; CHECK-NEXT: [[X:%.*]] = ptrtoint <3 x i64*> %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: [[R:%.*]] = and <3 x i1> [[SOMEBITS_ARE_NOT_ZERO]], [[ISNOTNULL]] -; CHECK-NEXT: ret <3 x i1> [[R]] +; 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> @@ -262,12 +248,10 @@ define <3 x i1> @and_cmps_ptr_eq_zero_with_mask_commute3(<3 x i64*> %p, <3 x i64 define i1 @and_cmps_ptr_eq_zero_with_mask_commute4(i64* %p, i64 %y) { ; CHECK-LABEL: @and_cmps_ptr_eq_zero_with_mask_commute4( -; CHECK-NEXT: [[ISNOTNULL:%.*]] = icmp ne i64* %p, null ; CHECK-NEXT: [[X:%.*]] = ptrtoint i64* %p to i64 ; CHECK-NEXT: [[SOMEBITS:%.*]] = and i64 %y, [[X]] ; CHECK-NEXT: [[SOMEBITS_ARE_NOT_ZERO:%.*]] = icmp ne i64 [[SOMEBITS]], 0 -; CHECK-NEXT: [[R:%.*]] = and i1 [[ISNOTNULL]], [[SOMEBITS_ARE_NOT_ZERO]] -; CHECK-NEXT: ret i1 [[R]] +; CHECK-NEXT: ret i1 [[SOMEBITS_ARE_NOT_ZERO]] ; %isnotnull = icmp ne i64* %p, null %x = ptrtoint i64* %p to i64 |

