[LLVMdev] Invalid comparison instruction generation

Villmow, Micah Micah.Villmow at amd.com
Mon Nov 10 15:06:35 PST 2008


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>


More information about the llvm-dev mailing list