ValueTracking: Figure out more bits when looking at add/sub
Given something like X01XX + X01XX, we know that the result must look
like X1XXX.
Adapted from a patch by Richard Smith, test-case written by me.
llvm-svn: 216250
diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index 94872d3..27fe1bea 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -969,3 +969,16 @@
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[DIV]], 1073741824
; CHECK-NEXT: ret i1 [[CMP]]
}
+
+define i1 @icmp_known_bits(i4 %x, i4 %y) {
+ %and1 = and i4 %y, -7
+ %and2 = and i4 %x, -7
+ %or1 = or i4 %and1, 2
+ %or2 = or i4 %and2, 2
+ %add = add i4 %or1, %or2
+ %cmp = icmp eq i4 %add, 0
+ ret i1 %cmp
+
+; CHECK-LABEL: @icmp_known_bits
+; CHECK-NEXT: ret i1 false
+}