On 11/18/17 12:16 AM, Jeff Law wrote: > You might wander a bit and see if/how cse handles other similar > circumstances. For example (not (not (x)) (neg (neg x)) and (bswap > (bswap (x))
I actually tried examples like that to see what CSE would do, but I could never come up with a test case, where those would survive until CSE. I suppose I could try disabling the optimizations that remove them before CSE to see what happens, but... > THe last would seem particularly interesting -- as a hack see if you can > generate a bswap instead of vec_select at expansion time, then see if > CSE is able to fix it up. Or perhaps set it as a REG_EQUAL note. > Again, it's a hack, but you just want to see if CSE can see the > equivalence if it's in a more common form. Though I'm not sure if BSWAP > is handled significantly better than an equivalence VEC_SELECT. ...the problem is that CSE only creates equivalences between two expressions when one is assigned to the other. It doesn't seem to look deeper into the expressions to try and find other equivalences, so even if we see A = (not (not (B))), the only equivalence it makes is that one. We don't get A is equivalent to B. Do you have any input on the following hunk, which seems to be an independent change to the rest of the patch? @@ -2640,7 +2699,7 @@ exp_equiv_p (const_rtx x, const_rtx y, i return 1; for (i = regno; i < endregno; i++) - if (REG_IN_TABLE (i) != REG_TICK (i)) + if (REG_IN_TABLE (i) != -1 && REG_IN_TABLE (i) != REG_TICK (i)) return 0; Peter