Skip to content

Cannot optimize complex ge_u 0 out #7556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xuruiyang2002 opened this issue Apr 26, 2025 · 0 comments · May be fixed by #7557
Open

Cannot optimize complex ge_u 0 out #7556

xuruiyang2002 opened this issue Apr 26, 2025 · 0 comments · May be fixed by #7557

Comments

@xuruiyang2002
Copy link
Contributor

Given the following code:

(module
  (type $0 (func))
  (type $1 (func (param i32 i32) (result i32)))
  (type $2 (func (result i32)))
  (type $3 (func (param i32) (result i32)))
  (import "External" "external_function" (func $external_function (type $0)))
  (func $_start (type $3) (param $0 i32) (result i32)
    (local $1 i32) (local $2 i32)
    i32.const 0
    i32.load
    local.set $2
    local.get $1
    i32.const 0
    call $foo
    local.set $1
    local.get $1
    local.get $2
    i32.le_u
    if (result i32)
      i32.const 0
    else
      call $external_function
      i32.const 1
    end)
  (func $foo (type $1) (param $0 i32) (param $1 i32) (result i32)
    i32.const 0
    i32.const 0
    i32.store
    i32.const 0)
  (memory $0 258 258)
  (export "_start" (func $_start)))

wasm-opt (e6d02fa) -all -O3 cannot optimize the

   (i32.ge_u
    (i32.load
     (i32.const 0)
    )
    (block (result i32)
     (i32.store
      (i32.const 0)
      (i32.const 0)
     )
     (i32.const 0)
    )
   )

to one (while -all -O2 can)

It is already discussed in #7455 (complex lt_u 0). in contrast, this is complex ge_u 0. So fix this the way as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant