| ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. |
| ;; RUN: wasm-opt %s --simplify-locals -S -o - | filecheck %s |
| |
| (module |
| ;; CHECK: (global $imm-glob i32 (i32.const 1234)) |
| (global $imm-glob i32 (i32.const 1234)) |
| |
| ;; CHECK: (global $mut-glob (mut i32) (i32.const 5678)) |
| (global $mut-glob (mut i32) (i32.const 5678)) |
| |
| ;; CHECK: (func $reorder-of-immmutable-global (result i32) |
| ;; CHECK-NEXT: (local $temp i32) |
| ;; CHECK-NEXT: (nop) |
| ;; CHECK-NEXT: (call $helper) |
| ;; CHECK-NEXT: (global.get $imm-glob) |
| ;; CHECK-NEXT: ) |
| (func $reorder-of-immmutable-global (result i32) |
| (local $temp i32) |
| ;; As the global is immutable, it cannot be modified in the call, and we can |
| ;; reorder here. |
| (local.set $temp |
| (global.get $imm-glob) |
| ) |
| (call $helper) |
| (local.get $temp) |
| ) |
| |
| ;; CHECK: (func $no-reorder-of-mutable-global (result i32) |
| ;; CHECK-NEXT: (local $temp i32) |
| ;; CHECK-NEXT: (local.set $temp |
| ;; CHECK-NEXT: (global.get $mut-glob) |
| ;; CHECK-NEXT: ) |
| ;; CHECK-NEXT: (call $helper) |
| ;; CHECK-NEXT: (local.get $temp) |
| ;; CHECK-NEXT: ) |
| (func $no-reorder-of-mutable-global (result i32) |
| (local $temp i32) |
| ;; As the global is mutable, it can be modified in the call, and we cannot |
| ;; reorder here. |
| (local.set $temp |
| (global.get $mut-glob) |
| ) |
| (call $helper) |
| (local.get $temp) |
| ) |
| |
| ;; CHECK: (func $helper |
| ;; CHECK-NEXT: (nop) |
| ;; CHECK-NEXT: ) |
| (func $helper) |
| ) |