Skip to content

[ValueTracking] miscompile in samesign compare #124267

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

Closed
dianqk opened this issue Jan 24, 2025 · 0 comments · Fixed by #124271
Closed

[ValueTracking] miscompile in samesign compare #124267

dianqk opened this issue Jan 24, 2025 · 0 comments · Fixed by #124271

Comments

@dianqk
Copy link
Member

dianqk commented Jan 24, 2025

#122590 and #122700 miscompile the following code:

define i1 @src(i8 %L0, i8 %L1, i1 %V) {
  %LHS = icmp samesign ugt i8 %L0, %L1
  %R0 = sub nsw i8 %L0, %L1
  %RHS = icmp ult i8 %R0, -1
  br i1 %LHS, label %LHS_true, label %LHS_false

LHS_true:
  br label %EXIT

LHS_false:
  br label %EXIT

EXIT:
  %RET = phi i1 [ %RHS, %LHS_true ], [ %V, %LHS_false ]
  ret i1 %RET
}

%RHS should be 1: https://alive2.llvm.org/ce/z/RscAzy.

@dianqk dianqk self-assigned this Jan 24, 2025
dianqk added a commit that referenced this issue Jan 24, 2025
…atchingCmp` (#124271)

Fixes #124267.

Since we are using the new predicate, we should also update the
parameters of `isImpliedByMatchingCmp`.
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.

2 participants