[PATCH] D35014: [X86] PR32755 : Improvement in CodeGen instruction selection for LEAs.

Lama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 04:50:25 PDT 2017


lsaba added inline comments.


================
Comment at: lib/Target/X86/X86OptimizeLEAs.cpp:839
+               MachineInstr *NewMI = 
+                  BuildMI(*(const_cast<MachineBasicBlock *>(&MBB)),
+                     &LI1,DL,TII->get(LI1.getOpcode()))
----------------
This could end up in an assertion failure if LI1 is at the beginning of the BB, need to handle it separately, for example in this reproducer :

 ; ModuleID = 'bugpoint-reduced-simplified.bc'
 source_filename = "bugpoint-output-2ef2e5d.bc"
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
 ; Function Attrs: norecurse nounwind readnone uwtable
 define i32 @foo(i32 %a, i32 %b, i32 %d, i32 %y, i32 %x) local_unnamed_addr #0 {
 entry:
   %mul1 = shl i32 %b, 1
   %add2 = add i32 %a, 4
   %add3 = add i32 %add2, %mul1
   %mul4 = shl i32 %b, 2
   %add6 = add i32 %add2, %mul4
   br label %for.body
 
 for.cond.cleanup:                                 ; preds = %for.body
   ret i32 %add
 
 for.body:                                         ; preds = %for.body, %entry
   %x.addr.015 = phi i32 [ %x, %entry ], [ %add3, %for.body ]
   %y.addr.014 = phi i32 [ %y, %entry ], [ %add6, %for.body ]
   %mul = mul nsw i32 %x.addr.015, %y.addr.014
   %add = add nsw i32 0, %mul
   %exitcond = icmp eq i32 undef, %d
   br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !1
 }
 
 attributes #0 = { norecurse nounwind readnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-       math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+   mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
 
 !llvm.ident = !{!0}
 
 !0 = !{!"clang version 6.0.0 (cfe/trunk 309511)"}
 !1 = distinct !{!1, !2}
 !2 = !{!"llvm.loop.unroll.disable"}



https://reviews.llvm.org/D35014





More information about the llvm-commits mailing list