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

Inlining misses some simple simplifications #5580

Closed
vicuna opened this issue Apr 9, 2012 · 1 comment
Closed

Inlining misses some simple simplifications #5580

vicuna opened this issue Apr 9, 2012 · 1 comment
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Apr 9, 2012

Original bug ID: 5580
Reporter: jfc
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2015-12-11T18:19:30Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86-64
OS: Linux
Version: 3.12.1
Target version: 4.01.0+dev
Fixed in version: 4.01.0+dev
Category: back end (clambda to assembly)
Monitored by: @hcarty

Bug description

Consider this program:

type t = False | True
let of_bool = function true -> True | false -> False
let x = of_bool true

x should be assigned the constant True but ocamlopt generates a runtime comparison (true != false) to decide the result of of_bool.

Closure.simplif_prim_pure receives the arguments

p = Pintcomp Cneq
approxs = [Value_constptr 1; Value_integer 0]

If both approximations were Value_integer the comparison would be simplified.
The function does not know how to compare a constptr and an integer.

If I change simplif_prim_pure to add a case matching [Value_constptr x; Value_integer y] similarly to [Value_integer x; Value_integer y] code generation improves. I don't understand the compiler well enough to know if that is the correct solution.

@vicuna
Copy link
Author

vicuna commented Jun 7, 2013

Comment author: @xavierleroy

Improved constant propagation in commit r13754. Will be in release 4.01.

@vicuna vicuna closed this as completed Dec 11, 2015
@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants