[InstSimplify] Only check self-simplify in simplifyInstruction()
authorNikita Popov <npopov@redhat.com>
Mon, 17 Oct 2022 13:43:11 +0000 (15:43 +0200)
committerNikita Popov <npopov@redhat.com>
Mon, 17 Oct 2022 13:52:38 +0000 (15:52 +0200)
commitac74e7a7806480a000c9a3502405c3dedd8810de
treeb2b3118f68b4bb7869cdb816188a68d640addc81
parentc4331358fb9de83289b2638a77e8e08e41f56860
[InstSimplify] Only check self-simplify in simplifyInstruction()

InstSimplify currently checks whether the instruction simplifies
back to itself, and returns undef in that case. Generally, this
should only occur in unreachable code.

However, this was also done for the simplifyInstructionWithOperands()
API. In that case, the instruction only serves as a template that
provides the opcode and other non-operand data. In this case,
simplifying back to the same "instruction" may be expected. This
caused PR58401 in conjunction with D134954.

As such, move this check into simplifyInstruction() only. The only
other caller of simplifyInstructionWithOperands() also handles the
self-simplification case explicitly.
llvm/lib/Analysis/InstructionSimplify.cpp