[llvm] [CodeGenPrepare] Reverse the canonicalization of isInf/isNanOrInf (PR #81572)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 15 06:42:22 PDT 2024


================
@@ -99,12 +87,13 @@ entry:
 define zeroext i1 @abs_isinfornanf(float %x) {
 ; P8-LABEL: abs_isinfornanf:
 ; P8:       # %bb.0: # %entry
-; P8-NEXT:    addis 3, 2, .LCPI3_0 at toc@ha
-; P8-NEXT:    xsabsdp 0, 1
-; P8-NEXT:    lfs 1, .LCPI3_0 at toc@l(3)
-; P8-NEXT:    li 3, 1
-; P8-NEXT:    fcmpu 0, 0, 1
-; P8-NEXT:    isellt 3, 0, 3
+; P8-NEXT:    xscvdpspn 0, 1
+; P8-NEXT:    lis 4, 32639
+; P8-NEXT:    ori 4, 4, 65535
+; P8-NEXT:    mffprwz 3, 0
+; P8-NEXT:    clrlwi 3, 3, 1
+; P8-NEXT:    sub 3, 4, 3
+; P8-NEXT:    rldicl 3, 3, 1, 63
----------------
dtcxzyw wrote:

> This looks worse. The cost of expand for some compares isn't any more than legal operations, since it's just commuting.

Before:
```
Iterations:        100
Instructions:      600
Total Cycles:      1905
Total uOps:        1200

Dispatch Width:    8
uOps Per Cycle:    0.63
IPC:               0.31
Block RThroughput: 1.5
```

After:
```
Iterations:        100
Instructions:      700
Total Cycles:      614
Total uOps:        1400

Dispatch Width:    8
uOps Per Cycle:    2.28
IPC:               1.14
Block RThroughput: 1.8
```

It looks better :)


https://github.com/llvm/llvm-project/pull/81572


More information about the llvm-commits mailing list