about summary refs log tree commit diff
path: root/tests/mir-opt/optimize_none.rs
blob: a5b541bd2b62852e3c3f08855fe0d1440cf57eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//@ 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: switchInt(const true) -> [0: [[FALSE:bb[0-9]+]], otherwise: [[TRUE:bb[0-9]+]]];
    // CHECK-NEXT: }
    // CHECK: [[FALSE]]: {
    // CHECK-NEXT: _0 = const 0
    // CHECK-NEXT: goto
    // CHECK-NEXT: }
    // CHECK: [[TRUE]]: {
    // CHECK-NEXT: _0 = const 1
    // CHECK-NEXT: goto
    // CHECK-NEXT: }

    if true { 1 } else { 0 }
}

fn main() {}