[llvm] r372929 - [NFC][InstCombine] Tests for 'base u<= offset && (base - offset) != 0' pattern (PR43251)
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 15:59:49 PDT 2019
Author: lebedevri
Date: Wed Sep 25 15:59:48 2019
New Revision: 372929
URL: http://llvm.org/viewvc/llvm-project?rev=372929&view=rev
Log:
[NFC][InstCombine] Tests for 'base u<= offset && (base - offset) != 0' pattern (PR43251)
Modified:
llvm/trunk/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll
Modified: llvm/trunk/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll?rev=372929&r1=372928&r2=372929&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll Wed Sep 25 15:59:48 2019
@@ -399,3 +399,36 @@ define i1 @t14_bad(i64 %base, i64 %offse
%r = and i1 %not_null, %no_underflow
ret i1 %r
}
+
+define i1 @base_ult_offset(i8 %base, i8 %offset) {
+; CHECK-LABEL: @base_ult_offset(
+; CHECK-NEXT: [[ADJUSTED:%.*]] = sub i8 [[BASE:%.*]], [[OFFSET:%.*]]
+; CHECK-NEXT: call void @use8(i8 [[ADJUSTED]])
+; CHECK-NEXT: [[NOT_NULL:%.*]] = icmp ne i8 [[ADJUSTED]], 0
+; CHECK-NEXT: [[NO_UNDERFLOW:%.*]] = icmp ule i8 [[BASE]], [[OFFSET]]
+; CHECK-NEXT: [[R:%.*]] = and i1 [[NO_UNDERFLOW]], [[NOT_NULL]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %adjusted = sub i8 %base, %offset
+ call void @use8(i8 %adjusted)
+ %not_null = icmp ne i8 %adjusted, 0
+ %no_underflow = icmp ule i8 %base, %offset
+ %r = and i1 %no_underflow, %not_null
+ ret i1 %r
+}
+define i1 @base_uge_offset(i8 %base, i8 %offset) {
+; CHECK-LABEL: @base_uge_offset(
+; CHECK-NEXT: [[ADJUSTED:%.*]] = sub i8 [[BASE:%.*]], [[OFFSET:%.*]]
+; CHECK-NEXT: call void @use8(i8 [[ADJUSTED]])
+; CHECK-NEXT: [[NOT_NULL:%.*]] = icmp eq i8 [[ADJUSTED]], 0
+; CHECK-NEXT: [[NO_UNDERFLOW:%.*]] = icmp ugt i8 [[BASE]], [[OFFSET]]
+; CHECK-NEXT: [[R:%.*]] = or i1 [[NO_UNDERFLOW]], [[NOT_NULL]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %adjusted = sub i8 %base, %offset
+ call void @use8(i8 %adjusted)
+ %not_null = icmp eq i8 %adjusted, 0
+ %no_underflow = icmp ugt i8 %base, %offset
+ %r = or i1 %no_underflow, %not_null
+ ret i1 %r
+}
More information about the llvm-commits
mailing list