Skip to content

Commit 879e506

Browse files
nikicAlexisPerry
authored andcommitted
[IR] Mark shl constant expression as undesirable (llvm#95940)
Mark shl constant expressions undesirable, so that they are no longer automatically created by IRBuilder, constant folding, etc. This is in preparation for removing them entirely.
1 parent 1741bc6 commit 879e506

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

llvm/lib/IR/Constants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2324,11 +2324,11 @@ bool ConstantExpr::isDesirableBinOp(unsigned Opcode) {
23242324
case Instruction::Or:
23252325
case Instruction::LShr:
23262326
case Instruction::AShr:
2327+
case Instruction::Shl:
23272328
return false;
23282329
case Instruction::Add:
23292330
case Instruction::Sub:
23302331
case Instruction::Mul:
2331-
case Instruction::Shl:
23322332
case Instruction::Xor:
23332333
return true;
23342334
default:

llvm/test/CodeGen/AArch64/stack-tagging-initializer-merge.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ define void @InitVectorSplit() sanitize_memtag {
304304
; CHECK-NEXT: [[TX:%.*]] = call ptr @llvm.aarch64.tagp.p0(ptr [[X]], ptr [[BASETAG]], i64 0)
305305
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 16, ptr nonnull [[X]])
306306
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[TX]], i32 1
307+
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 bitcast (<2 x i32> <i32 1, i32 2> to i64), 32
307308
; CHECK-NEXT: [[LSHR:%.*]] = lshr i64 bitcast (<2 x i32> <i32 1, i32 2> to i64), 32
308-
; CHECK-NEXT: call void @llvm.aarch64.stgp(ptr [[TX]], i64 shl (i64 bitcast (<2 x i32> <i32 1, i32 2> to i64), i64 32), i64 [[LSHR]])
309+
; CHECK-NEXT: call void @llvm.aarch64.stgp(ptr [[TX]], i64 [[TMP1]], i64 [[LSHR]])
309310
; CHECK-NEXT: call void @use(ptr nonnull [[TX]])
310311
; CHECK-NEXT: call void @llvm.aarch64.settag(ptr [[X]], i64 16)
311312
; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 16, ptr nonnull [[X]])

llvm/test/CodeGen/AMDGPU/lower-buffer-fat-pointers-constants.ll

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ define ptr addrspace(7) @gep_p7_from_p7() {
143143
define i160 @ptrtoint() {
144144
; CHECK-LABEL: define i160 @ptrtoint
145145
; CHECK-SAME: () #[[ATTR0]] {
146-
; CHECK-NEXT: [[TMP1:%.*]] = or i160 shl nuw (i160 ptrtoint (ptr addrspace(8) @buf to i160), i160 32), 12
147-
; CHECK-NEXT: ret i160 [[TMP1]]
146+
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw i160 ptrtoint (ptr addrspace(8) @buf to i160), 32
147+
; CHECK-NEXT: [[TMP2:%.*]] = or i160 [[TMP1]], 12
148+
; CHECK-NEXT: ret i160 [[TMP2]]
148149
;
149150
ret i160 ptrtoint(
150151
ptr addrspace(7) getelementptr(
@@ -155,8 +156,9 @@ define i160 @ptrtoint() {
155156
define i256 @ptrtoint_long() {
156157
; CHECK-LABEL: define i256 @ptrtoint_long
157158
; CHECK-SAME: () #[[ATTR0]] {
158-
; CHECK-NEXT: [[TMP1:%.*]] = or i256 shl nuw nsw (i256 ptrtoint (ptr addrspace(8) @buf to i256), i256 32), 12
159-
; CHECK-NEXT: ret i256 [[TMP1]]
159+
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i256 ptrtoint (ptr addrspace(8) @buf to i256), 32
160+
; CHECK-NEXT: [[TMP2:%.*]] = or i256 [[TMP1]], 12
161+
; CHECK-NEXT: ret i256 [[TMP2]]
160162
;
161163
ret i256 ptrtoint(
162164
ptr addrspace(7) getelementptr(
@@ -167,8 +169,9 @@ define i256 @ptrtoint_long() {
167169
define i64 @ptrtoint_short() {
168170
; CHECK-LABEL: define i64 @ptrtoint_short
169171
; CHECK-SAME: () #[[ATTR0]] {
170-
; CHECK-NEXT: [[TMP1:%.*]] = or i64 shl (i64 ptrtoint (ptr addrspace(8) @buf to i64), i64 32), 12
171-
; CHECK-NEXT: ret i64 [[TMP1]]
172+
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 ptrtoint (ptr addrspace(8) @buf to i64), 32
173+
; CHECK-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 12
174+
; CHECK-NEXT: ret i64 [[TMP2]]
172175
;
173176
ret i64 ptrtoint(
174177
ptr addrspace(7) getelementptr(

0 commit comments

Comments
 (0)