Files
swift-mirror/test/SILOptimizer/sil_combine_bitops.sil
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00

145 lines
5.3 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -sil-combine | %FileCheck %s
// Test optimizations for binary bit operations.
sil_stage canonical
import Builtin
import Swift
// CHECK-LABEL: sil @test_and1
// CHECK: %1 = integer_literal $Builtin.Int64, 0
// CHECK: return %1
sil @test_and1 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 0
%2 = builtin "and_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
return %2 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_and2
// CHECK: bb0(%0 : $Builtin.Int64):
// CHECK: return %0
sil @test_and2 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, -1
%2 = builtin "and_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
return %2 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_and3
// CHECK: %1 = integer_literal $Builtin.Int64, 32
// CHECK: %2 = builtin "and_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64)
// CHECK: return %2
sil @test_and3 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 288
%2 = builtin "and_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
%3 = integer_literal $Builtin.Int64, 35
%4 = builtin "and_Int64"(%2 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int64
return %4 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_and4
// CHECK: %1 = integer_literal $Builtin.Int64, 0
// CHECK: return %1
sil @test_and4 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 18
%2 = builtin "and_Int64"(%1 : $Builtin.Int64, %0 : $Builtin.Int64) : $Builtin.Int64
%3 = integer_literal $Builtin.Int64, 256
%4 = builtin "and_Int64"(%2 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int64
return %4 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_or1
// CHECK: bb0(%0 : $Builtin.Int64):
// CHECK: return %0
sil @test_or1 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 0
%2 = builtin "or_Int64"(%1 : $Builtin.Int64, %0 : $Builtin.Int64) : $Builtin.Int64
return %2 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_or2
// CHECK: %1 = integer_literal $Builtin.Int64, -1
// CHECK: return %1
sil @test_or2 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, -1
%2 = builtin "or_Int64"(%1 : $Builtin.Int64, %0 : $Builtin.Int64) : $Builtin.Int64
return %2 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_or3
// CHECK: %1 = integer_literal $Builtin.Int64, 291
// CHECK: %2 = builtin "or_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64)
// CHECK: return %2
sil @test_or3 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 288
%2 = builtin "or_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
%3 = integer_literal $Builtin.Int64, 35
%4 = builtin "or_Int64"(%2 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int64
return %4 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_or4
// CHECK: %1 = integer_literal $Builtin.Int64, -1
// CHECK: return %1
sil @test_or4 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, -4
%2 = builtin "or_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
%3 = integer_literal $Builtin.Int64, 3
%4 = builtin "or_Int64"(%2 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int64
return %4 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_xor1
// CHECK: bb0(%0 : $Builtin.Int64):
// CHECK: return %0
sil @test_xor1 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 0
%2 = builtin "xor_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
return %2 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_xor2
// CHECK: %1 = integer_literal $Builtin.Int64, -1
// CHECK: %2 = builtin "xor_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64)
// CHECK: return %2
sil @test_xor2 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, -1
%2 = builtin "xor_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
return %2 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_xor3
// CHECK: %1 = integer_literal $Builtin.Int64, 259
// CHECK: %2 = builtin "xor_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64)
// CHECK: return %2
sil @test_xor3 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 288
%2 = builtin "xor_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
%3 = integer_literal $Builtin.Int64, 35
%4 = builtin "xor_Int64"(%2 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int64
return %4 : $Builtin.Int64
}
// CHECK-LABEL: sil @test_xor4
// CHECK: bb0(%0 : $Builtin.Int64):
// CHECK: return %0
sil @test_xor4 : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
%1 = integer_literal $Builtin.Int64, 18
%2 = builtin "xor_Int64"(%0 : $Builtin.Int64, %1 : $Builtin.Int64) : $Builtin.Int64
%3 = builtin "xor_Int64"(%1 : $Builtin.Int64, %2 : $Builtin.Int64) : $Builtin.Int64
return %3 : $Builtin.Int64
}