[GlobalISel][Utils] Add a getConstantVRegVal variant that looks through instrs
authorQuentin Colombet <quentin.colombet@gmail.com>
Thu, 14 Mar 2019 01:37:13 +0000 (01:37 +0000)
committerQuentin Colombet <quentin.colombet@gmail.com>
Thu, 14 Mar 2019 01:37:13 +0000 (01:37 +0000)
commite77e5f44b871faa775b2cfa289b35f900f9443ab
tree42c308960e044b69f92972ce4d5f29036b04b6e9
parent591040adc2666006b7242520f8b55e8960b07d71
[GlobalISel][Utils] Add a getConstantVRegVal variant that looks through instrs

getConstantVRegVal used to only look for G_CONSTANT when looking at
unboxing the value of a vreg. However, constants are sometimes not
directly used and are hidden behind trunc, s|zext or copy chain of
computation.

In particular this may be introduced by the legalization process that
doesn't want to simplify these patterns because it can lead to infine
loop when legalizing a constant.

To circumvent that problem, add a new variant of getConstantVRegVal,
named getConstantVRegValWithLookThrough, that allow to look through
extensions.

Differential Revision: https://reviews.llvm.org/D59227

llvm-svn: 356116
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/lib/CodeGen/GlobalISel/Utils.cpp
llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/select.ll
llvm/test/CodeGen/X86/GlobalISel/ashr-scalar.ll
llvm/test/CodeGen/X86/GlobalISel/lshr-scalar.ll
llvm/test/CodeGen/X86/GlobalISel/shl-scalar.ll