Skip to content

Commit 46cca67

Browse files
committed
Improve mutator
1 parent c1ae80d commit 46cca67

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

fuzz_existing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"simplify-demanded-fpclass.ll", # https://alive2.llvm.org/ce/z/9KZBCB
4747
"fpclass-from-dom-cond.ll", # https://alive2.llvm.org/ce/z/FLRYV5
4848
"icmp-custom-dl.ll", # https://alive2.llvm.org/ce/z/GAJKhi
49-
"funnel.ll", # https://github.com/llvm/llvm-project/issues/161493
5049
]
5150

5251

mutate.cpp

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ bool mutateFlags(Instruction &I, bool Add) {
378378
}
379379
if (auto *FPOp = dyn_cast<FPMathOperator>(&I)) {
380380
if (Add) {
381-
switch (randomUInt(2)) {
381+
switch (randomUInt(1)) {
382382
case 0:
383383
if (!FPOp->hasNoInfs()) {
384384
I.setHasNoInfs(true);
@@ -391,22 +391,23 @@ bool mutateFlags(Instruction &I, bool Add) {
391391
return true;
392392
}
393393
break;
394-
case 2:
395-
if (!FPOp->hasNoSignedZeros()) {
396-
// See
397-
// https://discourse.llvm.org/t/rfc-clarify-the-behavior-of-fp-operations-on-bit-strings-with-nsz-flag/85981
398-
if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
399-
auto IID = II->getIntrinsicID();
400-
if (IID == Intrinsic::fabs || IID == Intrinsic::copysign)
401-
return false;
402-
}
403-
if (I.getOpcode() == Instruction::FNeg ||
404-
I.getOpcode() == Instruction::Select)
405-
return false;
406-
I.setHasNoSignedZeros(true);
407-
return true;
408-
}
409-
break;
394+
// case 2:
395+
// if (!FPOp->hasNoSignedZeros()) {
396+
// // See
397+
// //
398+
// https://discourse.llvm.org/t/rfc-clarify-the-behavior-of-fp-operations-on-bit-strings-with-nsz-flag/85981
399+
// if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
400+
// auto IID = II->getIntrinsicID();
401+
// if (IID == Intrinsic::fabs || IID == Intrinsic::copysign)
402+
// return false;
403+
// }
404+
// if (I.getOpcode() == Instruction::FNeg ||
405+
// I.getOpcode() == Instruction::Select)
406+
// return false;
407+
// I.setHasNoSignedZeros(true);
408+
// return true;
409+
// }
410+
// break;
410411
}
411412
} else {
412413
switch (randomUInt(2)) {
@@ -576,6 +577,16 @@ bool mutateOpcode(Instruction &I) {
576577
{Cmp->getOperand(0), Cmp->getOperand(1)});
577578
});
578579
}
580+
// fshl/fshr
581+
if (match(&I, m_Intrinsic<Intrinsic::fshl>()) ||
582+
match(&I, m_Intrinsic<Intrinsic::fshr>()))
583+
return createNewInst(I, [&](IRBuilder<> &Builder) {
584+
return Builder.CreateIntrinsic(
585+
I.getType(),
586+
match(&I, m_Intrinsic<Intrinsic::fshl>()) ? Intrinsic::fshr
587+
: Intrinsic::fshl,
588+
{I.getOperand(0), I.getOperand(1), I.getOperand(2)});
589+
});
579590
return false;
580591
}
581592
bool canonicalizeOp(Instruction &I) {

0 commit comments

Comments
 (0)