[llvm] 7255ce3 - [SelectionDAG] Fix incorrect condition for shift amount truncation
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 28 17:52:45 PDT 2021
Author: Itay Bookstein
Date: 2021-09-28T17:52:30-07:00
New Revision: 7255ce30e48feb07e4e82613f518683fbc247c1c
URL: https://github.com/llvm/llvm-project/commit/7255ce30e48feb07e4e82613f518683fbc247c1c
DIFF: https://github.com/llvm/llvm-project/commit/7255ce30e48feb07e4e82613f518683fbc247c1c.diff
LOG: [SelectionDAG] Fix incorrect condition for shift amount truncation
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.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D110509
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 7c16652451b4..83c3c1689b19 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3146,7 +3146,7 @@ void SelectionDAGBuilder::visitShift(const User &I, unsigned Opcode) {
// 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.
More information about the llvm-commits
mailing list