[PATCH] D110509: [SelectionDAG] Fix incorrect condition for shift amount truncation
Itay Bookstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 26 13:07:53 PDT 2021
nextsilicon-itay-bookstein created this revision.
nextsilicon-itay-bookstein added reviewers: bogner, craig.topper.
Herald added subscribers: ecnelises, hiraditya.
nextsilicon-itay-bookstein requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Comment says:
// If the operand is larger than the shift count type but the shift
// count type has enough bits to represent any shift value ...
It clearly talks about the shifted operand, not the shift-amount operand,
but the comparison is performed against Log2_32_Ceil(Op2.getValueSizeInBits())
where Op2 is the shift amount operand. This comparison also doesn't make
sense in the context of the previous one (ShiftsSize > Op2Size) because
Op2Size == Op2.getValueSizeInBits(). Fix to use Op1.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110509
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3146,7 +3146,7 @@
// count type has enough bits to represent any shift value, truncate
// it now. This is a common case and it exposes the truncate to
// optimization early.
- else if (ShiftSize >= Log2_32_Ceil(Op2.getValueSizeInBits()))
+ else if (ShiftSize >= Log2_32_Ceil(Op1.getValueSizeInBits()))
Op2 = DAG.getNode(ISD::TRUNCATE, DL, ShiftTy, Op2);
// Otherwise we'll need to temporarily settle for some other convenient
// type. Type legalization will make adjustments once the shiftee is split.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110509.375129.patch
Type: text/x-patch
Size: 790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210926/c75ab56b/attachment.bin>
More information about the llvm-commits
mailing list