[llvm] [llvm-reduce] Reduce samesign flag from icmp (PR #115492)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 06:43:18 PST 2024
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/115492
None
>From 4086297eb2a5e712099c33cb89fe3d313bd64ff8 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Fri, 8 Nov 2024 22:41:07 +0800
Subject: [PATCH] [llvm-reduce] Reduce samesign flag from icmp
---
llvm/test/tools/llvm-reduce/reduce-flags.ll | 16 ++++++++++++++++
.../deltas/ReduceInstructionFlags.cpp | 3 +++
2 files changed, 19 insertions(+)
diff --git a/llvm/test/tools/llvm-reduce/reduce-flags.ll b/llvm/test/tools/llvm-reduce/reduce-flags.ll
index 293504e32f9108..f220fc429c89e9 100644
--- a/llvm/test/tools/llvm-reduce/reduce-flags.ll
+++ b/llvm/test/tools/llvm-reduce/reduce-flags.ll
@@ -272,3 +272,19 @@ define i32 @trunc_nsw_keep(i64 %a) {
%op = trunc nsw i64 %a to i32
ret i32 %op
}
+
+; CHECK-LABEL: @icmp_samesign_drop(
+; INTERESTING: = icmp
+; RESULT: icmp ult i32
+define i1 @icmp_samesign_drop(i32 %a) {
+ %op = icmp samesign ult i32 %a, 10
+ ret i1 %op
+}
+
+; CHECK-LABEL: @icmp_samesign_keep(
+; INTERESTING: = icmp samesign
+; RESULT: icmp samesign ult i32
+define i1 @icmp_samesign_keep(i32 %a) {
+ %op = icmp samesign ult i32 %a, 10
+ ret i1 %op
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp b/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
index ff9dde40b2df41..e157747004782d 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
@@ -42,6 +42,9 @@ static void reduceFlagsInModule(Oracle &O, ReducerWorkItem &WorkItem) {
} else if (auto *PDI = dyn_cast<PossiblyDisjointInst>(&I)) {
if (PDI->isDisjoint() && !O.shouldKeep())
PDI->setIsDisjoint(false);
+ } else if (auto *ICmp = dyn_cast<ICmpInst>(&I)) {
+ if (ICmp->hasSameSign() && !O.shouldKeep())
+ ICmp->setSameSign(false);
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
GEPNoWrapFlags NW = GEP->getNoWrapFlags();
if (NW.isInBounds() && !O.shouldKeep())
More information about the llvm-commits
mailing list