Skip to content

[llvm-reduce] Reduce samesign flag from icmp #115492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions llvm/test/tools/llvm-reduce/reduce-flags.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading