Skip to content
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

BranchInliner is too aggressive for ternaries #8

Open
fehnomenal opened this issue Jun 2, 2019 · 0 comments
Open

BranchInliner is too aggressive for ternaries #8

fehnomenal opened this issue Jun 2, 2019 · 0 comments

Comments

@fehnomenal
Copy link

Running

function ao1(s)
    return s == "" and 1 or 2
end

function ao2(b)
    return b and 1 or 2
end

function ao3()
    return true and 1 or 2
end

function ao4()
    return false and 1 or 2
end

r1 = ao1("")
r2 = ao1("a")
r3 = ao2(true)
r4 = ao2(false)
r5 = ao3()
r6 = ao4()

results in the following

env.rawget("r1") = 1
env.rawget("r2") = false
env.rawget("r3") = 1
env.rawget("r4") = 2
env.rawget("r5") = 1
env.rawget("r6") = false

where I would expect (see also on https://www.lua.org/cgi-bin/demo)

env.rawget("r1") = 1
env.rawget("r2") = 2
env.rawget("r3") = 1
env.rawget("r4") = 2
env.rawget("r5") = 1
env.rawget("r6") = 2

This is exactly the result I get when I remove the call to the BranchInliner in the optimize method for IRFuncs.

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

No branches or pull requests

1 participant