Skip to content
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
20 changes: 20 additions & 0 deletions llvm/test/tools/llvm-reduce/operands-to-args-preserve-fmf.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; 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
; RUN: FileCheck %s --input-file %t --check-prefix=REDUCED

; INTERESTING-LABEL: define float @callee(
; INTERESTING: fadd float
define float @callee(float %a) {
%x = fadd float %a, 1.0
ret float %x
}

; INTERESTING-LABEL: define float @caller(
; INTERESTING: load float

; REDUCED-LABEL: define float @caller(ptr %ptr, float %val, float %callee.ret1) {
; REDUCED: %callee.ret12 = call nnan nsz float @callee(float %val, float 0.000000e+00)
define float @caller(ptr %ptr) {
%val = load float, ptr %ptr
%callee.ret = call nnan nsz float @callee(float %val)
ret float %callee.ret
}
4 changes: 4 additions & 0 deletions llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Operator.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"

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

if (auto *FPOp = dyn_cast<FPMathOperator>(NewCI))
NewCI->setFastMathFlags(CI->getFastMathFlags());

// Do the replacement for this use.
if (!CI->use_empty())
CI->replaceAllUsesWith(NewCI);
Expand Down
Loading