Skip to content

Commit eb009ed

Browse files
committed
[GlobalISel] Fix the select->minmax combine from trying to operate on pointer types.
1 parent 58b33d0 commit eb009ed

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6555,6 +6555,9 @@ bool CombinerHelper::tryFoldSelectToIntMinMax(GSelect *Select,
65556555
Register False = Select->getFalseReg();
65566556
LLT DstTy = MRI.getType(DstReg);
65576557

6558+
if (DstTy.isPointer())
6559+
return false;
6560+
65586561
// We need an G_ICMP on the condition register.
65596562
GICmp *Cmp = getOpcodeDef<GICmp>(Cond, MRI);
65606563
if (!Cmp)

llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,3 +825,30 @@ body: |
825825
%sel:_(<4 x s32>) = exact G_SELECT %c, %t, %f
826826
$q0 = COPY %sel(<4 x s32>)
827827
...
828+
---
829+
name: dont_combine_pointer_type
830+
body: |
831+
bb.1:
832+
liveins: $x0
833+
834+
; CHECK-LABEL: name: dont_combine_pointer_type
835+
; CHECK: liveins: $x0
836+
; CHECK-NEXT: {{ $}}
837+
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
838+
; CHECK-NEXT: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
839+
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[C]](p0) :: (load (p0))
840+
; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ugt), [[LOAD]](p0), [[C]]
841+
; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[ICMP]](s1), [[LOAD]], [[C]]
842+
; CHECK-NEXT: G_STORE [[SELECT]](p0), [[COPY]](p0) :: (store (p0))
843+
; CHECK-NEXT: $x0 = COPY [[C]](p0)
844+
; CHECK-NEXT: RET_ReallyLR implicit $x0
845+
%0:_(p0) = COPY $x0
846+
%2:_(p0) = G_CONSTANT i64 0
847+
%1:_(p0) = G_LOAD %2(p0) :: (load (p0))
848+
%3:_(s1) = G_ICMP intpred(ugt), %1(p0), %2
849+
%4:_(p0) = G_SELECT %3(s1), %1, %2
850+
G_STORE %4(p0), %0(p0) :: (store (p0))
851+
$x0 = COPY %2(p0)
852+
RET_ReallyLR implicit $x0
853+
854+
...

0 commit comments

Comments
 (0)