[llvm] 26fa440 - [GlobalISel] Fix yet another pointer type invalid combining issue, this time in tryFoldSelectOfConstants()
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 15:58:35 PST 2024
Author: Amara Emerson
Date: 2024-03-07T15:58:28-08:00
New Revision: 26fa4409572ad81c5522165ba2a831845f4d0635
URL: https://github.com/llvm/llvm-project/commit/26fa4409572ad81c5522165ba2a831845f4d0635
DIFF: https://github.com/llvm/llvm-project/commit/26fa4409572ad81c5522165ba2a831845f4d0635.diff
LOG: [GlobalISel] Fix yet another pointer type invalid combining issue, this time in tryFoldSelectOfConstants()
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 4862207d53f492..ab055b723dbb1f 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -6369,6 +6369,9 @@ bool CombinerHelper::tryFoldSelectOfConstants(GSelect *Select,
if (CondTy != LLT::scalar(1))
return false;
+ if (TrueTy.isPointer())
+ return false;
+
// Both are scalars.
std::optional<ValueAndVReg> TrueOpt =
getIConstantVRegValWithLookThrough(True, MRI);
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir b/llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir
index 7b73c8cec47746..2bf7e84a379ba0 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir
@@ -859,3 +859,40 @@ body: |
RET_ReallyLR implicit $x0
...
+---
+name: dont_combine_pointer_type_select_of_constant
+alignment: 4
+liveins:
+ - { reg: '$w0' }
+ - { reg: '$x1' }
+body: |
+ bb.1:
+ liveins: $w0, $x1
+
+ ; CHECK-LABEL: name: dont_combine_pointer_type_select_of_constant
+ ; CHECK: liveins: $w0, $x1
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
+ ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s8) = G_ASSERT_ZEXT [[TRUNC]], 1
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s1) = G_TRUNC [[ASSERT_ZEXT]](s8)
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
+ ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[C1]](s64)
+ ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[TRUNC1]](s1), [[C]], [[INTTOPTR]]
+ ; CHECK-NEXT: G_STORE [[SELECT]](p0), [[COPY1]](p0) :: (store (p0))
+ ; CHECK-NEXT: RET_ReallyLR
+ %3:_(s32) = COPY $w0
+ %2:_(s8) = G_TRUNC %3(s32)
+ %1:_(p0) = COPY $x1
+ %4:_(s8) = G_ASSERT_ZEXT %2, 1
+ %0:_(s1) = G_TRUNC %4(s8)
+ %6:_(p0) = G_CONSTANT i64 0
+ %8:_(s64) = G_CONSTANT i64 -1
+ %7:_(p0) = G_INTTOPTR %8(s64)
+ %5:_(p0) = G_SELECT %0(s1), %6, %7
+ G_STORE %5(p0), %1(p0) :: (store (p0))
+ RET_ReallyLR
+
+...
More information about the llvm-commits
mailing list