[llvm] [DAGCombine] Propagate truncate to operands (PR #98666)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 16:40:44 PDT 2024


================
@@ -5797,7 +5797,7 @@ SDValue DAGCombiner::hoistLogicOpWithSameOpcodeHands(SDNode *N) {
   }
 
   // logic_op (truncate x), (truncate y) --> truncate (logic_op x, y)
-  if (HandOpcode == ISD::TRUNCATE) {
+  if (HandOpcode == ISD::TRUNCATE && !TLI.shouldReduceRegisterPressure()) {
----------------
justinfargnoli wrote:

I've added a comment. 

I added support for `TLI.isTruncateFree(EVT, EVT)`. 

I'm holding off on implementing `TLI.ZExtFree()` because it isn't necessary for this optimization. 

https://github.com/llvm/llvm-project/pull/98666


More information about the llvm-commits mailing list