[PATCH] D30502: [DAGCombiner] fold binops with constant into select-of-constants

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 08:35:57 PST 2017


spatel created this revision.
Herald added subscribers: nemanjai, mcrosier, aemerson.

This is part of the ongoing attempt to improve select codegen for all targets and select canonicalization in IR (see https://reviews.llvm.org/D24480 for more background).
The transform is a subset of what is done in InstCombine's FoldOpIntoSelect().

I first noticed a regression in the x86 avx512-insert-extract.ll tests with a patch that hopes to convert more selects to basic math ops. This appears to be a general missing DAG transform though, so I added tests for all standard binops in https://reviews.llvm.org/rL296621 (PowerPC was chosen semi-randomly; it has scripted FileCheck support, but so do ARM and x86).

The debug output for "sel_constants_shl_constant" makes me think that this patch is not at fault for that mess. The shl fold happens as expected. PPC then changes the i8 select to an i32 select, but the return value is i64, so the extend gets folded in creating an i64 select. I noticed this problem in a lesser form in https://reviews.llvm.org/D30180; it's why there weren't more improvements for PPC with that patch.


https://reviews.llvm.org/D30502

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/ARM/select_xform.ll
  test/CodeGen/PowerPC/select_const.ll
  test/CodeGen/X86/2010-08-04-MaskedSignedCompare.ll
  test/CodeGen/X86/avx512-insert-extract.ll
  test/CodeGen/X86/setcc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30502.90182.patch
Type: text/x-patch
Size: 34743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170301/3b5458fb/attachment.bin>


More information about the llvm-commits mailing list