[llvm-dev] Condition removed? Difference between LLVM and GCC on a small testcase

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 1 15:53:55 PST 2019


On Fri, 1 Mar 2019 at 14:38, Yan Luo via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I have a very simple testcase, which shows strange difference between LLVM and GCC. Does anyone know which optimization pass removes the condition?

SimplifyCFG converts branching conditions into equivalents with the
LLVM "select" instruction (think cmov on x86), and then CSE (common
subexpression elimination) removes the select entirely on the grounds
that the other branch is undefined (it could in principle be anything,
so a*51 or a*58 is as good a value as any to assume).

Cheers.

Tim.


More information about the llvm-dev mailing list