[llvm] 3356eb3 - [llvm-reduce] Reduce samesign flag from icmp (#115492)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 08:12:15 PST 2024
Author: Yingwei Zheng
Date: 2024-11-09T00:12:09+08:00
New Revision: 3356eb3b15f391b9b4f62b0157fede16bd8cd5b3
URL: https://github.com/llvm/llvm-project/commit/3356eb3b15f391b9b4f62b0157fede16bd8cd5b3
DIFF: https://github.com/llvm/llvm-project/commit/3356eb3b15f391b9b4f62b0157fede16bd8cd5b3.diff
LOG: [llvm-reduce] Reduce samesign flag from icmp (#115492)
Added:
Modified:
llvm/test/tools/llvm-reduce/reduce-flags.ll
llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
Removed:
################################################################################
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