[Local] Clean up EmitGEPOffset
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 4 Nov 2020 21:13:40 +0000 (22:13 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 13 Nov 2020 17:30:56 +0000 (18:30 +0100)
commit02dda1c659e8d675a20ace06dc060b787345b972
tree27e5d13d3c845e772fad5957d8af04eee15a4928
parente5a82b4594d700fe5afd2eaa7e03a213ac91d895
[Local] Clean up EmitGEPOffset

Handle the emission of the add in a single place, instead of three
different ones.

Don't emit an unnecessary add with zero to start with. It will get
dropped by InstCombine, but we may as well not create it in the
first place. This also means that InstCombine does not need to
specially handle this extra add.

This is conceptually NFC, but can affect worklist order etc.
llvm/include/llvm/Analysis/Utils/Local.h
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub-gep.ll