Skip to content

Commit 0f278a9

Browse files
committed
Use computeKnownBits.
1 parent 1e3b565 commit 0f278a9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Transforms/Scalar/EarlyCSE.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/ADT/Hashing.h"
1717
#include "llvm/ADT/STLExtras.h"
1818
#include "llvm/ADT/ScopedHashTable.h"
19+
#include "llvm/ADT/SetVector.h"
1920
#include "llvm/ADT/SmallVector.h"
2021
#include "llvm/ADT/Statistic.h"
2122
#include "llvm/Analysis/AssumptionCache.h"
@@ -1607,9 +1608,11 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
16071608
// load with.
16081609
if (Inst.hasMetadata(LLVMContext::MD_noundef)) {
16091610
if (auto *AlignMD = Inst.getMetadata(LLVMContext::MD_align)) {
1611+
Inst.setMetadata(LLVMContext::MD_align, nullptr);
16101612
auto *A = mdconst::extract<ConstantInt>(AlignMD->getOperand(0));
1611-
if (Op->getPointerAlignment(SQ.DL).value() % A->getZExtValue() !=
1612-
0) {
1613+
auto KB = computeKnownBits(Op, SQ.DL);
1614+
unsigned AlignFromKB = 1 << KB.countMinTrailingZeros();
1615+
if (AlignFromKB < A->getZExtValue()) {
16131616
IRBuilder B(&Inst);
16141617
B.CreateAlignmentAssumption(SQ.DL, Op, A);
16151618
}

0 commit comments

Comments
 (0)