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

Yan Luo via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 1 16:17:49 PST 2019


Tim,

Thanks for the reply! It makes sense that LLVM selects a*51 or a*58 for an undefined value although it makes the arguments to bar() "predictable".


Regards,
Yan  

-----Original Message-----
From: Tim Northover <t.p.northover at gmail.com> 
Sent: Friday, March 1, 2019 3:54 PM
To: Yan Luo <yan.luo2 at synopsys.com>
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] Condition removed? Difference between LLVM and GCC on a small testcase

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