Skip to content

[RISCV] canCreateUndefOrPoisonForTargetNode - RISCVISD::SELECT_CC is only for integer comparisons which can't create poison #151943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025

Conversation

RKSimon
Copy link
Collaborator

@RKSimon RKSimon commented Aug 4, 2025

The result type is irrelevant - its the comparison type that matters

…'t create poison

The result type is irrelevant - its the comparison type that matters
@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Simon Pilgrim (RKSimon)

Changes

The result type is irrelevant - its the comparison type that matters


Full diff: https://github.com/llvm/llvm-project/pull/151943.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+4-5)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index b6d1ee8bc3050..9e1deea93b971 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -21478,11 +21478,10 @@ bool RISCVTargetLowering::canCreateUndefOrPoisonForTargetNode(
   // TODO: Add more target nodes.
   switch (Op.getOpcode()) {
   case RISCVISD::SELECT_CC:
-    // Integer select_cc cannot create poison.
-    // TODO: What are the FP poison semantics?
-    // TODO: This instruction blocks poison from the unselected operand, can
-    // we do anything with that?
-    return !Op.getValueType().isInteger();
+    // Integer comparisons cannot create poison.
+    assert(Op.getOperand(0).getValueType().isInteger() &&
+           "RISCVISD::SELECT_CC only compares integers");
+    return false;
   }
   return TargetLowering::canCreateUndefOrPoisonForTargetNode(
       Op, DemandedElts, DAG, PoisonOnly, ConsiderFlags, Depth);

@RKSimon RKSimon changed the title [RISCV] RISCVISD::SELECT_CC is for integer comparisons only which can't create poison [RISCV] RISCVISD::SELECT_CC is only for integer comparisons which can't create poison Aug 4, 2025
@RKSimon RKSimon changed the title [RISCV] RISCVISD::SELECT_CC is only for integer comparisons which can't create poison [RISCV] canCreateUndefOrPoisonForTargetNode - RISCVISD::SELECT_CC is only for integer comparisons which can't create poison Aug 4, 2025
Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RKSimon RKSimon merged commit f72c8dc into llvm:main Aug 4, 2025
11 checks passed
@RKSimon RKSimon deleted the riscv-selectcc-nopoison branch August 4, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants