[llvm] r343328 - [InstCombine] adjust shuffle undef propagation tests; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 08:20:06 PDT 2018


Author: spatel
Date: Fri Sep 28 08:20:06 2018
New Revision: 343328

URL: http://llvm.org/viewvc/llvm-project?rev=343328&view=rev
Log:
[InstCombine] adjust shuffle undef propagation tests; NFC

These are the updated baseline tests for D52548 -
I'm putting the tests next to the tests where the transform 
functions as expected, so we can see the intended/unintended
consequences.

Patch by: @sheredom (Neil Henning)

Removed:
    llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll
Modified:
    llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll

Removed: llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll?rev=343327&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll (removed)
@@ -1,200 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
-
-; For each of the div/rem integer instructions we test 3 different variants for
-; how an undef value could be back propagated:
-; 0) back propagation because of an undef shuffle vector mask
-; 1) back propagation because of an undef value selected from RHS
-; 2) back propagation because of an undef value selected from LHS
-
-define <3 x float> @udiv0(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @udiv0(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = udiv <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = uitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @udiv1(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @udiv1(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = udiv <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = uitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @udiv2(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @udiv2(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = udiv <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = uitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @sdiv0(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @sdiv0(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = sdiv <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = sitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @sdiv1(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @sdiv1(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = sdiv <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = sitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @sdiv2(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @sdiv2(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = sdiv <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = sitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @urem0(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @urem0(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = urem <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = uitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @urem1(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @urem1(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = urem <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = uitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @urem2(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @urem2(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = urem <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = uitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @srem0(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @srem0(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = srem <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = sitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @srem1(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @srem1(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = srem <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = sitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}
-
-define <3 x float> @srem2(<3 x float> %x, i32 %y, i32 %z) {
-; CHECK-LABEL: @srem2(
-; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4>
-; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]
-; CHECK-NEXT:    ret <3 x float> [[T6]]
-;
-  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0
-  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1
-  %t2 = srem <2 x i32> %t1, <i32 255, i32 255>
-  %t3 = sitofp <2 x i32> %t2 to <2 x float>
-  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0>
-  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4>
-  %t6 = fmul <3 x float> %x, %t5
-  ret <3 x float> %t6
-}

Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll?rev=343328&r1=343327&r2=343328&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Fri Sep 28 08:20:06 2018
@@ -184,6 +184,35 @@ define <2 x i8> @test13a(i8 %x1, i8 %x2)
   ret <2 x i8> %D
 }
 
+; TODO: Increasing length of vector ops is not a good canonicalization.
+ 
+define <3 x i32> @add_wider(i32 %y, i32 %z) {
+; CHECK-LABEL: @add(
+; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <3 x i32> undef, i32 [[Y:%.*]], i32 0
+; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <3 x i32> [[TMP1]], i32 [[Z:%.*]], i32 1
+; CHECK-NEXT:    [[TMP3:%.*]] = add <3 x i32> [[TMP2]], <i32 255, i32 255, i32 undef>
+; CHECK-NEXT:    ret <3 x i32> [[TMP3]]
+;
+  %i0 = insertelement <2 x i32> undef, i32 %y, i32 0
+  %i1 = insertelement <2 x i32> %i0, i32 %z, i32 1
+  %a = add <2 x i32> %i1, <i32 255, i32 255>
+  %ext = shufflevector <2 x i32> %a, <2 x i32> undef, <3 x i32> <i32 0, i32 1, i32 undef>
+  ret <3 x i32> %ext
+}
+
+; FIXME: Increasing length of vector ops must be safe from illegal undef propagation.
+
+define <3 x i32> @div_wider(i32 %y, i32 %z) {
+; CHECK-LABEL: @div(
+; CHECK-NEXT:    ret <3 x i32> undef
+;
+  %i0 = insertelement <2 x i32> undef, i32 %y, i32 0
+  %i1 = insertelement <2 x i32> %i0, i32 %z, i32 1
+  %a = sdiv <2 x i32> %i1, <i32 255, i32 255>
+  %ext = shufflevector <2 x i32> %a, <2 x i32> undef, <3 x i32> <i32 0, i32 1, i32 undef>
+  ret <3 x i32> %ext
+}
+
 define <2 x i8> @test13b(i8 %x) {
 ; CHECK-LABEL: @test13b(
 ; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i8> undef, i8 [[X:%.*]], i32 1




More information about the llvm-commits mailing list