https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122769

--- Comment #1 from Vineet Gupta <vineetg at gcc dot gnu.org> ---
This doesn't seem costing related as I've hacked branch_cost in generic tune
structure to absurd high number (16 vs. 4).

For the optim-OK case (1 << 62), ifcvt is able to do the transform via
noce_try_cond_zero_arith().
```
  (eq (reg:DI 141 [ _1 ])
    (const_int 0 [0]))
```

For the missed-optim case (1 << 63), the same call chain fails

noce_try_cond_zero_arith()
   noce_bbs_ok_for_cond_zero_arith()
     if (GET_CODE (cond) != NE && GET_CODE (cond) != EQ)

```
  (ge (reg/v:DI 137 [ val ])
    (const_int 0 [0]))
```

The fallthough noce_try_cmove_arith () tries to transform this as -1 based
which fails costing in canonicalize_comparison ()

```
IF-THEN-JOIN block found, pass 1, test 3, then 4, join 5
;; cmp: lt, old cst: (const_int 0 [0]) new cst: (const_int -1
[0xffffffffffffffff])
;; old cst cost: 0, new cst cost: 4
;; cmp: ge, old cst: (const_int 0 [0]) new cst: (const_int -1
[0xffffffffffffffff])
;; old cst cost: 0, new cst cost: 4
```

Reply via email to