[PATCH] D9397: llvm.noalias - computeKnownBits should look through them
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 10 19:32:27 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275036: Teach computeKnownBits to look through returned-argument functions (authored by hfinkel).
Changed prior to commit:
http://reviews.llvm.org/D9397?vs=63344&id=63450#toc
Repository:
rL LLVM
http://reviews.llvm.org/D9397
Files:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstCombine/align-attr.ll
Index: llvm/trunk/test/Transforms/InstCombine/align-attr.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/align-attr.ll
+++ llvm/trunk/test/Transforms/InstCombine/align-attr.ll
@@ -13,3 +13,16 @@
; CHECK: ret i32
}
+define i32 @foo2(i32* align 32 %a) #0 {
+entry:
+ %v = call i32* @func1(i32* %a)
+ %0 = load i32, i32* %v, align 4
+ ret i32 %0
+
+; CHECK-LABEL: @foo2
+; CHECK-DAG: load i32, i32* %v, align 32
+; CHECK: ret i32
+}
+
+declare i32* @func1(i32* returned) nounwind
+
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -1279,11 +1279,16 @@
}
case Instruction::Call:
case Instruction::Invoke:
+ // If range metadata is attached to this call, set known bits from that,
+ // and then intersect with known bits based on other properties of the
+ // function.
if (MDNode *MD = cast<Instruction>(I)->getMetadata(LLVMContext::MD_range))
computeKnownBitsFromRangeMetadata(*MD, KnownZero, KnownOne);
- // If a range metadata is attached to this IntrinsicInst, intersect the
- // explicit range specified by the metadata and the implicit range of
- // the intrinsic.
+ if (Value *RV = CallSite(I).getReturnedArgOperand()) {
+ computeKnownBits(RV, KnownZero2, KnownOne2, Depth + 1, Q);
+ KnownZero |= KnownZero2;
+ KnownOne |= KnownOne2;
+ }
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
switch (II->getIntrinsicID()) {
default: break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9397.63450.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160711/f6be2fac/attachment.bin>
More information about the llvm-commits
mailing list