summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-01-17 14:39:28 +0000
committerSanjay Patel <spatel@rotateright.com>2018-01-17 14:39:28 +0000
commitaa766efd09f759758686b31571ca50ad59c62ca4 (patch)
treeee6994775dd552d7812595af8837f4f4e948539b
parent10d95c53af3d30cd362ab798c51cdaaaac325c89 (diff)
downloadbcm5719-llvm-aa766efd09f759758686b31571ca50ad59c62ca4.tar.gz
bcm5719-llvm-aa766efd09f759758686b31571ca50ad59c62ca4.zip
[InstCombine] fix demanded-bits propagation for zext/trunc
I was comparing the demanded-bits implementations between InstCombine and TargetLowering as part of investigating questions in D42088 and noticed that this was wrong in IR. We were losing all of the prior known bits when we got back to the 'zext'. llvm-svn: 322662
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/and.ll4
2 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index a2e757cb427..73746bfda44 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -333,7 +333,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
KnownBits InputKnown(SrcBitWidth);
if (SimplifyDemandedBits(I, 0, InputDemandedMask, InputKnown, Depth + 1))
return I;
- Known = Known.zextOrTrunc(BitWidth);
+ Known = InputKnown.zextOrTrunc(BitWidth);
// Any top bits are known to be zero.
if (BitWidth > SrcBitWidth)
Known.Zero.setBitsFrom(SrcBitWidth);
diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll
index f5ee4022ce8..4925013b195 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -376,9 +376,7 @@ define i32 @and_zext_demanded(i16 %x, i32 %y) {
; CHECK-LABEL: @and_zext_demanded(
; CHECK-NEXT: [[S:%.*]] = lshr i16 %x, 8
; CHECK-NEXT: [[Z:%.*]] = zext i16 [[S]] to i32
-; CHECK-NEXT: [[O:%.*]] = or i32 %y, 255
-; CHECK-NEXT: [[A:%.*]] = and i32 [[O]], [[Z]]
-; CHECK-NEXT: ret i32 [[A]]
+; CHECK-NEXT: ret i32 [[Z]]
;
%s = lshr i16 %x, 8
%z = zext i16 %s to i32
OpenPOWER on IntegriCloud