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

Cannot lower "icmp uge <4 x i32> zeroinitializer, ..." for ARMv7 #58514

Closed
aaronpuchert opened this issue Oct 21, 2022 · 5 comments
Closed

Cannot lower "icmp uge <4 x i32> zeroinitializer, ..." for ARMv7 #58514

aaronpuchert opened this issue Oct 21, 2022 · 5 comments

Comments

@aaronpuchert
Copy link
Member

This is reduced from a larger file:

define <4 x i32> @vcmpz(<4 x i32> %0) {
  %2 = icmp uge <4 x i32> zeroinitializer, %0
  %3 = sext <4 x i1> %2 to <4 x i32>
  ret <4 x i32> %3
}

Compilation with llc -O2 -march=arm --float-abi=hard -mattr=+armv7-a fails with:

LLVM ERROR: Cannot select: t17: v4i32 = ARMISD::VCMPZ t3, Constant:i32<2>
  t3: v4i32 = bitcast t2
    t2: v2f64,ch = CopyFromReg t0, Register:v2f64 %0
      t1: v2f64 = Register %0
  t16: i32 = Constant<2>

The larger file had a more complex tree, but I think it boils down to the VCMPZ. Other comparisons are not (necessarily) an issue, e.g. for the opposite icmp ult we get

        vceq.i32        q8, q0, #0
        vmvn    q0, q8
        bx      lr
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 21, 2022

@llvm/issue-subscribers-backend-arm

@davemgreen
Copy link
Collaborator

The backend is probably assuming that %2 = icmp uge <4 x i32> zeroinitializer, %0 has been simplified into %2 = icmp eq <4 x i32> %0, zeroinitializer, but that is not always reliably done.

There is a fix in https://reviews.llvm.org/D136447

@Vogtinator
Copy link

That fits.

This particular failure was caused by Mesa not doing optimization passes with LLVM 15: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19217

With the instcombine pass the selection failure is gone.

For completeness, the downstream bug report: http://bugzilla.opensuse.org/show_bug.cgi?id=1204267

@davemgreen
Copy link
Collaborator

I see. Makes sense.

FYI, You likely don't need instsimplify, instcombine should be a super-set of it. But from the look of "After:" in the PR I don't see instsimplify running between PromotePass and InstCombinePass anyway.

@aaronpuchert
Copy link
Member Author

This particular failure was caused by Mesa not doing optimization passes with LLVM 15

Adding optimizations could make it disappear, but backends should be able to lower non-optimized code.

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Oct 29, 2022
https://build.opensuse.org/request/show/1031948
by user aaronpuchert + dimstar_suse
- Update to version 15.0.3.
  * This release contains bug-fixes for the LLVM 15.0.0 release.
    This release is API and ABI compatible with 15.0.0.
- Add llvm-armv7-fix-vector-compare-with-zero-lowering.patch: Fix
  lowering of non-canonical vector comparison with zero on armv7,
  preventing a crash (boo#1204267, gh#llvm/llvm-project#58514).
- Add lldb-swig-4.1.0-build-fix.patch: Fix build with Swig 4.1.0.
- Rebase llvm-do-not-install-static-libraries.patch.
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

4 participants