[NFC][POWER] add Pre-Commit test case for Inefficient std::bit_floor(x) - #183363
Conversation
|
@llvm/pr-subscribers-backend-powerpc Author: zhijian lin (diggerlin) Changesadd a pre-commit test case for Inefficient asm of std::bit_floor(x) for powerpc. Full diff: https://github.com/llvm/llvm-project/pull/183363.diff 1 Files Affected:
diff --git a/llvm/test/CodeGen/PowerPC/bit_floor.ll b/llvm/test/CodeGen/PowerPC/bit_floor.ll
new file mode 100644
index 0000000000000..9d316924c2d3e
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/bit_floor.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=powerpc-ibm-aix-xcoff -ppc-asm-full-reg-names < %s | FileCheck --check-prefix=AIX32 %s
+; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-asm-full-reg-names < %s | FileCheck --check-prefixes=COMM64,AIX64 %s
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-asm-full-reg-names < %s | FileCheck --check-prefixes=COMM64,LNX64 %s
+
+define noundef range(i32 0, -2147483647) i32 @_Z10bitfloor32j(i32 noundef %x) local_unnamed_addr {
+; AIX32-LABEL: _Z10bitfloor32j:
+; AIX32: # %bb.0: # %entry
+; AIX32-NEXT: cntlzw r4, r3
+; AIX32-NEXT: lis r5, -32768
+; AIX32-NEXT: cmplwi r3, 0
+; AIX32-NEXT: srw r4, r5, r4
+; AIX32-NEXT: iseleq r3, 0, r4
+; AIX32-NEXT: blr
+;
+; COMM64-LABEL: _Z10bitfloor32j:
+; COMM64: # %bb.0: # %entry
+; COMM64-NEXT: cntlzw r4, r3
+; AIX64-NEXT: lis r5, -32768
+; AIX64-NEXT: cmplwi r3, 0
+; LNX64-NEXT: cmplwi r3, 0
+; LNX64-NEXT: lis r5, -32768
+; COMM64-NEXT: srw r4, r5, r4
+; COMM64-NEXT: iseleq r3, 0, r4
+; COMM64-NEXT: blr
+entry:
+ %cmp.i = icmp eq i32 %x, 0
+ %0 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %x, i1 true)
+ %shl.i = lshr exact i32 -2147483648, %0
+ %cond.i = select i1 %cmp.i, i32 0, i32 %shl.i
+ ret i32 %cond.i
+}
+
+declare i32 @llvm.ctlz.i32(i32, i1 immarg)
+
+define noundef range(i64 0, -9223372036854775807) i64 @_Z10bitfloor64y(i64 noundef %x) local_unnamed_addr {
+; AIX32-LABEL: _Z10bitfloor64y:
+; AIX32: # %bb.0: # %entry
+; AIX32-NEXT: cntlzw r6, r4
+; AIX32-NEXT: cntlzw r5, r3
+; AIX32-NEXT: lis r7, -32768
+; AIX32-NEXT: cmplwi r3, 0
+; AIX32-NEXT: addi r6, r6, 32
+; AIX32-NEXT: iseleq r5, r6, r5
+; AIX32-NEXT: or. r3, r4, r3
+; AIX32-NEXT: addi r6, r5, -32
+; AIX32-NEXT: subfic r8, r5, 32
+; AIX32-NEXT: srw r5, r7, r5
+; AIX32-NEXT: srw r6, r7, r6
+; AIX32-NEXT: slw r8, r7, r8
+; AIX32-NEXT: or r3, r8, r6
+; AIX32-NEXT: iseleq r4, 0, r3
+; AIX32-NEXT: iseleq r3, 0, r5
+; AIX32-NEXT: blr
+;
+; COMM64-LABEL: _Z10bitfloor64y:
+; COMM64: # %bb.0: # %entry
+; COMM64-NEXT: li r5, 1
+; COMM64-NEXT: cntlzd r4, r3
+; COMM64-NEXT: cmpldi r3, 0
+; COMM64-NEXT: rldic r5, r5, 63, 0
+; COMM64-NEXT: srd r4, r5, r4
+; COMM64-NEXT: iseleq r3, 0, r4
+; COMM64-NEXT: blr
+
+entry:
+ %cmp.i = icmp eq i64 %x, 0
+ %0 = tail call range(i64 0, 65) i64 @llvm.ctlz.i64(i64 %x, i1 true)
+ %shl.i = lshr exact i64 -9223372036854775808, %0
+ %cond.i = select i1 %cmp.i, i64 0, i64 %shl.i
+ ret i64 %cond.i
+}
+
+declare i64 @llvm.ctlz.i64(i64, i1 immarg)
+
|
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
| @@ -0,0 +1,75 @@ | |||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | |||
| ; RUN: llc -mtriple=powerpc-ibm-aix-xcoff -ppc-asm-full-reg-names < %s | FileCheck --check-prefix=AIX32 %s | |||
| ; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-asm-full-reg-names < %s | FileCheck --check-prefixes=COMM64,AIX64 %s | |||
There was a problem hiding this comment.
nit: I understand this make things smaller and seems neater --check-prefixes=COMM64,AIX64 but I think in general it's best to use the tool to auto generate the checks if possible. Easier to maintain.
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/177/builds/30118 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/37561 Here is the relevant piece of the build log for the reference |
…x) (llvm#183363) add a pre-commit test case for Inefficient asm of std::bit_floor(x) for powerpc.
add a pre-commit test case for Inefficient asm of std::bit_floor(x) for powerpc.