escha via llvm-dev
2015-Sep-13 18:11 UTC
[llvm-dev] RFC: faster simplifyInstructionsInBlock/SimplifyInstructions pass
> > Instead of adding the operands to a list, erase the instruction and add them to the worklist wouldn’t be probably faster something like: > > if (Instruction *Used = dyn_cast<Instruction>(*OI)) > if (Used->hasOneUse()) > WorkList.insert(Used); > > If it has one use is going to be the instruction we are going to remove anyway, right?I don’t think this is strictly true, but someone correct me if I’m wrong: if you have %y = add i32 %x, %x %x will have two uses, but it will have zero if %y is deleted. This was the corner case I was worried about. —escha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150913/5ace6ad5/attachment.html>
Marcello Maggioni via llvm-dev
2015-Sep-13 18:32 UTC
[llvm-dev] RFC: faster simplifyInstructionsInBlock/SimplifyInstructions pass
> On 13 Sep 2015, at 11:11, escha <escha at apple.com> wrote: > >> >> Instead of adding the operands to a list, erase the instruction and add them to the worklist wouldn’t be probably faster something like: >> >> if (Instruction *Used = dyn_cast<Instruction>(*OI)) >> if (Used->hasOneUse()) >> WorkList.insert(Used); >> >> If it has one use is going to be the instruction we are going to remove anyway, right? > > I don’t think this is strictly true, but someone correct me if I’m wrong: if you have > > %y = add i32 %x, %x > > %x will have two uses, but it will have zero if %y is deleted. This was the corner case I was worried about.Yeah, I think you are right , I didn’t think about this case! Marcello> > —escha-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150913/fc6c3907/attachment.html>
escha via llvm-dev
2015-Sep-13 18:38 UTC
[llvm-dev] RFC: faster simplifyInstructionsInBlock/SimplifyInstructions pass
> On Sep 13, 2015, at 11:32 AM, Marcello Maggioni <mmaggioni at apple.com> wrote: > >> >> On 13 Sep 2015, at 11:11, escha <escha at apple.com <mailto:escha at apple.com>> wrote: >> >>> >>> Instead of adding the operands to a list, erase the instruction and add them to the worklist wouldn’t be probably faster something like: >>> >>> if (Instruction *Used = dyn_cast<Instruction>(*OI)) >>> if (Used->hasOneUse()) >>> WorkList.insert(Used); >>> >>> If it has one use is going to be the instruction we are going to remove anyway, right? >> >> I don’t think this is strictly true, but someone correct me if I’m wrong: if you have >> >> %y = add i32 %x, %x >> >> %x will have two uses, but it will have zero if %y is deleted. This was the corner case I was worried about. > > Yeah, I think you are right , I didn’t think about this case! > > Marcello > >> >> —eschaOn this note, I have a feeling that both IR and the DAG could use a hasOneUser() function… —escha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150913/2b2ac455/attachment.html>