This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Prevent infinite loop in InstCombine of select statements
ClosedPublic

Authored by tpopp on Jan 18 2021, 2:41 PM.

Details

Summary

This fixes an issue where the RHS and LHS the comparison operation
creating the predicate were swapped back and forth forever.

Diff Detail

Event Timeline

tpopp created this revision.Jan 18 2021, 2:41 PM
tpopp requested review of this revision.Jan 18 2021, 2:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2021, 2:41 PM
tpopp added subscribers: lebedev.ri, spatel.
nikic accepted this revision.Jan 18 2021, 2:49 PM

LGTM

A test case would be nice of course, but with this kind of worklist order issue (select folded before icmp) it's always tricky.

This revision is now accepted and ready to land.Jan 18 2021, 2:49 PM
xbolva00 added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
1129

llvm patternmatch has m_ImmConstant :) check it

tpopp marked an inline comment as done.Jan 19 2021, 1:31 AM

I apologize, but I was not having any luck at creating a test case that wasn't constant folded away.

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
1129

Thank you for the pointer.

I apologize, but I was not having any luck at creating a test case that wasn't constant folded away.

Why create it? You already have a reproducer, right? Just reduce it.