Skip to content

[LoopVectorize] Failure to compare multiple inputs as the same (splatted) value #62565

Closed
@RKSimon

Description

@RKSimon

Pulled out of a regression report on https://reviews.llvm.org/rGfed28ada47f5 / fed28ad

I haven't done a great job with reducing this - but this shows the effect - https://gcc.godbolt.org/z/5q36ExYqa - loop-vectorize creates the icmp ne <2 x i64> %24, undef and then instcombine simplifies it all - but I'm still not certain that LV is at fault or not @fhahn do you have any suggestions?

That's a very interesting case! It looks like this is indeed a LV miscompile. The issue is that we introduce multiple new uses of undef. The issue is that each use of undef could take different values, whereas the code we generate relies that we compare against the same value. See https://alive2.llvm.org/ce/z/osWdyX for Alive2 showing the issue (the input is a further reduced version of the test case)

I think we need to insert a freeze, then broadcast it to a vector and consistently use that in the generated code instead of undef: https://alive2.llvm.org/ce/z/HT7J6u. I can look into a patch for this

FTR this also is an issue for arbitrary inputs, not just poison/undef constants: https://alive2.llvm.org/ce/z/5BsKqY

CC @fhahn @alexfh

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorloopoptimmiscompilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions