[PATCH] D57260: Reapply rL352238: [WarnMissedTransforms] Set default to 1.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 25 14:42:19 PST 2019


asbirlea created this revision.
asbirlea added reviewers: Meinersbur, hfinkel, dmgreen.
Herald added a subscriber: jlebar.

Set default value for retrieved attributes to 1, since the check is against 1 (if attribute value does not exist, no warnings should be emitted).
Eliminates the warning noise generated when the attributes are not present.
Update tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D57260

Files:
  lib/Transforms/Scalar/WarnMissedTransforms.cpp
  test/Transforms/LoopTransformWarning/vectorization-remarks-missed.ll
  test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
  test/Transforms/LoopVectorize/no_array_bounds.ll
  test/Transforms/LoopVectorize/no_switch.ll


Index: test/Transforms/LoopVectorize/no_switch.ll
===================================================================
--- test/Transforms/LoopVectorize/no_switch.ll
+++ test/Transforms/LoopVectorize/no_switch.ll
@@ -3,15 +3,10 @@
 ; RUN: opt < %s -loop-vectorize -force-vector-width=4 -transform-warning -pass-remarks-missed='loop-vectorize' -S 2>&1 | FileCheck %s -check-prefix=MOREINFO
 
 ; CHECK: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
-; CHECK: warning: source.cpp:4:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
-
 ; NOANALYSIS-NOT: remark: {{.*}}
-; NOANALYSIS: warning: source.cpp:4:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
 
 ; MOREINFO: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
 ; MOREINFO: remark: source.cpp:4:5: loop not vectorized (Force=true, Vector Width=4)
-; MOREINFO: warning: source.cpp:4:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
-
 ; CHECK: _Z11test_switchPii
 ; CHECK-NOT: x i32>
 ; CHECK: ret
Index: test/Transforms/LoopVectorize/no_array_bounds.ll
===================================================================
--- test/Transforms/LoopVectorize/no_array_bounds.ll
+++ test/Transforms/LoopVectorize/no_array_bounds.ll
@@ -1,8 +1,7 @@
 ; RUN: opt < %s -loop-vectorize -transform-warning -S 2>&1 | FileCheck %s
 
-; Verify warning is generated when vectorization/ interleaving is explicitly specified and fails to occur.
-; CHECK: warning: no_array_bounds.cpp:5:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
-; CHECK: warning: no_array_bounds.cpp:10:5: loop not interleaved: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
+; Verify warning is generated when vectorization/ interleaving is explicitly specified and fails to occur. The llvm.loop.vectorize.width and llvm.loop.interleave.count metadata needs to be set forthat loop
+; CHECK-LABEL: @_Z4testPiS_i
 
 ;  #pragma clang loop vectorize(enable)
 ;  for (int i = 0; i < number; i++) {
Index: test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
+++ test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
@@ -33,7 +33,6 @@
 ; }
 ; CHECK: remark: source.cpp:19:5: loop not vectorized: cannot identify array bounds
 ; CHECK: remark: source.cpp:19:5: loop not vectorized
-; CHECK: warning: source.cpp:19:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
 
 ; int foo();
 ; void test_multiple_failures(int *A) {
@@ -93,14 +92,6 @@
 ; YAML-NEXT:   - Force:           'true'
 ; YAML-NEXT:   - String:          ')'
 ; YAML-NEXT: ...
-; YAML-NEXT: --- !Failure
-; YAML-NEXT: Pass:            transform-warning
-; YAML-NEXT: Name:            FailedRequestedVectorization
-; YAML-NEXT: DebugLoc:        { File: source.cpp, Line: 19, Column: 5 }
-; YAML-NEXT: Function:        _Z17test_array_boundsPiS_i
-; YAML-NEXT: Args:
-; YAML-NEXT:   - String:          'loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering'
-; YAML-NEXT: ...
 ; YAML-NEXT: --- !Analysis
 ; YAML-NEXT: Pass:            loop-vectorize
 ; YAML-NEXT: Name:            NoCFGForSelect
Index: test/Transforms/LoopTransformWarning/vectorization-remarks-missed.ll
===================================================================
--- test/Transforms/LoopTransformWarning/vectorization-remarks-missed.ll
+++ test/Transforms/LoopTransformWarning/vectorization-remarks-missed.ll
@@ -8,6 +8,8 @@
 ; RUN: opt < %s -passes=transform-warning -disable-output -pass-remarks-output=%t.yaml
 ; RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
 
+; No warnings should be emitted unless the "llvm.loop.vectorize.width" is attached to the loop.
+; XFAIL: *
 
 ; C/C++ code for tests
 ; void test(int *A, int Length) {
Index: lib/Transforms/Scalar/WarnMissedTransforms.cpp
===================================================================
--- lib/Transforms/Scalar/WarnMissedTransforms.cpp
+++ lib/Transforms/Scalar/WarnMissedTransforms.cpp
@@ -51,7 +51,7 @@
     Optional<int> InterleaveCount =
         getOptionalIntLoopAttribute(L, "llvm.loop.interleave.count");
 
-    if (VectorizeWidth.getValueOr(0) != 1)
+    if (VectorizeWidth.getValueOr(1) != 1)
       ORE->emit(
           DiagnosticInfoOptimizationFailure(DEBUG_TYPE,
                                             "FailedRequestedVectorization",
@@ -59,7 +59,7 @@
           << "loop not vectorized: the optimizer was unable to perform the "
              "requested transformation; the transformation might be disabled "
              "or specified as part of an unsupported transformation ordering");
-    else if (InterleaveCount.getValueOr(0) != 1)
+    else if (InterleaveCount.getValueOr(1) != 1)
       ORE->emit(
           DiagnosticInfoOptimizationFailure(DEBUG_TYPE,
                                             "FailedRequestedInterleaving",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57260.183626.patch
Type: text/x-patch
Size: 5858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190125/0790ea95/attachment.bin>


More information about the llvm-commits mailing list