[PATCH] D150556: [ValueTracking] Fix computeKnownFPClass with canonicalize
Piotr Sobczak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 05:22:31 PDT 2023
piotr created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
piotr requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Update code that assumes llvm.canonicalize only handles scalars,
by adding a call to getScalarType().
This is fine, as the intrinsic is trivially vectorizable.
Introduced in D147870 <https://reviews.llvm.org/D147870>, and uncovered by D148065 <https://reviews.llvm.org/D148065>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150556
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/canonicalize.ll
Index: llvm/test/Transforms/InstCombine/canonicalize.ll
===================================================================
--- llvm/test/Transforms/InstCombine/canonicalize.ll
+++ llvm/test/Transforms/InstCombine/canonicalize.ll
@@ -457,5 +457,20 @@
ret i1 %cmp
}
+; --------------------------------------------------------------------
+; Others
+; --------------------------------------------------------------------
+
+; Regression test checking that the vector version of llvm.canonicalize works.
+define <2 x i1> @vec_canonicalize_with_fpclass(<2 x float> %x) {
+; CHECK-LABEL: @vec_canonicalize_with_fpclass(
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
+;
+ %canon = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> %x)
+ %fpclass = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> %canon, i32 1)
+ ret <2 x i1> %fpclass
+}
+
declare float @llvm.canonicalize.f32(float)
declare <2 x float> @llvm.canonicalize.v2f32(<2 x float>)
+declare <2 x i1> @llvm.is.fpclass.v2f32(<2 x float>, i32 immarg)
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4801,7 +4801,8 @@
// If the parent function flushes denormals, the canonical output cannot
// be a denormal.
- const fltSemantics &FPType = II->getType()->getFltSemantics();
+ const fltSemantics &FPType =
+ II->getType()->getScalarType()->getFltSemantics();
DenormalMode DenormMode = II->getFunction()->getDenormalMode(FPType);
if (DenormMode.inputsAreZero() || DenormMode.outputsAreZero())
Known.knownNot(fcSubnormal);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150556.522127.patch
Type: text/x-patch
Size: 1708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230515/55399933/attachment.bin>
More information about the llvm-commits
mailing list