Skip to content

Commit a40b5e1

Browse files
committed
let strictfp only work for libm
1 parent 6ad9565 commit a40b5e1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9392,7 +9392,9 @@ bool SelectionDAGBuilder::visitStrNLenCall(const CallInst &I) {
93929392
bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I,
93939393
unsigned Opcode) {
93949394
// We already checked this call's prototype; verify it doesn't modify errno.
9395-
if (!I.onlyReadsMemory())
9395+
// Do not perform optimizations for call sites that require strict
9396+
// floating-point semantics.
9397+
if (!I.onlyReadsMemory() || I.isStrictFP())
93969398
return false;
93979399

93989400
SDNodeFlags Flags;
@@ -9412,7 +9414,9 @@ bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I,
94129414
bool SelectionDAGBuilder::visitBinaryFloatCall(const CallInst &I,
94139415
unsigned Opcode) {
94149416
// We already checked this call's prototype; verify it doesn't modify errno.
9415-
if (!I.onlyReadsMemory())
9417+
// Do not perform optimizations for call sites that require strict
9418+
// floating-point semantics.
9419+
if (!I.onlyReadsMemory() || I.isStrictFP())
94169420
return false;
94179421

94189422
SDNodeFlags Flags;
@@ -9445,11 +9449,10 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
94459449

94469450
// Check for well-known libc/libm calls. If the function is internal, it
94479451
// can't be a library call. Don't do the check if marked as nobuiltin for
9448-
// some reason or the call site requires strict floating point semantics.
9452+
// some reason.
94499453
LibFunc Func;
9450-
if (!I.isNoBuiltin() && !I.isStrictFP() && !F->hasLocalLinkage() &&
9451-
F->hasName() && LibInfo->getLibFunc(*F, Func) &&
9452-
LibInfo->hasOptimizedCodeGen(Func)) {
9454+
if (!I.isNoBuiltin() && !F->hasLocalLinkage() && F->hasName() &&
9455+
LibInfo->getLibFunc(*F, Func) && LibInfo->hasOptimizedCodeGen(Func)) {
94539456
switch (Func) {
94549457
default: break;
94559458
case LibFunc_bcmp:

llvm/test/CodeGen/PowerPC/milicode32.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ entry:
6464
%str.addr = alloca ptr, align 4
6565
store ptr %str, ptr %str.addr, align 4
6666
%0 = load ptr, ptr %str.addr, align 4
67-
%call = call i32 @strlen(ptr noundef %0)
67+
%call = call i32 @strlen(ptr noundef %0) #0
6868
ret i32 %call
6969
}
7070

7171
declare i32 @strlen(ptr noundef) nounwind
72+
attributes #0 = { strictfp }

0 commit comments

Comments
 (0)