Skip to content

Commit f18941c

Browse files
committed
also check FeatureBit equality
1 parent 675f42f commit f18941c

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,9 @@ bool SystemZTTIImpl::areInlineCompatible(const Function *Caller,
431431
const FeatureBitset &CalleeBits =
432432
TM.getSubtargetImpl(*Callee)->getFeatureBits();
433433

434-
// Check that targets features from the callee are subset of the caller's.
435-
return CalleeBits < CallerBits;
434+
// Check that target features from the callee are subset or
435+
// equal to the caller's features.
436+
return (CalleeBits == CallerBits) || (CalleeBits < CallerBits);
436437
}
437438

438439
unsigned SystemZTTIImpl::getNumberOfRegisters(unsigned ClassID) const {

llvm/test/Transforms/Inline/SystemZ/inline-target-attr.ll

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --tool ../build/bin/opt --version 5
2-
; RUN: opt < %s -mtriple=s390x-ibm-linux -S -passes=inline | FileCheck %s
3-
; RUN: opt < %s -mtriple=s390x-ibm-linux -S -passes='cgscc(inline)' | FileCheck %s
1+
; RUN: opt < %s -mtriple=s390x-linux-gnu -S -passes=inline | FileCheck %s
2+
; RUN: opt < %s -mtriple=s390x-linux-gnu -S -passes='cgscc(inline)' | FileCheck %s
43
; Check that we only inline when we have compatible target attributes.
54

65
define i32 @foo() #0 {
@@ -29,5 +28,23 @@ entry:
2928
; CHECK: call i32 @bar()
3029
}
3130

32-
attributes #0 = { "target-cpu"="z13" }
33-
attributes #1 = { "target-cpu"="z14" }
31+
define i32 @quux() #2 {
32+
entry:
33+
%call = call i32 @bar()
34+
ret i32 %call
35+
; CHECK-LABEL: quux
36+
; CHECK: call i32 (...) @baz()
37+
}
38+
39+
define i32 @foobar() #1 {
40+
entry:
41+
%call = call i32 @bar()
42+
ret i32 %call
43+
; CHECK-LABEL: foobar
44+
; CHECK: call i32 (...) @baz()
45+
}
46+
47+
48+
attributes #0 = { "target-cpu"="generic" "target-features"="+guarded-storage" }
49+
attributes #1 = { "target-cpu"="generic" "target-features"="+guarded-storage,+enhanced-sort" }
50+
attributes #2 = { "target-cpu"="generic" "target-features"="+concurrent-functions" }

0 commit comments

Comments
 (0)