[llvm-dev] Comparing Clang and GCC: only clang stores updated value in each iteration.
Friedman, Eli via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 20 12:34:43 PDT 2018
On 9/20/2018 6:52 AM, Jonas Paulsson via llvm-dev wrote:
> Hi,
>
> I have a benchmark (mcf) that is currently slower when compiled with
> clang compared to gcc 8 (~10%). It seems that a hot loop has a few
> differences, where one interesting one is that while clang stores an
> incremented value in each iteration, gcc waits and just stores the
> final value just once after the loop. The value is a global variable.
>
> I wonder if this is something clang does not do per default but can be
> activated, similarly to the fp-contract situation?
>
> If not, is this a deficiency in clang? What pass should handle this?
> IndVarSimplify?
See http://lists.llvm.org/pipermail/llvm-dev/2018-September/126064.html .
>
> I have made a reduced test case which shows the same difference
> between the compilers: clang adds 1 and stores it back to 'a' in each
> iteration, while gcc instead figures out the value a has after the
> loop (0) and stores it then once to 'a'.
Your testcase is a bit weird because the condition of the while loop is
the same as the condition of the if statement. Is that really what the
original loop looks like?
-Eli
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-dev
mailing list