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

Failure to optimize based on umax implication #63896

Closed
nikic opened this issue Jul 16, 2023 · 1 comment
Closed

Failure to optimize based on umax implication #63896

nikic opened this issue Jul 16, 2023 · 1 comment

Comments

@nikic
Copy link
Contributor

nikic commented Jul 16, 2023

https://alive2.llvm.org/ce/z/o_8ch3

define i1 @src(i8 %x, i8 %y) {
  %max = call i8 @llvm.umax.i8(i8 %x, i8 1)
  %cmp = icmp ugt i8 %y, %max
  br i1 %cmp, label %if, label %end

if:
  %cmp2 = icmp ugt i8 %y, %x
  ret i1 %cmp2

end:
  ret i1 false
}

define i1 @tgt(i8 %x, i8 %y) {
  %max = call i8 @llvm.umax.i8(i8 %x, i8 1)
  %cmp = icmp ugt i8 %y, %max
  br i1 %cmp, label %if, label %end

if:
  ret i1 true

end:
  ret i1 false
}

declare i8 @llvm.umax.i8(i8, i8)

This might be either for ConstraintElimination or InstCombine.

For the case where icmp ugt i8 %y, 1 is used, CVP/LVI could also handle this.

@dtcxzyw
Copy link
Member

dtcxzyw commented Jul 16, 2023

Candidate patch https://reviews.llvm.org/D155412

dtcxzyw added a commit that referenced this issue Jul 24, 2023
This patch adds some test cases from #63896.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D155853
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 7, 2024
This patch adds some test cases from llvm/llvm-project#63896.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D155853
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 7, 2024
Fixes llvm/llvm-project#63896 and rust-lang/rust#113757.
This patch adds facts implied by llvm.smin/smax/umin/umax intrinsics.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D155412
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