mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 01:40:02 +00:00
34 lines
905 B
Rust
34 lines
905 B
Rust
//@ revisions: NO-OPT SPEED-OPT
|
|
//@[NO-OPT] compile-flags: -Copt-level=0
|
|
//@[SPEED-OPT] compile-flags: -Copt-level=3 -Coverflow-checks=y
|
|
|
|
#![feature(optimize_attribute)]
|
|
|
|
#[optimize(none)]
|
|
pub fn add_noopt() -> i32 {
|
|
// CHECK-LABEL: fn add_noopt(
|
|
// CHECK: AddWithOverflow(const 1_i32, const 2_i32);
|
|
// CHECK-NEXT: assert
|
|
1 + 2
|
|
}
|
|
|
|
#[optimize(none)]
|
|
pub fn const_branch() -> i32 {
|
|
// CHECK-LABEL: fn const_branch(
|
|
// CHECK: [[BOOL:_[0-9]+]] = const true;
|
|
// CHECK: switchInt(move [[BOOL]]) -> [0: [[BB_FALSE_SHIM:bb[0-9]+]], otherwise: [[BB_TRUE:bb[0-9]+]]];
|
|
// CHECK-NEXT: }
|
|
// CHECK: [[BB_FALSE_SHIM]]: {
|
|
// CHECK-NEXT: goto -> [[BB_FALSE:bb[0-9]+]]
|
|
// CHECK: [[BB_FALSE]]: {
|
|
// CHECK-NEXT: _0 = const 0
|
|
// CHECK: [[BB_TRUE]]: {
|
|
// CHECK-NEXT: _0 = const 1
|
|
// CHECK-NEXT: goto
|
|
// CHECK-NEXT: }
|
|
|
|
if true { 1 } else { 0 }
|
|
}
|
|
|
|
fn main() {}
|