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
15 changes: 9 additions & 6 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9456,7 +9456,9 @@ bool SelectionDAGBuilder::visitStrNLenCall(const CallInst &I) {
bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I,
unsigned Opcode) {
// We already checked this call's prototype; verify it doesn't modify errno.
if (!I.onlyReadsMemory())
// Do not perform optimizations for call sites that require strict
// floating-point semantics.
if (!I.onlyReadsMemory() || I.isStrictFP())
return false;

SDNodeFlags Flags;
Expand All @@ -9476,7 +9478,9 @@ bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I,
bool SelectionDAGBuilder::visitBinaryFloatCall(const CallInst &I,
unsigned Opcode) {
// We already checked this call's prototype; verify it doesn't modify errno.
if (!I.onlyReadsMemory())
// Do not perform optimizations for call sites that require strict
// floating-point semantics.
if (!I.onlyReadsMemory() || I.isStrictFP())
return false;

SDNodeFlags Flags;
Expand Down Expand Up @@ -9509,11 +9513,10 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {

// Check for well-known libc/libm calls. If the function is internal, it
// can't be a library call. Don't do the check if marked as nobuiltin for
// some reason or the call site requires strict floating point semantics.
// some reason.
LibFunc Func;
if (!I.isNoBuiltin() && !I.isStrictFP() && !F->hasLocalLinkage() &&
F->hasName() && LibInfo->getLibFunc(*F, Func) &&
LibInfo->hasOptimizedCodeGen(Func)) {
if (!I.isNoBuiltin() && !F->hasLocalLinkage() && F->hasName() &&
LibInfo->getLibFunc(*F, Func) && LibInfo->hasOptimizedCodeGen(Func)) {
switch (Func) {
default: break;
case LibFunc_bcmp:
Expand Down
34 changes: 34 additions & 0 deletions llvm/test/CodeGen/PowerPC/milicode32.ll
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,41 @@ entry:
ret i32 %call
}

define i32 @strlen_test_fp_strict(ptr noundef %str) nounwind {
; CHECK-AIX-32-P9-LABEL: strlen_test_fp_strict:
; CHECK-AIX-32-P9: # %bb.0: # %entry
; CHECK-AIX-32-P9-NEXT: mflr r0
; CHECK-AIX-32-P9-NEXT: stwu r1, -64(r1)
; CHECK-AIX-32-P9-NEXT: stw r0, 72(r1)
; CHECK-AIX-32-P9-NEXT: stw r3, 60(r1)
; CHECK-AIX-32-P9-NEXT: bl .___strlen[PR]
; CHECK-AIX-32-P9-NEXT: nop
; CHECK-AIX-32-P9-NEXT: addi r1, r1, 64
; CHECK-AIX-32-P9-NEXT: lwz r0, 8(r1)
; CHECK-AIX-32-P9-NEXT: mtlr r0
; CHECK-AIX-32-P9-NEXT: blr
;
; CHECK-LINUX32-P9-LABEL: strlen_test_fp_strict:
; CHECK-LINUX32-P9: # %bb.0: # %entry
; CHECK-LINUX32-P9-NEXT: mflr r0
; CHECK-LINUX32-P9-NEXT: stwu r1, -16(r1)
; CHECK-LINUX32-P9-NEXT: stw r0, 20(r1)
; CHECK-LINUX32-P9-NEXT: stw r3, 12(r1)
; CHECK-LINUX32-P9-NEXT: bl strlen
; CHECK-LINUX32-P9-NEXT: lwz r0, 20(r1)
; CHECK-LINUX32-P9-NEXT: addi r1, r1, 16
; CHECK-LINUX32-P9-NEXT: mtlr r0
; CHECK-LINUX32-P9-NEXT: blr
entry:
%str.addr = alloca ptr, align 4
store ptr %str, ptr %str.addr, align 4
%0 = load ptr, ptr %str.addr, align 4
%call = call i32 @strlen(ptr noundef %0) #0
ret i32 %call
}

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

define ptr @test_memmove(ptr noundef %destination, ptr noundef %source, i32 noundef %num) #0 {
; CHECK-AIX-32-P9-LABEL: test_memmove:
Expand Down