Page MenuHomePhabricator

[LazyValueInfo] Let getEdgeValueLocal look into freeze instructions
Needs ReviewPublic

Authored by aqjune on Mon, Jul 27, 3:19 AM.

Details

Summary

This patch makes getEdgeValueLocal more precise when a freeze instruction is
given, by

  • Exploting the fact that a branch condition cannot be undef or poison
  • Adding support for freeze into constantFoldUser

Diff Detail

Unit TestsFailed

TimeTest
130 mslinux > Polly.ScopInfo::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; opt -polly-process-unprofitable -polly-remarks-minimal -polly-use-llvm-names -polly-import-jscop-dir=/mnt/disks/ssd0/agent/llvm-project/polly/test/ScopInfo -polly-codegen-verify -basic-aa -scoped-noalias -tbaa -polly-scops -analyze < /mnt/disks/ssd0/agent/llvm-project/polly/test/ScopInfo/memcpy-raw-source.ll

Event Timeline

aqjune created this revision.Mon, Jul 27, 3:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Jul 27, 3:19 AM

Which of the changes in the patch corresponds to each testcase?

nikic added inline comments.Mon, Jul 27, 12:09 PM
llvm/lib/Analysis/LazyValueInfo.cpp
1316

Wouldn't we expect such a freeze to get dropped by InstSimplify/InstCombine anyway?

efriedma added inline comments.Mon, Jul 27, 12:26 PM
llvm/lib/Analysis/LazyValueInfo.cpp
1316

You mean, we should rewrite uses of a freeze in blocks where we know the operand of the freeze can't be undef/poison? I guess that's something we should do. I don't think instsimplify has the context necessary to do that sort of rewrite.

nikic added inline comments.Mon, Jul 27, 12:58 PM
llvm/lib/Analysis/LazyValueInfo.cpp
1316

You're right, if there are multiple uses and only some are dominated by the condition we currently don't handle it in InstCombine. The @simple case from the test would be handled though, because the freeze gets sunk.

getEdgeValueLocal's change at if (BranchInst *BI ...) { .. } corresponds to the simple example.
For the switch example, if (SwitchInst *SI ...) { ... } branch calls constantFoldUser, which is newly updated.

llvm/lib/Analysis/LazyValueInfo.cpp
1316

Would it be the right direction if I implement this optimization in InstCombine instead?