[PATCH] D88432: [InstCombine] Fix pr47668

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 10:31:23 PDT 2020


aqjune created this revision.
aqjune added reviewers: lebedev.ri, spatel, craig.topper.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aqjune requested review of this revision.

This patch fixes pr47668 (https://llvm.org/pr47668) by checking whether the shift amount is smaller than the bitwidth of variables.

This is done by checking whether Z is a constant and it is smaller than the bitwidth.

When the shift amount is undef, it is unsafe in theory because 1 << undef is poison, causing the miscompilation happen again.
To prevent this, I made the undef simply fold into zero, since shl 0 can be optimized later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88432

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/select-of-bittest.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88432.294750.patch
Type: text/x-patch
Size: 12357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200928/a84af44a/attachment.bin>


More information about the llvm-commits mailing list