Skip to content

[InstCombine] Commuted pattern is not handled #121701

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 Jan 5, 2025 · 0 comments · Fixed by #121766
Closed

[InstCombine] Commuted pattern is not handled #121701

dtcxzyw opened this issue Jan 5, 2025 · 0 comments · Fixed by #121766

Comments

@dtcxzyw
Copy link
Member

dtcxzyw commented Jan 5, 2025

https://godbolt.org/z/5bh5v8Tn6

define i1 @no_masks_with_logical_or1(i32 %a, i32 %b, i32 noundef %c) {
  %cmp1 = icmp ne i32 %a, 0
  %cmp2 = icmp ne i32 %b, 63
  %or1 = select i1 %cmp1, i1 true, i1 %cmp2
  %cmp3 = icmp ne i32 %c, 0
  %or2 = or i1 %or1, %cmp3
  ret i1 %or2
}

define i1 @no_masks_with_logical_or2(i32 %a, i32 %b, i32 noundef %c) {
  %cmp1 = icmp ne i32 %a, 0
  %cmp2 = icmp ne i32 %b, 63
  %or1 = select i1 %cmp1, i1 true, i1 %cmp2
  %cmp3 = icmp ne i32 %c, 0
  %or2 = or i1 %cmp3, %or1
  ret i1 %or2
}
define i1 @no_masks_with_logical_or1(i32 %a, i32 %b, i32 noundef %c) {
  %cmp2 = icmp ne i32 %b, 63
  %1 = or i32 %a, %c
  %2 = icmp ne i32 %1, 0
  %or2 = select i1 %2, i1 true, i1 %cmp2
  ret i1 %or2
}

define i1 @no_masks_with_logical_or2(i32 %a, i32 %b, i32 noundef %c) {
  %cmp1 = icmp ne i32 %a, 0
  %cmp2 = icmp ne i32 %b, 63
  %or1 = select i1 %cmp1, i1 true, i1 %cmp2
  %cmp3 = icmp ne i32 %c, 0
  %or2 = or i1 %cmp3, %or1
  ret i1 %or2
}
@dtcxzyw dtcxzyw self-assigned this Jan 5, 2025
@dtcxzyw dtcxzyw closed this as completed in 4ebfd43 Jan 6, 2025
github-actions bot pushed a commit to arm/arm-toolchain that referenced this issue Jan 10, 2025
In llvm/llvm-project#116065, we pass `IsLogical`
into `foldBooleanAndOr` when folding inner and/or ops. But it is always
safe to treat them as bitwise if the outer ops are bitwise.

Alive2: https://alive2.llvm.org/ce/z/hULrgH
Closes llvm/llvm-project#121701.
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