Skip to content

Commit ac32705

Browse files
committed
[InstCombine] Mark as unknown the branch weights of packed integer selecting shifts
1 parent 8ce46b2 commit ac32705

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
470470
Value *simplifyNonNullOperand(Value *V, bool HasDereferenceable,
471471
unsigned Depth = 0);
472472

473+
public:
473474
/// Create `select C, S1, S2` and copy metadata from MDFrom.
474475
SelectInst *createSelectInst(Value *C, Value *S1, Value *S2,
475476
const Instruction &MDFrom,
@@ -490,7 +491,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
490491
return Sel;
491492
}
492493

493-
public:
494494
/// Create and insert the idiom we use to indicate a block is unreachable
495495
/// without having to rewrite the CFG from within InstCombine.
496496
void CreateNonTerminatorUnreachable(Instruction *InsertAt) {

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/IR/GetElementPtrTypeIterator.h"
1717
#include "llvm/IR/IntrinsicInst.h"
1818
#include "llvm/IR/PatternMatch.h"
19+
#include "llvm/IR/ProfDataUtils.h"
1920
#include "llvm/Support/KnownBits.h"
2021
#include "llvm/Transforms/InstCombine/InstCombiner.h"
2122

@@ -107,7 +108,10 @@ static Value *simplifyShiftSelectingPackedElement(Instruction *I,
107108
Value *ShrAmtZ =
108109
IC.Builder.CreateICmpEQ(ShrAmt, Constant::getNullValue(ShrAmt->getType()),
109110
ShrAmt->getName() + ".z");
110-
Value *Select = IC.Builder.CreateSelect(ShrAmtZ, Lower, Upper);
111+
// There is no existing !prof metadata we can derive the !prof metadata for
112+
// this select.
113+
Value *Select = IC.createSelectInstWithUnknownProfile(ShrAmtZ, Lower, Upper);
114+
IC.Builder.Insert(Select);
111115
Select->takeName(I);
112116
return Select;
113117
}

0 commit comments

Comments
 (0)