[llvm] [GlobalIsel] Combine logic of icmps (PR #77855)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 07:17:48 PST 2024


================
@@ -635,19 +635,7 @@ define i64 @select_noccmp1(i64 %v1, i64 %v2, i64 %v3, i64 %r) {
 ;
 ; GISEL-LABEL: select_noccmp1:
 ; GISEL:       ; %bb.0:
-; GISEL-NEXT:    cmp x0, #0
-; GISEL-NEXT:    cset w8, lt
-; GISEL-NEXT:    cmp x0, #13
-; GISEL-NEXT:    cset w9, gt
-; GISEL-NEXT:    cmp x2, #2
-; GISEL-NEXT:    cset w10, lt
-; GISEL-NEXT:    cmp x2, #4
-; GISEL-NEXT:    cset w11, gt
-; GISEL-NEXT:    and w8, w8, w9
-; GISEL-NEXT:    and w9, w10, w11
-; GISEL-NEXT:    orr w8, w8, w9
-; GISEL-NEXT:    tst w8, #0x1
-; GISEL-NEXT:    csel x0, xzr, x3, ne
+; GISEL-NEXT:    mov x0, x3
----------------
tschuett wrote:

`%and0 = and i1 %c0, %c1` ought to be false.
```
 %c0 = icmp slt i64 %v1, 0
  %c1 = icmp sgt i64 %v1, 13
```
less than 0 and larger 13 is false.
```
 %c2 = icmp slt i64 %v3, 2
  %c4 = icmp sgt i64 %v3, 4
```
less than 2 and greater than 4 is false.

```
 %or = or i1 %and0, %and1
```
It is or of 0 and 0.
The condition of the select is 0.

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


More information about the llvm-commits mailing list