[PATCH] D76975: Make GVN aware of aligned_alloc
Uday Bondhugula via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 28 00:30:43 PDT 2020
bondhugula created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Make the GVN pass aware of aligned_alloc. There don't appear to be any
GVN test cases for malloc/alloca - this change is trivial and along the
same lines malloc/alloca are treated; a test case could be added when
it's added for the former.
Signed-off-by: Uday Bondhugula <uday at polymagelabs.com>
Depends on D76974 <https://reviews.llvm.org/D76974>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76975
Files:
llvm/lib/Transforms/Scalar/GVN.cpp
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -946,6 +946,7 @@
// Loading the allocation -> undef.
if (isa<AllocaInst>(DepInst) || isMallocLikeFn(DepInst, TLI) ||
+ isAlignedAllocLikeFn(DepInst, TLI) ||
// Loading immediately after lifetime begin -> undef.
isLifetimeStart(DepInst)) {
Res = AvailableValue::get(UndefValue::get(LI->getType()));
@@ -1450,7 +1451,7 @@
Value *LHS = Cmp->getOperand(0);
Value *RHS = Cmp->getOperand(1);
// If we can prove either side non-zero, then equality must imply
- // equivalence.
+ // equivalence.
// FIXME: We should do this optimization if 'no signed zeros' is
// applicable via an instruction-level fast-math-flag or some other
// indicator that relaxed FP semantics are being used.
@@ -1515,10 +1516,10 @@
// If we find an equality fact, canonicalize all dominated uses in this block
// to one of the two values. We heuristically choice the "oldest" of the
// two where age is determined by value number. (Note that propagateEquality
- // above handles the cross block case.)
- //
+ // above handles the cross block case.)
+ //
// Key case to cover are:
- // 1)
+ // 1)
// %cmp = fcmp oeq float 3.000000e+00, %0 ; const on lhs could happen
// call void @llvm.assume(i1 %cmp)
// ret float %0 ; will change it to ret float 3.000000e+00
@@ -1559,7 +1560,7 @@
<< *CmpLHS << " with "
<< *CmpRHS << " in block "
<< IntrinsicI->getParent()->getName() << "\n");
-
+
// Setup the replacement map - this handles uses within the same block
if (hasUsersIn(CmpLHS, IntrinsicI->getParent()))
@@ -1824,7 +1825,7 @@
bool GVN::replaceOperandsForInBlockEquality(Instruction *Instr) const {
bool Changed = false;
for (unsigned OpNum = 0; OpNum < Instr->getNumOperands(); ++OpNum) {
- Value *Operand = Instr->getOperand(OpNum);
+ Value *Operand = Instr->getOperand(OpNum);
auto it = ReplaceOperandsWithMap.find(Operand);
if (it != ReplaceOperandsWithMap.end()) {
LLVM_DEBUG(dbgs() << "GVN replacing: " << *Operand << " with "
@@ -1944,7 +1945,7 @@
// If "A == B" is known true, or "A != B" is known false, then replace
// A with B everywhere in the scope. For floating point operations, we
- // have to be careful since equality does not always imply equivalance.
+ // have to be careful since equality does not always imply equivalance.
if ((isKnownTrue && impliesEquivalanceIfTrue(Cmp)) ||
(isKnownFalse && impliesEquivalanceIfFalse(Cmp)))
Worklist.push_back(std::make_pair(Op0, Op1));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76975.253304.patch
Type: text/x-patch
Size: 2832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200328/6974b341/attachment.bin>
More information about the llvm-commits
mailing list