Skip to content

Commit 6d55981

Browse files
committed
llvm-reduce: Fix losing fast math flags in operands-to-args
1 parent 1e43812 commit 6d55981

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction --delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg --check-prefix=INTERESTING --test-arg --input-file
2+
; RUN: FileCheck %s --input-file %t --check-prefix=REDUCED
3+
4+
; INTERESTING-LABEL: define float @callee(
5+
; INTERESTING: fadd float
6+
define float @callee(float %a) {
7+
%x = fadd float %a, 1.0
8+
ret float %x
9+
}
10+
11+
; INTERESTING-LABEL: define float @caller(
12+
; INTERESTING: load float
13+
14+
; REDUCED-LABEL: define float @caller(ptr %ptr, float %val, float %callee.ret1) {
15+
; REDUCED: %callee.ret12 = call nnan nsz float @callee(float %val, float 0.000000e+00)
16+
define float @caller(ptr %ptr) {
17+
%val = load float, ptr %ptr
18+
%callee.ret = call nnan nsz float @callee(float %val)
19+
ret float %callee.ret
20+
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/IR/InstIterator.h"
1515
#include "llvm/IR/InstrTypes.h"
1616
#include "llvm/IR/Instructions.h"
17+
#include "llvm/IR/Operator.h"
1718
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
1819
#include "llvm/Transforms/Utils/Cloning.h"
1920

@@ -107,6 +108,9 @@ static void replaceFunctionCalls(Function *OldF, Function *NewF) {
107108
NewCI->setCallingConv(NewF->getCallingConv());
108109
NewCI->setAttributes(CI->getAttributes());
109110

111+
if (auto *FPOp = dyn_cast<FPMathOperator>(NewCI))
112+
NewCI->setFastMathFlags(CI->getFastMathFlags());
113+
110114
// Do the replacement for this use.
111115
if (!CI->use_empty())
112116
CI->replaceAllUsesWith(NewCI);

0 commit comments

Comments
 (0)