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

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 15:08:29 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()) {
----------------
Artem-B wrote:

I'd add a comment describing why register pressure matters here (benefit of keeping arguments/result narrow outweighs an extra truncate op (which may be free in practice)

Speaking of which, NVPTX currently does not override  `TLI.isTruncateFree` and `TLI.isZExtFree`, and it probably should. For NVPTX zext/truncate between i32/i64 can probably be considered free, as the values already live in separate 32-bit registers in hardware.

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


More information about the llvm-commits mailing list