Hal Finkel
2012-Oct-22 05:18 UTC
[LLVMdev] Self-referential instruction from jump threading
Hello, After investigating PR14133, I've discovered that jump threading can output self-referential instructions: %inc.us = add nsw i32 %inc.us, 1 At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this instruction causes BBVectorize to hang. Should I make BBVectorize ignore this kind of thing, on the assumption that it occurs only in unreachable (or otherwise dead) code, or should this be fixed at the source (in jump threading in this case)? Thanks again, Hal -- Hal Finkel Postdoctoral Appointee Leadership Computing Facility Argonne National Laboratory
Nick Lewycky
2012-Oct-22 09:25 UTC
[LLVMdev] Self-referential instruction from jump threading
Hal Finkel wrote:> Hello, > > After investigating PR14133, I've discovered that jump threading can output self-referential instructions: > %inc.us = add nsw i32 %inc.us, 1 > > At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this instruction causes BBVectorize to hang. Should I make BBVectorize ignore this kind of thing, on the assumption that it occurs only in unreachable (or otherwise dead) code, or should this be fixed at the source (in jump threading in this case)?The way to check whether it's valid is with the verifier. If jump threading were emitting that in a reachable block it would fail the verifier, in an unreachable block it would pass the verifier. Your pass gets to assume its input passes the verifier, and must produce output that does as well. That leads to the conclusion that if you see one of these in your input, then its parent block must be unreachable. Nick
Duncan Sands
2012-Oct-22 09:40 UTC
[LLVMdev] Self-referential instruction from jump threading
Hi Hal,> After investigating PR14133, I've discovered that jump threading can output self-referential instructions: > %inc.us = add nsw i32 %inc.us, 1such instructions are valid in unreachable basic blocks.> At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this instruction causes BBVectorize to hang. Should I make BBVectorize ignore this kind of thing, on the assumption that it occurs only in unreachable (or otherwise dead) code, or should this be fixed at the source (in jump threading in this case)?All such instructions are dead, as they always live in unreachable basic blocks, so there is no point in trying to optimize them. Ciao, Duncan.
Hal Finkel
2012-Oct-22 12:59 UTC
[LLVMdev] Self-referential instruction from jump threading
----- Original Message -----> From: "Duncan Sands" <baldrick at free.fr> > To: llvmdev at cs.uiuc.edu > Sent: Monday, October 22, 2012 4:40:50 AM > Subject: Re: [LLVMdev] Self-referential instruction from jump threading > > Hi Hal, > > > After investigating PR14133, I've discovered that jump threading > > can output self-referential instructions: > > %inc.us = add nsw i32 %inc.us, 1 > > such instructions are valid in unreachable basic blocks.Okay, thanks!> > > At least in the test case for that bug report, the relevant code is > > later deleted (perhaps it is unreachable), and so this does not > > cause a problem. Unfortunately, when vectorization is enabled, > > this instruction causes BBVectorize to hang. Should I make > > BBVectorize ignore this kind of thing, on the assumption that it > > occurs only in unreachable (or otherwise dead) code, or should > > this be fixed at the source (in jump threading in this case)? > > All such instructions are dead, as they always live in unreachable > basic blocks, > so there is no point in trying to optimize them.Fair enough. I'll change BBVectorize to ignore blocks for which isReachableFromEntry is false. -Hal> > Ciao, Duncan. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Postdoctoral Appointee Leadership Computing Facility Argonne National Laboratory
Hal Finkel
2012-Oct-22 13:01 UTC
[LLVMdev] Self-referential instruction from jump threading
----- Original Message -----> From: "Nick Lewycky" <nicholas at mxc.ca> > To: "Hal Finkel" <hfinkel at anl.gov> > Cc: llvmdev at cs.uiuc.edu > Sent: Monday, October 22, 2012 4:25:36 AM > Subject: Re: [LLVMdev] Self-referential instruction from jump threading > > Hal Finkel wrote: > > Hello, > > > > After investigating PR14133, I've discovered that jump threading > > can output self-referential instructions: > > %inc.us = add nsw i32 %inc.us, 1 > > > > At least in the test case for that bug report, the relevant code is > > later deleted (perhaps it is unreachable), and so this does not > > cause a problem. Unfortunately, when vectorization is enabled, > > this instruction causes BBVectorize to hang. Should I make > > BBVectorize ignore this kind of thing, on the assumption that it > > occurs only in unreachable (or otherwise dead) code, or should > > this be fixed at the source (in jump threading in this case)? > > The way to check whether it's valid is with the verifier. If jump > threading were emitting that in a reachable block it would fail the > verifier, in an unreachable block it would pass the verifier. Your > pass > gets to assume its input passes the verifier, and must produce output > that does as well. That leads to the conclusion that if you see one > of > these in your input, then its parent block must be unreachable.Makes sense, thanks! -Hal> > Nick >-- Hal Finkel Postdoctoral Appointee Leadership Computing Facility Argonne National Laboratory
Maybe Matching Threads
- [LLVMdev] Self-referential instruction from jump threading
- [LLVMdev] Self-referential instruction from jump threading
- [LLVMdev] Jump Theading/GVN bug - moving discussion to llvm-dev
- Self-Referential has_many :through
- [LLVMdev] Jump Theading/GVN bug - moving discussion to llvm-dev