[llvm] 6eef387 - [InstCombine] Test comparison of abs with int min (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 11:25:04 PDT 2020
Author: Nikita Popov
Date: 2020-09-08T20:20:32+02:00
New Revision: 6eef387ddd863db1afe044e208bbff4366d5dac2
URL: https://github.com/llvm/llvm-project/commit/6eef387ddd863db1afe044e208bbff4366d5dac2
DIFF: https://github.com/llvm/llvm-project/commit/6eef387ddd863db1afe044e208bbff4366d5dac2.diff
LOG: [InstCombine] Test comparison of abs with int min (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/abs-intrinsic.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/abs-intrinsic.ll b/llvm/test/Transforms/InstCombine/abs-intrinsic.ll
index b5a74f728ac3..d63b0a21f217 100644
--- a/llvm/test/Transforms/InstCombine/abs-intrinsic.ll
+++ b/llvm/test/Transforms/InstCombine/abs-intrinsic.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
+declare i8 @llvm.abs.i8(i8, i1)
declare i32 @llvm.abs.i32(i32, i1)
declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1)
declare <3 x i82> @llvm.abs.v3i82(<3 x i82>, i1)
@@ -253,3 +254,43 @@ define i32 @abs_known_neg(i16 %x) {
%abs = call i32 @llvm.abs.i32(i32 %neg, i1 false)
ret i32 %abs
}
+
+define i1 @abs_eq_int_min_poison(i8 %x) {
+; CHECK-LABEL: @abs_eq_int_min_poison(
+; CHECK-NEXT: ret i1 false
+;
+ %abs = call i8 @llvm.abs.i8(i8 %x, i1 true)
+ %cmp = icmp eq i8 %abs, -128
+ ret i1 %cmp
+}
+
+define i1 @abs_ne_int_min_poison(i8 %x) {
+; CHECK-LABEL: @abs_ne_int_min_poison(
+; CHECK-NEXT: ret i1 true
+;
+ %abs = call i8 @llvm.abs.i8(i8 %x, i1 true)
+ %cmp = icmp ne i8 %abs, -128
+ ret i1 %cmp
+}
+
+define i1 @abs_eq_int_min_nopoison(i8 %x) {
+; CHECK-LABEL: @abs_eq_int_min_nopoison(
+; CHECK-NEXT: [[ABS:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[ABS]], -128
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %abs = call i8 @llvm.abs.i8(i8 %x, i1 false)
+ %cmp = icmp eq i8 %abs, -128
+ ret i1 %cmp
+}
+
+define i1 @abs_ne_int_min_nopoison(i8 %x) {
+; CHECK-LABEL: @abs_ne_int_min_nopoison(
+; CHECK-NEXT: [[ABS:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[ABS]], -128
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %abs = call i8 @llvm.abs.i8(i8 %x, i1 false)
+ %cmp = icmp ne i8 %abs, -128
+ ret i1 %cmp
+}
More information about the llvm-commits
mailing list