[llvm] [InstCombine] Copy flags of extractelement for extelt -> icmp combine (PR #86366)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 23 04:06:23 PDT 2024
================
@@ -487,7 +487,9 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
// extelt (cmp X, Y), Index --> cmp (extelt X, Index), (extelt Y, Index)
Value *E0 = Builder.CreateExtractElement(X, Index);
Value *E1 = Builder.CreateExtractElement(Y, Index);
- return CmpInst::Create(cast<CmpInst>(SrcVec)->getOpcode(), Pred, E0, E1);
+ Instruction *SrcInst = cast<Instruction>(SrcVec);
+ return CmpInst::CreateWithCopiedFlags(cast<CmpInst>(SrcVec)->getOpcode(),
----------------
tschuett wrote:
You could pass `SrcInst->getOpcode()` as the first parameter to prevent the double cast.
https://github.com/llvm/llvm-project/pull/86366
More information about the llvm-commits
mailing list