[LLVMdev] Invalid comparison instruction generation

Villmow, Micah Micah.Villmow at amd.com
Mon Nov 10 17:00:59 PST 2008

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

So, this is invalid, or am I misunderstanding what ogt and ule stand

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.
For example, I need to convert all ogt instructions to an olt
instruction with LHS and RHS swapped, but since ogt is converted to ule,
do I convert all ule into olt and swap? 



-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
On Behalf Of Eli Friedman
Sent: Monday, November 10, 2008 4:38 PM
To: LLVM Developers Mailing List
Subject: Re: [LLVMdev] Invalid comparison instruction generation

On Mon, Nov 10, 2008 at 3:06 PM, Villmow, Micah <Micah.Villmow at amd.com>
> With the above kernel run through llc with -march=x86
> -view-dag-combine1-dags I still see the ogt as the comparison
operation, but
> when I run it with llc -march=x86 -view-legalize-dags the ogt node has
> transformed into a ule.

Okay... I can see that in the attached graph.

> So, my question is, how do I get llvm to stop doing invalid
translation of
> comparison instructions? This problem affects my custom backend and I
> reproduced it with the x86 backend.

It seems valid to me... what makes you think it's invalid?

LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu

More information about the llvm-dev mailing list