[DAGCombine] Remove SIGN_EXTEND-related inf-loop
authorHal Finkel <hfinkel@anl.gov>
Mon, 6 Oct 2014 20:19:47 +0000 (20:19 +0000)
committerHal Finkel <hfinkel@anl.gov>
Mon, 6 Oct 2014 20:19:47 +0000 (20:19 +0000)
commit807111a8f434293f84bbd1171a953197e40819d1
tree2c63f59e59af92adf0d29b2cfcde26a188a3886a
parentb67100314b9128e74a8a6d816a060c7d3943f665
[DAGCombine] Remove SIGN_EXTEND-related inf-loop

The patch's author points out that, despite the function's documentation,
getSetCCResultType is only used to get the SETCC result type (with one
here-removed problematic exception). In one case, getSetCCResultType was being
used to get the predicate type to use for a SELECT node, and then
SIGN_EXTENDing (or truncating) to get the input predicate to match that type.
Unfortunately, this was happening inside visitSIGN_EXTEND, and creating new
SIGN_EXTEND nodes was causing an infinite loop. In addition, this behavior was
wrong if a target was not using ZeroOrNegativeOneBooleanContent. Lastly, the
extension/truncation seems unnecessary here: SELECT is defined as:

  Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not i1
  then the high bits must conform to getBooleanContents.

So here we remove this use of getSetCCResultType and update
getSetCCResultType's documentation to reflect its actual uses.

Patch by deadal nix!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219141 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/sext-i1.ll