[LLVMdev] Invalid comparison instruction generation
Micah.Villmow at amd.com
Tue Nov 11 08:29:19 PST 2008
Thanks for clearing this up. For some reason the xor is not being
propagated through my backend and I need to figure out why. I'll look
into the files mentioned and see if I can get llvm to do what I need.
Thanks as always,
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
On Behalf Of Eli Friedman
Sent: Monday, November 10, 2008 5:35 PM
To: LLVM Developers Mailing List
Subject: Re: [LLVMdev] Invalid comparison instruction generation
On Mon, Nov 10, 2008 at 5:00 PM, Villmow, Micah <Micah.Villmow at amd.com>
> Using the variables from the original IR,
> assuming tmp == tmp1 and assume the value is not nan
> ogt(tmp, tmp1) is !isnan(tmp) && !isnan(tmp1) && tmp > tmp1, or false
> ule(tmp, tmp1) is isnan(tmp) || isnan(tmp1) || tmp <= tmp1, or true
Correct; in fact, ogt and ule are exact opposites.
> So, this is invalid, or am I misunderstanding what ogt and ule stand
What you're missing is the xor in the pre-combine graph; I assume it
got added during branch lowering.
> Assuming this is valid, why convert comparison instructions instead of
> just passing them through as they originally exist? The backend I am
> targeting does not support all comparison instructions and trying to
> guess which instruction LLVM converted the current comparison
> instruction from and then converting to a supported instruction is not
> as simple as it can be.
It's not a matter of guessing... you need to able to support all of
the possible comparisons, since they can be introduced by optimizers
at multiple levels.
> For example, I need to convert all ogt instructions to an olt
> instruction with LHS and RHS swapped, but since ogt is converted to
> do I convert all ule into olt and swap?
The existing legalization infrastructure for condition codes is in
SelectionDAGLegalize::LegalizeSetCCCondCode. If this isn't flexible
enough, you might need to modify it a bit. You should be able to just
do something like "setCondCodeAction(ISD::SETOGT, MVT::f64, Expand);"
for the unsupported comparisons, and let Legalize should take care of
Oh, and it looks like there's a legitimate bug in
DAGCombiner::visitXOR: it needs to check whether condition codes are
legal before transforming them.
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev