[PATCH] D109149: [DAG] Fold select_cc setgt X, -1, C, ~C -> xor (ashr X, BW-1), C

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 2 09:18:55 PDT 2021


arsenm added inline comments.


================
Comment at: llvm/test/CodeGen/AMDGPU/select-constant-xor.ll:31-56
 define i32 @selecti64i32(i64 %a) {
 ; CHECK-LABEL: selecti64i32:
 ; CHECK:       ; %bb.0:
 ; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; CHECK-NEXT:    s_waitcnt_vscnt null, 0x0
-; CHECK-NEXT:    v_cmp_lt_i64_e32 vcc_lo, -1, v[0:1]
-; CHECK-NEXT:    v_bfrev_b32_e32 v2, -2
-; CHECK-NEXT:    v_cndmask_b32_e32 v0, 0x80000000, v2, vcc_lo
+; CHECK-NEXT:    v_ashrrev_i32_e32 v0, 31, v1
+; CHECK-NEXT:    v_xor_b32_e32 v0, 0x7fffffff, v0
----------------
dmgreen wrote:
> Do you mean one of these two tests? Are some of the instructions more costly than others?
This case is an improvement. The case I think would regress would swap out a 64-bit type for the compare, i.e.


```
  %c = icmp sgt i64 %a, -1
  %s = select i1 %c, i32 C, i32 -C
  ret i32 %s

```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109149/new/

https://reviews.llvm.org/D109149



More information about the llvm-commits mailing list