[PATCH] Enable ExitValue rewrite only when expansion cost is low.

Wei Mi wmi at google.com
Fri May 15 13:57:01 PDT 2015


Hi qcolombet, hfinkel, atrick,

The patch is to enable ExitValue rewrite (In IndVarSimplify pass) only when the cost of expansion is low, just like LinearFunctionTestReplace does right now. The problem is described in https://llvm.org/bugs/show_bug.cgi?id=23538.

It includes these changes:
1. Add an option. -replexitval=cheap is the default.
  -replexitval      - Choose the strategy to replace exit value in IndVarSimplify
    =never          -   never replace exit value
    =cheap          -   only replace exit value when the cost is cheap
    =always         -   always replace exit value whenever possible

2. The existing logic of SCEVExpander::isHighCostExpansionHelper is problematic. It cannot find out the udiv operator inside SCEVNAryExpr other than SCEVAddExpr. It doesn't check the sub SCEV inside SCEVTruncateExpr/SCEVZeroExtendExpr/SCEVSignExtendExpr. Like the SCEV: (-12 + (-12 * ((-12 + %len) /u 12)) + %len), SCEVExpander::isHighCostExpansionHelper will return false for it now. Fix the logic.

The patch improved an internal benchmark by 10%. It improved bzip2 in spec2000 by 1%.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9800

Files:
  lib/Analysis/ScalarEvolutionExpander.cpp
  lib/Transforms/Scalar/IndVarSimplify.cpp
  test/Transforms/IndVarSimplify/exit_value_test2.ll
  test/Transforms/IndVarSimplify/exit_value_tests.ll
  test/Transforms/IndVarSimplify/lcssa-preservation.ll
  test/Transforms/IndVarSimplify/loop_evaluate_1.ll
  test/Transforms/IndVarSimplify/loop_evaluate_6.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9800.25880.patch
Type: text/x-patch
Size: 8459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150515/141d6907/attachment.bin>


More information about the llvm-commits mailing list