[PATCH] D104022: [llvm-stress] Fix dead code preventing us generating per-element vector selects
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 10 04:50:50 PDT 2021
RKSimon created this revision.
RKSimon added reviewers: chandlerc, craig.topper, lebedev.ri, mehdi_amini, jyknight.
RKSimon requested review of this revision.
Herald added a project: LLVM.
This has been reported several times by the PVS Studio team as well as coming up in some static analysis.
getRandom() % 1 always returns 0 so we never actually test this codepath, (git blame suggests this has always been like this) - given that we have plenty of other "getRandom() & 1" the typo is pretty obvious, and matches the intention in the comment above - with this change we generate a nice mixture of scalar/vector condition selects of vectors.
I don't know llvm-stress that well - but I don't think we guarantee that the same seed value will always generate the same IR for later versions of the program - just that the same binary would.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104022
Files:
llvm/tools/llvm-stress/llvm-stress.cpp
Index: llvm/tools/llvm-stress/llvm-stress.cpp
===================================================================
--- llvm/tools/llvm-stress/llvm-stress.cpp
+++ llvm/tools/llvm-stress/llvm-stress.cpp
@@ -632,7 +632,7 @@
// If the value type is a vector, and we allow vector select, then in 50%
// of the cases generate a vector select.
- if (isa<FixedVectorType>(Val0->getType()) && (getRandom() % 1)) {
+ if (isa<FixedVectorType>(Val0->getType()) && (getRandom() & 1)) {
unsigned NumElem =
cast<FixedVectorType>(Val0->getType())->getNumElements();
CondTy = FixedVectorType::get(CondTy, NumElem);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104022.351130.patch
Type: text/x-patch
Size: 640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210610/9746c552/attachment.bin>
More information about the llvm-commits
mailing list