[PATCH] D48278: [SelectionDAG] Fold redundant masking operations of shifted value

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 10 06:59:30 PDT 2018


spatel added a reviewer: efriedma.
spatel added a comment.

In https://reviews.llvm.org/D48278#1155803, @dnsampaio wrote:

> >> Ah, I see that now. But I'm not convinced this is the right approach. Why are we waiting to optimize this in the backend? This is a universally good optimization, so it should be in IR:
>
> Agree, I also intend to implement this transformation in the IR. But there are cases that this is only seen after some instructions have been combined in the dag, so why not here also? And indeed, it is a requirement for a future patch that detects opportunities to reduce load and store widths.


IMO, this is backwards, we optimize first in IR (because the sooner we can fold something like this, the more it helps later transforms). Then, only if there's reason to create redundancy (because the patterns emerge late) do we repeat a fold in the backend. Can you post a motivating example that would not be solved by IR transforms, so we can see why this is necessary for the DAG?


https://reviews.llvm.org/D48278





More information about the llvm-commits mailing list