I have a simple program that generates correct intermediate
representation. However, when working on my backend, and my lowering
function gets called. The comparison operation is flipped via an invalid
transformation. i.e. gt ==> le, lt ==> ge etc..
define void @test_fc_if_gt(double %x, double %y, double addrspace(11)*
%result) {
entry:
        %x.addr = alloca double         ; <double*> [#uses=3]
        %y.addr = alloca double         ; <double*> [#uses=2]
        %result.addr = alloca double addrspace(11)*             ;
<double addrspace(11)**> [#uses=2]
        store double %x, double* %x.addr
        store double %y, double* %y.addr
        store double addrspace(11)* %result, double addrspace(11)**
%result.addr
        %tmp = load double* %x.addr             ; <double> [#uses=1]
        %tmp1 = load double* %y.addr            ; <double> [#uses=1]
        %cmp = fcmp ogt double %tmp, %tmp1              ; <i1> [#uses=1]
        br i1 %cmp, label %ifthen, label %ifend
 
ifthen:         ; preds = %entry
        %tmp2 = load double addrspace(11)** %result.addr
; <double addrspace(11)*> [#uses=1]
        %tmp3 = load double* %x.addr            ; <double> [#uses=1]
        store double %tmp3, double addrspace(11)* %tmp2
        br label %ifend
 
ifend:          ; preds = %ifthen, %entry
        ret void
}
 
 
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 been transformed into a ule.
 
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
have reproduced it with the x86 backend.
 
 
Micah Villmow
Systems Engineer
Advanced Technology & Performance
Advanced Micro Devices Inc.
4555 Great America Pkwy,
Santa Clara, CA. 95054
P: 408-572-6219
F: 408-572-6596
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20081110/0bf10a19/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: good-graph.dot
Type: application/octet-stream
Size: 8955 bytes
Desc: good-graph.dot
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20081110/0bf10a19/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad-graph.dot
Type: application/octet-stream
Size: 7503 bytes
Desc: bad-graph.dot
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20081110/0bf10a19/attachment-0001.obj>
On Mon, Nov 10, 2008 at 3:06 PM, Villmow, Micah <Micah.Villmow at amd.com> wrote:> 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 been > 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 have > reproduced it with the x86 backend.It seems valid to me... what makes you think it's invalid? -Eli
Eli, 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 for? 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? Thanks, Micah -----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> wrote:> With the above kernel run through llc with -march=x86 > -view-dag-combine1-dags I still see the ogt as the comparisonoperation, but> when I run it with llc -march=x86 -view-legalize-dags the ogt node hasbeen> 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 invalidtranslation of> comparison instructions? This problem affects my custom backend and Ihave> reproduced it with the x86 backend.It seems valid to me... what makes you think it's invalid? -Eli _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev