[llvm] [llvm][CodeGen] respect booleanVectorContents while UnrollVSETCC (NFC) (PR #97589)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 08:05:31 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Yingchi Long (inclyc)
<details>
<summary>Changes</summary>
This is an NFC change that focus fixing correctness of UnrollVSETCC. For historical reason this function assumes all targets setBooleanVectorContents to "ZeroOrNegativeOneBooleanContent". i.e. vector boolean values are "-1".
However this is not true for some targets, e.g. RISC-V, Sparc, VE, XCore, ARC...
Actually all these targets support native vector comparison. Thus it is no need to invoke this function and it is not coveraged by any test cases.
I'm not sure whether or not it is OK to submit such patch, but this does indeed fix potential miscompilation for furthur targets.
---
Full diff: https://github.com/llvm/llvm-project/pull/97589.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (+2-1)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
index 14b147cc5b01b..8b6fad684ba86 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -2016,7 +2016,8 @@ SDValue VectorLegalizer::UnrollVSETCC(SDNode *Node) {
TLI.getSetCCResultType(DAG.getDataLayout(),
*DAG.getContext(), TmpEltVT),
LHSElem, RHSElem, CC);
- Ops[i] = DAG.getSelect(dl, EltVT, Ops[i], DAG.getAllOnesConstant(dl, EltVT),
+ Ops[i] = DAG.getSelect(dl, EltVT, Ops[i],
+ DAG.getBoolConstant(true, dl, EltVT, VT),
DAG.getConstant(0, dl, EltVT));
}
return DAG.getBuildVector(VT, dl, Ops);
``````````
</details>
https://github.com/llvm/llvm-project/pull/97589
More information about the llvm-commits
mailing list