aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/slices.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/codegen/slices.go')
-rw-r--r--test/codegen/slices.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/codegen/slices.go b/test/codegen/slices.go
index 40e857f9f6..38e8a62f4b 100644
--- a/test/codegen/slices.go
+++ b/test/codegen/slices.go
@@ -347,3 +347,24 @@ func InitNotSmallSliceLiteral() []int {
42,
}
}
+
+// --------------------------------------- //
+// Test PPC64 SUBFCconst folding rules //
+// triggered by slice operations. //
+// --------------------------------------- //
+
+func SliceWithConstCompare(a []int, b int) []int {
+ var c []int = []int{1, 2, 3, 4, 5}
+ if b+len(a) < len(c) {
+ // ppc64le:-"NEG"
+ // ppc64:-"NEG"
+ return c[b:]
+ }
+ return a
+}
+
+func SliceWithSubtractBound(a []int, b int) []int {
+ // ppc64le:"SUBC",-"NEG"
+ // ppc64:"SUBC",-"NEG"
+ return a[(3 - b):]
+}