[PATCH] D134236: [GlobalISel][Legalizer] Fix lowerSelect() not sign-extending the mask value.
Amara Emerson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 19 16:25:06 PDT 2022
aemerson created this revision.
aemerson added reviewers: arsenm, paquette.
aemerson added a project: LLVM.
Herald added subscribers: hiraditya, rovka.
Herald added a project: All.
aemerson requested review of this revision.
Herald added a subscriber: wdng.
I'm not sure why the SEXT_INREG was gated on a bitwidth check of the mask vs element size.
This fixes a miscompile in chromium's skia library.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134236
Files:
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-select.mir
Index: llvm/test/CodeGen/AArch64/GlobalISel/legalize-select.mir
===================================================================
--- llvm/test/CodeGen/AArch64/GlobalISel/legalize-select.mir
+++ llvm/test/CodeGen/AArch64/GlobalISel/legalize-select.mir
@@ -307,7 +307,8 @@
; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[C1]](s32), [[C1]](s32), [[C1]](s32), [[C1]](s32)
; CHECK-NEXT: %cmp:_(s1) = G_ICMP intpred(eq), %w0(s32), [[C]]
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT %cmp(s1)
- ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ZEXT]](s32)
+ ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[ZEXT]], 1
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[SEXT_INREG]](s32)
; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s1>) = G_IMPLICIT_DEF
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
; CHECK-NEXT: [[IVEC:%[0-9]+]]:_(<4 x s1>) = G_INSERT_VECTOR_ELT [[DEF]], [[TRUNC]](s1), [[C2]](s64)
Index: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -7247,8 +7247,7 @@
// The condition was potentially zero extended before, but we want a sign
// extended boolean.
- if (MaskTy.getSizeInBits() <= DstTy.getScalarSizeInBits() &&
- MaskTy != LLT::scalar(1)) {
+ if (MaskTy != LLT::scalar(1)) {
MaskElt = MIRBuilder.buildSExtInReg(MaskTy, MaskElt, 1).getReg(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134236.461408.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220919/fe1b7042/attachment.bin>
More information about the llvm-commits
mailing list