Skip to content
Open
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 @@ -9392,7 +9392,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 @@ -9412,7 +9414,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 @@ -9445,11 +9449,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,4 +68,38 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add test, not modify existing one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve added a new test scenario called strlen_test_fp_strict , which differs from strlen_test.
there is

%call = call i32 @strlen(ptr noundef %0) #0 
attributes #0 = { strictfp }

in the strlen_test_fp_strict.
I’m not entirely sure what “bump” refers to in this context. could you please clarify its meaning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever you have a moment, could you please take another look and let me know your thoughts —especially regarding the “bump” reference I mentioned?
Thanks for your time! @arsenm

ret i32 %call
}

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