[llvm] [SelectionDAG] Fixup type usage of CondCodeAction table (PR #116082)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 09:01:06 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Alex MacLean (AlexMaclean)
<details>
<summary>Changes</summary>
Ensure that all uses of CondCodeAction table are checking the compared types, not the produced type. This is a prerequisite to landing https://github.com/llvm/llvm-project/pull/115035
---
Full diff: https://github.com/llvm/llvm-project/pull/116082.diff
2 Files Affected:
- (modified) llvm/include/llvm/CodeGen/TargetLowering.h (+4-3)
- (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (+2-2)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index e0b638201a0474..b0cda386e8ac0c 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -1618,13 +1618,14 @@ class TargetLoweringBase {
return Action;
}
- /// Return true if the specified condition code is legal on this target.
+ /// Return true if the specified condition code is legal for a comparison of
+ /// the specified types on this target.
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const {
return getCondCodeAction(CC, VT) == Legal;
}
- /// Return true if the specified condition code is legal or custom on this
- /// target.
+ /// Return true if the specified condition code is legal or custom for a
+ /// comparison of on this target.
bool isCondCodeLegalOrCustom(ISD::CondCode CC, MVT VT) const {
return getCondCodeAction(CC, VT) == Legal ||
getCondCodeAction(CC, VT) == Custom;
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 8287565336b54d..307461cd735e83 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -4975,7 +4975,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
APInt C = C1 - 1;
ISD::CondCode NewCC = (Cond == ISD::SETGE) ? ISD::SETGT : ISD::SETUGT;
if ((DCI.isBeforeLegalizeOps() ||
- isCondCodeLegal(NewCC, VT.getSimpleVT())) &&
+ isCondCodeLegal(NewCC, OpVT.getSimpleVT())) &&
(!N1C->isOpaque() || (C.getBitWidth() <= 64 &&
isLegalICmpImmediate(C.getSExtValue())))) {
return DAG.getSetCC(dl, VT, N0,
@@ -4995,7 +4995,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
APInt C = C1 + 1;
ISD::CondCode NewCC = (Cond == ISD::SETLE) ? ISD::SETLT : ISD::SETULT;
if ((DCI.isBeforeLegalizeOps() ||
- isCondCodeLegal(NewCC, VT.getSimpleVT())) &&
+ isCondCodeLegal(NewCC, OpVT.getSimpleVT())) &&
(!N1C->isOpaque() || (C.getBitWidth() <= 64 &&
isLegalICmpImmediate(C.getSExtValue())))) {
return DAG.getSetCC(dl, VT, N0,
``````````
</details>
https://github.com/llvm/llvm-project/pull/116082
More information about the llvm-commits
mailing list