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

[InstCombine] Missed optimization for icmp(constants[x]) when the range of x is implied #64238

Open
XChy opened this issue Jul 30, 2023 · 1 comment · May be fixed by #67093
Open

[InstCombine] Missed optimization for icmp(constants[x]) when the range of x is implied #64238

XChy opened this issue Jul 30, 2023 · 1 comment · May be fixed by #67093

Comments

@XChy
Copy link
Member

XChy commented Jul 30, 2023

@constant = constant [4 x i32] [i32 1, i32 2, i32 3, i32 4]

define i32 @src(i64 %x) local_unnamed_addr #0 {
entry:
    %cond = icmp ult i64 %x, 2
    br i1 %cond, label %case1, label %case2

case2:
    ret i32 789

case1:
    %isOK_ptr = getelementptr inbounds i32, ptr @constant, i64 %x
    %isOK = load i32, ptr %isOK_ptr, align 1
    %cond_inferred = icmp ult i32 %isOK, 5
    br i1 %cond_inferred, label %caseOK, label %caseErr

caseOK:
    ret i32 456

caseErr:
    ret i32 123
}

Here %cond_inferred should be always true.
Missed example
alive-tv

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

Successfully merging a pull request may close this issue.

1 participant