[llvm] 7d9f03f - [InstSimplify] Add tests for PR62760 (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 03:31:22 PDT 2023
Author: Nikita Popov
Date: 2023-05-17T12:31:13+02:00
New Revision: 7d9f03f4d8e1d59da267a863e0018f2e172ca0f9
URL: https://github.com/llvm/llvm-project/commit/7d9f03f4d8e1d59da267a863e0018f2e172ca0f9
DIFF: https://github.com/llvm/llvm-project/commit/7d9f03f4d8e1d59da267a863e0018f2e172ca0f9.diff
LOG: [InstSimplify] Add tests for PR62760 (NFC)
Added:
Modified:
llvm/test/Transforms/InstSimplify/abs_intrinsic.ll
llvm/test/Transforms/InstSimplify/call.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll b/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll
index aac07d5dd825..ca1ee9461cf7 100644
--- a/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll
+++ b/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
+declare i1 @llvm.abs.i1(i1, i1)
declare i8 @llvm.abs.i8(i8, i1)
declare i32 @llvm.abs.i32(i32, i1)
declare <3 x i82> @llvm.abs.v3i82(<3 x i82>, i1)
@@ -290,3 +291,42 @@ define i32 @select_nabs_of_abs_ne(i32 %x) {
%sel = select i1 %cmp, i32 %neg, i32 %abs
ret i32 %sel
}
+
+; FIXME: This is a miscompile.
+define i1 @abs_i1_non_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @abs_i1_non_poison_eq_false(
+; CHECK-NEXT: ret i1 true
+;
+ %abs = call i1 @llvm.abs.i1(i1 %x, i1 false)
+ %cmp = icmp eq i1 %abs, false
+ ret i1 %cmp
+}
+
+define i1 @abs_i1_non_poison_eq_true(i1 %x) {
+; CHECK-LABEL: @abs_i1_non_poison_eq_true(
+; CHECK-NEXT: [[ABS:%.*]] = call i1 @llvm.abs.i1(i1 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i1 [[ABS]]
+;
+ %abs = call i1 @llvm.abs.i1(i1 %x, i1 false)
+ %cmp = icmp eq i1 %abs, true
+ ret i1 %cmp
+}
+
+define i1 @abs_i1_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @abs_i1_poison_eq_false(
+; CHECK-NEXT: ret i1 true
+;
+ %abs = call i1 @llvm.abs.i1(i1 %x, i1 true)
+ %cmp = icmp eq i1 %abs, false
+ ret i1 %cmp
+}
+
+define i1 @abs_i1_poison_eq_true(i1 %x) {
+; CHECK-LABEL: @abs_i1_poison_eq_true(
+; CHECK-NEXT: [[ABS:%.*]] = call i1 @llvm.abs.i1(i1 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i1 [[ABS]]
+;
+ %abs = call i1 @llvm.abs.i1(i1 %x, i1 true)
+ %cmp = icmp eq i1 %abs, true
+ ret i1 %cmp
+}
diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll
index 989580fea451..449a60e79f3e 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -1379,7 +1379,7 @@ declare float @fmaxf(float, float)
define float @nobuiltin_fmax() {
; CHECK-LABEL: @nobuiltin_fmax(
-; CHECK-NEXT: [[M:%.*]] = call float @fmaxf(float 0.000000e+00, float 1.000000e+00) #[[ATTR4:[0-9]+]]
+; CHECK-NEXT: [[M:%.*]] = call float @fmaxf(float 0.000000e+00, float 1.000000e+00) #[[ATTR3:[0-9]+]]
; CHECK-NEXT: [[R:%.*]] = call float @llvm.fabs.f32(float [[M]])
; CHECK-NEXT: ret float [[R]]
;
@@ -1392,6 +1392,8 @@ define float @nobuiltin_fmax() {
declare i32 @llvm.ctpop.i32(i32)
declare <3 x i33> @llvm.ctpop.v3i33(<3 x i33>)
declare i1 @llvm.ctpop.i1(i1)
+declare i1 @llvm.ctlz.i1(i1, i1)
+declare i1 @llvm.cttz.i1(i1, i1)
define i32 @ctpop_lowbit(i32 %x) {
; CHECK-LABEL: @ctpop_lowbit(
@@ -1567,5 +1569,52 @@ define i1 @capture_vs_recurse(i64 %mask) {
ret i1 %cmp
}
+; FIXME: This is a miscompile.
+define i1 @ctlz_i1_non_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @ctlz_i1_non_poison_eq_false(
+; CHECK-NEXT: ret i1 true
+;
+ %ct = call i1 @llvm.ctlz.i1(i1 %x, i1 false)
+ %cmp = icmp eq i1 %ct, false
+ ret i1 %cmp
+}
+
+define i1 @ctlz_i1_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @ctlz_i1_poison_eq_false(
+; CHECK-NEXT: ret i1 true
+;
+ %ct = call i1 @llvm.ctlz.i1(i1 %x, i1 true)
+ %cmp = icmp eq i1 %ct, false
+ ret i1 %cmp
+}
+
+; FIXME: This is a miscompile.
+define i1 @cttz_i1_non_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @cttz_i1_non_poison_eq_false(
+; CHECK-NEXT: ret i1 true
+;
+ %ct = call i1 @llvm.cttz.i1(i1 %x, i1 false)
+ %cmp = icmp eq i1 %ct, false
+ ret i1 %cmp
+}
+
+define i1 @cttz_i1_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @cttz_i1_poison_eq_false(
+; CHECK-NEXT: ret i1 true
+;
+ %ct = call i1 @llvm.cttz.i1(i1 %x, i1 true)
+ %cmp = icmp eq i1 %ct, false
+ ret i1 %cmp
+}
+
+define i1 @ctpop_i1_non_poison_eq_false(i1 %x) {
+; CHECK-LABEL: @ctpop_i1_non_poison_eq_false(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i1 [[X:%.*]], false
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %ct = call i1 @llvm.ctpop.i1(i1 %x)
+ %cmp = icmp eq i1 %ct, false
+ ret i1 %cmp
+}
attributes #0 = { nobuiltin readnone }
More information about the llvm-commits
mailing list