[PATCH] D43449: [SelectionDAG] Add LegalTypes flag to getShiftAmountTy. Use it to unify and simplify DAGCombiner and simplifySetCC code and fix a bug.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 18 16:53:24 PST 2018


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.

DAGCombiner and SimplifySetCC both use getPointerTy for shift amounts pre-legalization. DAGCombiner uses a single helper function to hide this. SimplifySetCC does it in multiple places.

This patch adds a defaulted parameter to getShiftAmountTy that can make it return getPointerTy for scalar types. Use this parameter to simplify the SimplifySetCC and DAGCombiner.

Additionally, there were two places in SimplifySetCC that were creating shifts using the target's preferred shift amount pre-legalization. If the target uses a narrow type and the type is illegal, this can cause SimplfiySetCC to create a shift with an amount that can't represent all possible shift values for the type. To fix this we should use pointer type there too.

Alternatively we could make getScalarShiftAmountTy for each target return a safe value for large types as proposed in https://reviews.llvm.org/D43445. And maybe we should still do that, but fixing the SimplifySetCC code keeps other targets from tripping over this in the future.

Fixes PR36250.


Repository:
  rL LLVM

https://reviews.llvm.org/D43449

Files:
  include/llvm/CodeGen/TargetLowering.h
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/X86/legalize-shift.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43449.134850.patch
Type: text/x-patch
Size: 6906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180219/867a29c8/attachment.bin>


More information about the llvm-commits mailing list