Strange SetCond Behavior

Before I file a bug, I thought I'd check to make sure something hasn't
changed. Stacker used to work in 1.2, now it fails on six tests. All six
tests pertain to use of the SetLT, SetGT, SetLE, and SetGE SetCondInst.
In my test programs they all fail, regardless of the values.

The *only* thing I've done to Stacker is to change the base type
involved in the comparison from int to long. Is there something
"different" about the comparison of longs?

The code generated by Stacker Compiler is like:

setle long %11, %16 ; <bool>:0 [#uses=1]
cast bool %0 to long ; <long>:24 [#uses=1]
store long %24, long* %4

The value stored into %4 is later retrieved and compared against zero.
That test always fails if setle, setge, setlt, or setgt is used.
However, it works correctly for seteq, and setne!

Perhaps the cast from bool to long doesn't work the same as for bool
to int? Should it?

I've attached the full test program in case you want to investigate.

I'm going to try and reduce the test case because I suspect something
is broken in LLVM that only shows up in Stacker's usage. I'll let you
know what I find. Please let me know if the above sounds like a known
problem or usage issue.

Thanks,

Reid.

le.ll (5.74 KB)

testing.bc (832 Bytes)

Before I file a bug, I thought I'd check to make sure something hasn't
changed. Stacker used to work in 1.2, now it fails on six tests. All six
tests pertain to use of the SetLT, SetGT, SetLE, and SetGE SetCondInst.
In my test programs they all fail, regardless of the values.

The *only* thing I've done to Stacker is to change the base type
involved in the comparison from int to long. Is there something
"different" about the comparison of longs?

The code generated by Stacker Compiler is like:

setle long %11, %16 ; <bool>:0 [#uses=1]
cast bool %0 to long ; <long>:24 [#uses=1]
store long %24, long* %4

The value stored into %4 is later retrieved and compared against zero.
That test always fails if setle, setge, setlt, or setgt is used.
However, it works correctly for seteq, and setne!

That sounds like a bug. I'll look into it. I assume you are seeing this
problem with the X86 backend?

Perhaps the cast from bool to long doesn't work the same as for bool
to int? Should it?

Yes, you should get a long 0 or 1.

I'm going to try and reduce the test case because I suspect something
is broken in LLVM that only shows up in Stacker's usage. I'll let you
know what I find. Please let me know if the above sounds like a known
problem or usage issue.

Please do, I'll also try to some unit tests to make sure things are
working properly.

-Chris

That sounds like a bug. I'll look into it. I assume you are seeing this
problem with the X86 backend?

Yes.

> Perhaps the cast from bool to long doesn't work the same as for bool
> to int? Should it?

Yes, you should get a long 0 or 1.

That's what I thought.

Please do, I'll also try to some unit tests to make sure things are
working properly.

Working on it.

Bug 337 has been filed.

Here's the simplest test case I could find that reproduces the bug: