[llvm] Added ROLW/RORW/SLLW/SRAW/SRLW for canCreateUndefOrPoisonForTargetNode (PR #152609)

Jasmine Tang via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 15:59:11 PDT 2025


https://github.com/badumbatish created https://github.com/llvm/llvm-project/pull/152609

Fixes https://github.com/llvm/llvm-project/issues/149285.



>From 0dc3ad67b588d8b9cacdc5ad0fe111110e128239 Mon Sep 17 00:00:00 2001
From: Jasmine Tang <jjasmine at igalia.com>
Date: Wed, 6 Aug 2025 13:51:53 -0700
Subject: [PATCH] Added  ROLW/RORW + SLLW/SRAW/SRLW for
 canCreateUndefOrPoisonForTargetNode

---
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index adbfbeb4669e7..d86ec003459d3 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -21477,6 +21477,14 @@ bool RISCVTargetLowering::canCreateUndefOrPoisonForTargetNode(
 
   // TODO: Add more target nodes.
   switch (Op.getOpcode()) {
+  case RISCVISD::SLLW:
+  case RISCVISD::SRAW:
+  case RISCVISD::SRLW:
+  case RISCVISD::RORW:
+  case RISCVISD::ROLW:
+    // Only the lower 5 bits of RHS are read, guaranteeing the rotate/shift
+    // amount is bounds.
+    return false;
   case RISCVISD::SELECT_CC:
     // Integer select_cc cannot create poison.
     // TODO: What are the FP poison semantics?



More information about the llvm-commits mailing list