Page MenuHomePhabricator

[IndVarSimplify] Never sinking if none operand is used in or after loop exit block
Needs RevisionPublic

Authored by xjtuhu on Mar 22 2021, 11:10 PM.

Details

Summary

IndVarSimplify::sinkUnusedInvariants would sink a instruction from a loop's preheader block to exit block to reduce register pressure. But the optimization is not conservative, it could increase register pressure conversely if none operand is used in or after loop exit block, because sinking could extend operands' liveness range hence increase register pressure.

Diff Detail

Unit TestsFailed

TimeTest
30 msx64 debian > LLVM.Transforms/IndVarSimplify::pr24783.ll
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -S -indvars < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/pr24783.ll | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/pr24783.ll
40 msx64 debian > LLVM.Transforms/IndVarSimplify::pr39673.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -S -indvars -indvars-predicate-loops=0 < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/pr39673.ll | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/pr39673.ll
30 msx64 debian > LLVM.Transforms/IndVarSimplify::replace-loop-exit-folds.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -indvars -S -indvars-predicate-loops=0 < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/replace-loop-exit-folds.ll | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/replace-loop-exit-folds.ll
70 msx64 debian > LLVM.Transforms/IndVarSimplify::scev-expander-preserve-lcssa.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -aa-pipeline=basic-aa -passes=indvars,indvars -S -verify-loop-lcssa /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
30 msx64 debian > LLVM.Transforms/IndVarSimplify::sentinel.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -indvars -S < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/sentinel.ll | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/IndVarSimplify/sentinel.ll
View Full Test Results (18 Failed)

Event Timeline

xjtuhu created this revision.Mar 22 2021, 11:10 PM
xjtuhu requested review of this revision.Mar 22 2021, 11:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2021, 11:10 PM
lebedev.ri retitled this revision from Never sinking if none operand is used in or after loop exit block to [IndVarSimplify] Never sinking if none operand is used in or after loop exit block.Mar 23 2021, 12:39 AM

This looks pretty ad-hoc to me.
I believe we consider this to be a canonicalization transform that will be undone by other passes if profitable.

reames requested changes to this revision.Mar 23 2021, 9:52 AM

Change rejected. As Roman mentions, this is more of a canonicalization than an optimization. If you want to do actual scheduling, please use the MI layer.

p.s. The wording "If none operand is used" does not parse for me. I think I get the intent of the change, but I'd suggest rewording any future discussion of this.

This revision now requires changes to proceed.Mar 23 2021, 9:52 AM

OK, I see. Thanks for giving the advice!