[PATCH] D93850: [InstCombine] Rewrite (switch (zext X)) as (switch X).

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 28 12:05:21 PST 2020


lebedev.ri added a comment.

In D93850#2473044 <https://reviews.llvm.org/D93850#2473044>, @wecing wrote:

> @lebedev.ri , which "hook" did you mean?

The `shouldChangeType()`

> I think the existing fold is too aggressive.



> Please take a look at the example I gave in an earlier comment -- doing a less strict fold first gives GVN a chance to optimize the IR.

Could you please post a godbolt example showing *how* it GVN would optimize it? https://godbolt.org/z/cq5M5f
But that sounds like a GVN bug to me.

> When the new fold is triggered, the existing more aggressive fold would be triggered (if `NewWidth` happens to be a standard integer type, e.g. `i8`, so that `shouldChangeType()` returns true) the next time InstCombine gets executed.

Ah yes, sorry, so the example would already be optimized, just to a different width.
https://godbolt.org/z/37jMeM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93850



More information about the llvm-commits mailing list