This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix the incorrect iterator inside peephole
ClosedPublic

Authored by steven.zhang on May 27 2018, 10:57 PM.

Details

Summary

Instruction selection will insert nodes into the underlying list after the root node and iterating will thereby miss it. We should NOT assume that, the root node is the last element in the DAG nodelist.

Diff Detail

Repository
rL LLVM

Event Timeline

steven.zhang created this revision.May 27 2018, 10:57 PM

I'll let Hal chime in here, but I'd prefer if we just refactor this code to use a range-for instead of this while loop (in all 3 cases).

Hi, Nemanjai, if change it to the rangefor, we will walk the DAG in the reverse order(begin() -> end()), which result in two case failed. CodeGen/PowerPC/cmpb.ll and CodeGen/PowerPC/cmpb-ppc32.ll. It seems that, our implementation has some dependent on how we walk the DAG.

hfinkel accepted this revision.May 28 2018, 8:31 PM

I'll let Hal chime in here, but I'd prefer if we just refactor this code to use a range-for instead of this while loop (in all 3 cases).

I would as well, but I don't think that we can here. The range over which we're iterating is being modified as we do it. In any case, if we're going to try to change this, I'd do it in two stages. First, this change (so we know that we're hitting everything). Then look at trying to simplify the iteration structure. This LGTM.

This revision is now accepted and ready to land.May 28 2018, 8:31 PM
This revision was automatically updated to reflect the committed changes.