[PATCH] D26803: Fix known zero bits for addrspacecast
Yaxun Liu via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 21 07:52:29 PST 2016
This revision was automatically updated to reflect the committed changes.
yaxunl marked 2 inline comments as done.
Closed by commit rL287545: Fix known zero bits for addrspacecast. (authored by yaxunl).
Changed prior to commit:
https://reviews.llvm.org/D26803?vs=78404&id=78720#toc
Repository:
rL LLVM
https://reviews.llvm.org/D26803
Files:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Analysis/ValueTracking/knownzero-addrspacecast.ll
llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll
Index: llvm/trunk/test/Analysis/ValueTracking/knownzero-addrspacecast.ll
===================================================================
--- llvm/trunk/test/Analysis/ValueTracking/knownzero-addrspacecast.ll
+++ llvm/trunk/test/Analysis/ValueTracking/knownzero-addrspacecast.ll
@@ -0,0 +1,24 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+; When a pointer is addrspacecasted to a another addr space, we cannot assume
+; anything about the new bits.
+
+target datalayout = "p:32:32-p3:32:32-p4:64:64"
+
+; CHECK-LABEL: @test_shift
+; CHECK-NOT: ret i64 0
+define i64 @test_shift(i8* %p) {
+ %g = addrspacecast i8* %p to i8 addrspace(4)*
+ %i = ptrtoint i8 addrspace(4)* %g to i64
+ %shift = lshr i64 %i, 32
+ ret i64 %shift
+}
+
+; CHECK-LABEL: @test_null
+; A null pointer casted to another addr space may no longer have null value.
+; CHECK-NOT: ret i32 0
+define i32 @test_null() {
+ %g = addrspacecast i8* null to i8 addrspace(3)*
+ %i = ptrtoint i8 addrspace(3)* %g to i32
+ ret i32 %i
+}
Index: llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll
+++ llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll
@@ -14,33 +14,6 @@
ret <2 x i64> %tmp1
}
-; CHECK-LABEL: @static_hem_addrspacecast(
-; CHECK: , align 16
-define <2 x i64> @static_hem_addrspacecast() {
- %t = getelementptr <2 x i64>, <2 x i64>* @x, i32 7
- %t.asc = addrspacecast <2 x i64>* %t to <2 x i64> addrspace(1)*
- %tmp1 = load <2 x i64>, <2 x i64> addrspace(1)* %t.asc, align 1
- ret <2 x i64> %tmp1
-}
-
-; CHECK-LABEL: @static_hem_addrspacecast_smaller_ptr(
-; CHECK: , align 16
-define <2 x i64> @static_hem_addrspacecast_smaller_ptr() {
- %t = getelementptr <2 x i64>, <2 x i64>* @x, i32 7
- %t.asc = addrspacecast <2 x i64>* %t to <2 x i64> addrspace(2)*
- %tmp1 = load <2 x i64>, <2 x i64> addrspace(2)* %t.asc, align 1
- ret <2 x i64> %tmp1
-}
-
-; CHECK-LABEL: @static_hem_addrspacecast_larger_ptr(
-; CHECK: , align 16
-define <2 x i64> @static_hem_addrspacecast_larger_ptr() {
- %t = getelementptr <2 x i64>, <2 x i64> addrspace(2)* @x.as2, i32 7
- %t.asc = addrspacecast <2 x i64> addrspace(2)* %t to <2 x i64> addrspace(1)*
- %tmp1 = load <2 x i64>, <2 x i64> addrspace(1)* %t.asc, align 1
- ret <2 x i64> %tmp1
-}
-
; CHECK-LABEL: @hem(
; CHECK: , align 16
define <2 x i64> @hem(i32 %i) {
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -1025,7 +1025,6 @@
break; // Can't work with floating point.
case Instruction::PtrToInt:
case Instruction::IntToPtr:
- case Instruction::AddrSpaceCast: // Pointers could be different sizes.
// Fall through and handle them the same as zext/trunc.
LLVM_FALLTHROUGH;
case Instruction::ZExt:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26803.78720.patch
Type: text/x-patch
Size: 2987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161121/a6695270/attachment.bin>
More information about the llvm-commits
mailing list