Skip to content

[ConstraintElim] icmp spred x, y implies icmp samesign upred x, y #120089

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
dtcxzyw opened this issue Dec 16, 2024 · 2 comments · Fixed by #128168
Closed

[ConstraintElim] icmp spred x, y implies icmp samesign upred x, y #120089

dtcxzyw opened this issue Dec 16, 2024 · 2 comments · Fixed by #128168

Comments

@dtcxzyw
Copy link
Member

dtcxzyw commented Dec 16, 2024

Alive2: https://alive2.llvm.org/ce/z/ZNNbj_

define i1 @src(i32 %x, i32 %y) {
entry:
  %cond = icmp sgt i32 %x, %y
  br i1 %cond, label %if.then, label %if.else

if.then:
  %cmp = icmp samesign ugt i32 %x, %y
  ret i1 %cmp

if.else:
  ret i1 false
}

define i1 @tgt(i32 %x, i32 %y) {
entry:
  %cond = icmp sgt i32 %x, %y
  br i1 %cond, label %if.then, label %if.else

if.then:
  ret i1 true

if.else:
  ret i1 false
}

We already perform similar optimizations in #115893.

@dtcxzyw
Copy link
Member Author

dtcxzyw commented Feb 5, 2025

Another case:

define i1 @_ZN17double_conversionL15FillFractionalsEmiiNS_6VectorIcEEPiS2_(i32 %exponent) {
entry:
  %cmp = icmp samesign ult i32 %exponent, 65
  br i1 %cmp, label %for.cond.preheader, label %if.else

for.cond.preheader:                               ; preds = %entry
  ret i1 false

if.else:                                          ; preds = %entry
  %cmp12.i = icmp samesign ugt i32 %exponent, -65
  ret i1 %cmp12.i
}

@fhahn
Copy link
Contributor

fhahn commented Feb 6, 2025

cc @zjaffal @artagnon

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