[PATCH] D9387: llvm.noalias - Pointer comparison folding should look through them
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 15:58:48 PDT 2016
hfinkel updated this revision to Diff 63345.
hfinkel added a comment.
Herald added a subscriber: mcrosier.
Rebased.
http://reviews.llvm.org/D9387
Files:
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/noalias.ll
Index: test/Transforms/InstSimplify/noalias.ll
===================================================================
--- test/Transforms/InstSimplify/noalias.ll
+++ test/Transforms/InstSimplify/noalias.ll
@@ -18,7 +18,33 @@
; CHECK: ret i8* undef
}
+define i1 @bitcast() {
+; CHECK-LABEL: @bitcast(
+ %a = alloca i32
+ %b = alloca i64
+ %x = bitcast i32* %a to i8*
+ %z = bitcast i64* %b to i8*
+ %y = call i8* @llvm.noalias.p0i8(i8* %z, metadata !1)
+ %cmp = icmp eq i8* %x, %y
+ ret i1 %cmp
+; CHECK-NEXT: ret i1 false
+}
+
+%gept = type { i32, i32 }
+
+define i1 @gep3() {
+; CHECK-LABEL: @gep3(
+ %x = alloca %gept, align 8
+ %a = getelementptr %gept, %gept* %x, i64 0, i32 0
+ %y = call %gept* @llvm.noalias.p0gept(%gept* %x, metadata !1)
+ %b = getelementptr %gept, %gept* %y, i64 0, i32 1
+ %equal = icmp eq i32* %a, %b
+ ret i1 %equal
+; CHECK-NEXT: ret i1 false
+}
+
declare i8* @llvm.noalias.p0i8(i8*, metadata) nounwind
+declare %gept* @llvm.noalias.p0gept(%gept*, metadata) nounwind
!0 = !{!0, !"some domain"}
!1 = !{!1, !0, !"some scope"}
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -621,6 +621,12 @@
break;
V = GA->getAliasee();
} else {
+ if (IntrinsicInst *I = dyn_cast<IntrinsicInst>(V))
+ if (I->getIntrinsicID() == Intrinsic::noalias) {
+ V = I->getOperand(0);
+ continue;
+ }
+
break;
}
assert(V->getType()->getScalarType()->isPointerTy() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9387.63345.patch
Type: text/x-patch
Size: 1610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160708/00d5a7c8/attachment.bin>
More information about the llvm-commits
mailing list