[llvm-branch-commits] [SPARC] Promote i32 CTTZ when we have VIS3 (PR #135894)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 16 08:03:04 PDT 2025
================
@@ -1,70 +1,195 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=sparc -mcpu=v9 | FileCheck %s
+; RUN: llc < %s -mtriple=sparcv9 | FileCheck %s -check-prefix=V9
+; RUN: llc < %s -mtriple=sparcv9 -mattr=popc | FileCheck %s -check-prefix=POPC
+; RUN: llc < %s -mtriple=sparcv9 -mattr=vis3 | FileCheck %s -check-prefix=VIS3
-define i32 @f(i32 %x) {
-; CHECK-LABEL: f:
-; CHECK: .cfi_startproc
-; CHECK-NEXT: ! %bb.0: ! %entry
-; CHECK-NEXT: sub %g0, %o0, %o1
-; CHECK-NEXT: and %o0, %o1, %o1
-; CHECK-NEXT: sethi 122669, %o2
-; CHECK-NEXT: or %o2, 305, %o2
-; CHECK-NEXT: smul %o1, %o2, %o1
-; CHECK-NEXT: srl %o1, 27, %o1
-; CHECK-NEXT: sethi %hi(.LCPI0_0), %o2
-; CHECK-NEXT: add %o2, %lo(.LCPI0_0), %o2
-; CHECK-NEXT: ldub [%o2+%o1], %o1
-; CHECK-NEXT: cmp %o0, 0
-; CHECK-NEXT: move %icc, 0, %o1
-; CHECK-NEXT: retl
-; CHECK-NEXT: mov %o1, %o0
-entry:
- %0 = call i32 @llvm.cttz.i32(i32 %x, i1 true)
- %1 = icmp eq i32 %x, 0
- %2 = select i1 %1, i32 0, i32 %0
- %3 = trunc i32 %2 to i8
- %conv = zext i8 %3 to i32
- ret i32 %conv
+define i32 @i32_nopoison(i32 %x) nounwind {
+; V9-LABEL: i32_nopoison:
+; V9: ! %bb.0:
+; V9-NEXT: cmp %o0, 0
+; V9-NEXT: be %icc, .LBB0_2
+; V9-NEXT: nop
+; V9-NEXT: ! %bb.1: ! %cond.false
+; V9-NEXT: sub %g0, %o0, %o1
+; V9-NEXT: and %o0, %o1, %o0
+; V9-NEXT: sethi 122669, %o1
+; V9-NEXT: or %o1, 305, %o1
+; V9-NEXT: mulx %o0, %o1, %o0
+; V9-NEXT: srl %o0, 27, %o0
+; V9-NEXT: srl %o0, 0, %o0
+; V9-NEXT: sethi %h44(.LCPI0_0), %o1
+; V9-NEXT: add %o1, %m44(.LCPI0_0), %o1
+; V9-NEXT: sllx %o1, 12, %o1
+; V9-NEXT: add %o1, %l44(.LCPI0_0), %o1
+; V9-NEXT: retl
+; V9-NEXT: ldub [%o1+%o0], %o0
+; V9-NEXT: .LBB0_2:
+; V9-NEXT: retl
+; V9-NEXT: mov 32, %o0
----------------
koachan wrote:
So unfortunately setting CTTZ and/or CTTZ_ZERO_UNDEF to LibCall results in a crash like those:
```
LLVM ERROR: Cannot select: t3: i32 = cttz_zero_undef t2
t2: i32,ch = CopyFromReg t0, Register:i32 %0
t1: i32 = Register %0
In function: i32_nopoison
```
I'll just FIXME them for the time being, I think.
https://github.com/llvm/llvm-project/pull/135894
More information about the llvm-branch-commits
mailing list