Skip to content

Commit 82d7502

Browse files
committed
llvm-reduce: Handle nneg flag
1 parent 1fef0fa commit 82d7502

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/test/tools/llvm-reduce/reduce-flags.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,19 @@ define float @fadd_nnan_ninf_keep_nnan(float %a, float %b) {
200200
%op = fadd nnan ninf float %a, %b
201201
ret float %op
202202
}
203+
204+
; CHECK-LABEL: @zext_nneg_drop(
205+
; INTERESTING: = zext
206+
; RESULT: zext i32
207+
define i64 @zext_nneg_drop(i32 %a) {
208+
%op = zext nneg i32 %a to i64
209+
ret i64 %op
210+
}
211+
212+
; CHECK-LABEL: @zext_nneg_keep(
213+
; INTERESTING: = zext nneg
214+
; RESULT: zext nneg i32
215+
define i64 @zext_nneg_keep(i32 %a) {
216+
%op = zext nneg i32 %a to i64
217+
ret i64 %op
218+
}

llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ static void reduceFlagsInModule(Oracle &O, ReducerWorkItem &WorkItem) {
3030
} else if (auto *PE = dyn_cast<PossiblyExactOperator>(&I)) {
3131
if (PE->isExact() && !O.shouldKeep())
3232
I.setIsExact(false);
33+
} else if (auto *NNI = dyn_cast<PossiblyNonNegInst>(&I)) {
34+
if (NNI->hasNonNeg() && !O.shouldKeep())
35+
NNI->setNonNeg(false);
3336
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
3437
if (GEP->isInBounds() && !O.shouldKeep())
3538
GEP->setIsInBounds(false);

0 commit comments

Comments
 (0)